-
Notifications
You must be signed in to change notification settings - Fork 96
Add some wrong things #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| /* eslint-disable jsx-a11y/no-noninteractive-tabindex */ | ||
| /* eslint-disable jsx-a11y/alt-text */ | ||
| import Image from "next/legacy/image" | ||
| import { NavPage } from "../NavPage/NavPage" | ||
| import { CodeBlock } from "../CodeBlock/CodeBlock" | ||
|
|
@@ -8,6 +10,12 @@ import { PageUpdated } from "../PageUpdated/PageUpdated" | |
| export const ImagesTemplate = () => { | ||
| return ( | ||
| <> | ||
| <img src="/images/imagesTemplate/oldPaperTexture.jpg"></img> | ||
| <div role="button"> | ||
| Testing | ||
| <div role="menuitem">123</div> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WCAG 1.3.1: Role "menuitem" must be contained within: menu, menubar, group. Certain ARIA roles must be contained within specific parent roles. DetailsSome ARIA roles represent items that must exist within specific container roles. For example, a listitem must be within a list, a tab must be within a tablist. Wrap the element in the appropriate parent, or use native HTML elements that provide this structure (e.g., |
||
| </div> | ||
| <div tabIndex={0}>Testing tabindex</div> | ||
| <NavPage pageNavigation={imagePageNavigation} /> | ||
| <article> | ||
| <TemplateSection sectionName="introduction" title="Introduction"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # URL Mapping Script for Axe Testing | ||
|
|
||
| This script automatically detects which content pages have changed in a git diff and maps them to their corresponding URLs for accessibility testing with axe-core. | ||
|
|
||
| ## How it works | ||
|
|
||
| 1. **Detects changed files** using `git diff`: | ||
| - In PR context: compares against the base branch | ||
| - In push context: compares against the previous commit | ||
|
|
||
| 2. **Maps components to URLs** by: | ||
| - Reading `data/pages.ts` to get the page URL mapping | ||
| - Checking if changed files are template components (e.g., `AudioTemplate.tsx`) | ||
| - Converting template names to content slugs (e.g., `AudioTemplate` → `audio` → `/audio`) | ||
|
|
||
| 3. **Special cases**: | ||
| - If layout components change (Header, Footer, Nav, Layout), includes homepage | ||
| - If data files change, includes homepage + first few pages as sanity check | ||
| - If no relevant changes detected, defaults to homepage | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| # Get URLs with homepage included | ||
| node scripts/get-changed-urls.js http://localhost:3000 --include-home | ||
|
|
||
| # Get URLs without forcing homepage (only affected pages) | ||
| node scripts/get-changed-urls.js http://localhost:3000 | ||
| ``` | ||
|
|
||
| ## Output | ||
|
|
||
| The script outputs URLs (one per line): | ||
|
|
||
| ``` | ||
| http://localhost:3000 | ||
| http://localhost:3000/audio | ||
| http://localhost:3000/forms | ||
| ``` | ||
|
|
||
| ## In GitHub Actions | ||
|
|
||
| The workflow calls this script and pipes each URL to `axe` for accessibility testing. See `.github/workflows/axe.yaml` for the full implementation. | ||
|
|
||
| ## Extending the mapping | ||
|
|
||
| To add new pages: | ||
| 1. Add the page to `data/pages.ts` with a `content` field | ||
| 2. Add the corresponding template name mapping in this script's `templateNameMap` object | ||
| 3. The script will automatically detect changes to that template | ||
|
|
||
| Example: | ||
| ```javascript | ||
| // In data/pages.ts | ||
| { name: "Example", href: "/example", content: "example" } | ||
|
|
||
| // In scripts/get-changed-urls.js | ||
| const templateNameMap = { | ||
| // ... existing mappings | ||
| ExampleTemplate: "example", | ||
| }; | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| #!/usr/bin/env node | ||
| /* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
|
||
| /** | ||
| * Get list of URLs to scan based on changed files in git. | ||
| * Maps changed component templates back to their URLs using data/pages.ts | ||
| * | ||
| * Usage: | ||
| * node scripts/get-changed-urls.js [baseUrl] [--include-home] | ||
| * | ||
| * Example: | ||
| * node scripts/get-changed-urls.js http://localhost:3000 --include-home | ||
| */ | ||
|
|
||
| const fs = require("fs") | ||
| const path = require("path") | ||
| const { execSync } = require("child_process") | ||
|
|
||
| const baseUrl = process.argv[2] || "http://localhost:3000" | ||
| const includeHome = process.argv.includes("--include-home") | ||
|
|
||
| // Get git changes | ||
| let changedFiles = [] | ||
| try { | ||
| let diff | ||
| // Check if running in PR context (GitHub Actions sets GITHUB_BASE_SHA) | ||
| if (process.env.GITHUB_BASE_SHA) { | ||
| // For PR: compare against base branch SHA | ||
| diff = execSync( | ||
| `git diff --name-only ${process.env.GITHUB_BASE_SHA}...HEAD` | ||
| ).toString() | ||
| } else { | ||
| // For push: compare against previous commit | ||
| diff = execSync("git diff --name-only HEAD~1 HEAD").toString() | ||
| } | ||
| changedFiles = diff.trim().split("\n").filter(Boolean) | ||
| } catch (error) { | ||
| console.error("Error getting changed files:", error.message) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| // Read pages data to build URL mapping | ||
| let pagesData | ||
| try { | ||
| const pagesContent = fs.readFileSync( | ||
| path.join(__dirname, "../data/pages.ts"), | ||
| "utf-8" | ||
| ) | ||
|
|
||
| // Extract the pages array from the TypeScript file | ||
| const regex = /export const pages: IPage\[\] = \[([\s\S]*?)\]/ | ||
| const match = pagesContent.match(regex) | ||
| if (!match) { | ||
| console.error("Could not parse pages.ts") | ||
| process.exit(1) | ||
| } | ||
|
|
||
| pagesData = [] | ||
| const arrayContent = match[1] | ||
|
|
||
| // Parse each page entry | ||
| const pageRegex = | ||
| /{\s*name:\s*"([^"]+)",\s*href:\s*"([^"]+)",\s*content:\s*"([^"]+)"\s*}/g | ||
| let pageMatch | ||
| while ((pageMatch = pageRegex.exec(arrayContent)) !== null) { | ||
| pagesData.push({ | ||
| name: pageMatch[1], | ||
| href: pageMatch[2], | ||
| content: pageMatch[3], | ||
| }) | ||
| } | ||
| } catch (error) { | ||
| console.error("Error parsing pages.ts:", error.message) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| // Map component/template files to content names | ||
| const templateNameMap = { | ||
| AlertsTemplate: "alerts", | ||
| AnimationsTemplate: "animations", | ||
| AudioTemplate: "audio", | ||
| BreadcrumbsTemplate: "breadcrumbs", | ||
| ButtonsTemplate: "buttons", | ||
| CaptchasTemplate: "captchas", | ||
| ChartsTemplate: "charts", | ||
| FormsTemplate: "forms", | ||
| HeadingsTemplate: "headings", | ||
| IconsTemplate: "icons", | ||
| ImagesTemplate: "images", | ||
| LinksTemplate: "links", | ||
| ListsTemplate: "lists", | ||
| MenusTemplate: "menus", | ||
| ModalsTemplate: "modals", | ||
| NavigationTemplate: "navigation", | ||
| PaginationTemplate: "pagination", | ||
| TablesTemplate: "tables", | ||
| VideoTemplate: "video", | ||
| } | ||
|
|
||
| // Find which URLs need to be scanned | ||
| const urlsToScan = new Set() | ||
|
|
||
| // Always include homepage if flag is set or if certain key files change | ||
| if (includeHome) { | ||
| urlsToScan.add(baseUrl) | ||
| } | ||
|
|
||
| for (const file of changedFiles) { | ||
| // Check if it's a content template file | ||
| for (const [templateName, contentName] of Object.entries(templateNameMap)) { | ||
| if (file.includes(templateName)) { | ||
| // Find the corresponding page | ||
| const page = pagesData.find((p) => p.content === contentName) | ||
| if (page) { | ||
| urlsToScan.add(`${baseUrl}${page.href}`) | ||
| } | ||
| break | ||
| } | ||
| } | ||
|
|
||
| // If pages.ts or data files changed, include home and some key pages | ||
| if (file.includes("data/") || file.includes("utils.ts")) { | ||
| urlsToScan.add(baseUrl) | ||
| // Add first few pages as sanity check | ||
| pagesData.slice(0, 3).forEach((page) => { | ||
| urlsToScan.add(`${baseUrl}${page.href}`) | ||
| }) | ||
| break | ||
| } | ||
|
|
||
| // If layout/core components changed, scan home | ||
| if ( | ||
| file.includes("components/Layout/") || | ||
| file.includes("components/Header/") || | ||
| file.includes("components/Footer/") || | ||
| file.includes("components/Nav/") | ||
| ) { | ||
| urlsToScan.add(baseUrl) | ||
| } | ||
| } | ||
|
|
||
| // Output URLs | ||
| if (urlsToScan.size === 0) { | ||
| // No relevant changes detected, just scan homepage | ||
| console.log(baseUrl) | ||
| } else { | ||
| console.log(Array.from(urlsToScan).join("\n")) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WCAG 1.1.1: Image element missing alt attribute.
Images must have alternate text. Add an alt attribute to
<img>elements. Decorative images may use an empty alt attribute (alt=""), role='none', or role='presentation'.Details
Adjacent text: /* eslint-disable jsx-a11y/no-noninteractive-tabindex /
/ eslint-disable jsx-a11y/alt-text */
impo
Every image needs an alt attribute. For informative images, describe the content or function concisely. For decorative images (backgrounds, spacers, purely visual flourishes), use alt='' to hide them from screen readers. Never omit alt entirely—screen readers may read the filename instead.