Skip to content

Commit a541c7f

Browse files
committed
Improve Library navigation and site keyboard accessibility
1 parent 77f800c commit a541c7f

13 files changed

Lines changed: 306 additions & 14 deletions

File tree

‎bench/site-ux.mjs‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Full generated-site layout and automated accessibility audit.
2+
// Run after npm run build, against npm run preview. CHROME_PATH selects Chrome.
3+
import {chromium} from 'playwright-core';
4+
import {readFileSync,readdirSync,mkdirSync,writeFileSync} from 'node:fs';
5+
import {relative,join,resolve} from 'node:path';
6+
import {fileURLToPath} from 'node:url';
7+
const root=resolve(fileURLToPath(new URL('..',import.meta.url))),out=process.env.CHECK_OUTPUT??'/tmp/devutils-site-ux-audit',base=process.env.CHECK_BASE_URL??'http://127.0.0.1:5178';mkdirSync(out,{recursive:true});
8+
const walk=dir=>readdirSync(dir,{withFileTypes:true}).flatMap(e=>e.isDirectory()?walk(join(dir,e.name)):e.name.endsWith('.html')?[join(dir,e.name)]:[]);
9+
const records=walk(root+'/dist').map(file=>{const html=readFileSync(file,'utf8');return {route:'/'+relative(root+'/dist',file).replace(/index\.html$/,''),redirect:/http-equiv="refresh"/i.test(html),indexable:!/<meta[^>]+name="robots"[^>]+noindex/i.test(html)}});
10+
const axe=readFileSync(root+'/node_modules/axe-core/axe.min.js','utf8');const browser=await chromium.launch({executablePath:process.env.CHROME_PATH,headless:true,args:['--no-sandbox']});
11+
const results=[],issues=[];let completed=0;
12+
try{
13+
for(const width of [1440,375]){
14+
const context=await browser.newContext({viewport:{width,height:1000},reducedMotion:'reduce'});let cursor=0;
15+
await Promise.all(Array.from({length:3},async(_,worker)=>{
16+
const page=await context.newPage();let active='';page.on('pageerror',error=>issues.push({width,route:active,type:'javascript',message:error.message}));
17+
while(cursor<records.length){const record=records[cursor++];active=record.route;
18+
try{
19+
const response=await page.goto(base+record.route,{waitUntil:'load',timeout:30000});
20+
if(record.redirect)await page.waitForFunction(()=>!!document.querySelector('h1'),undefined,{timeout:10000});
21+
const layout=await page.evaluate(()=>({title:document.title,headings:document.querySelectorAll('h1').length,overflow:document.documentElement.scrollWidth>innerWidth+1,font:getComputedStyle(document.body).fontFamily,main:!!document.querySelector('main'),height:document.documentElement.scrollHeight}));
22+
if(response.status()!==200)issues.push({width,route:active,type:'http',status:response.status()});
23+
if(layout.headings!==1||!layout.main||layout.overflow)issues.push({width,route:active,type:'layout',...layout});
24+
let violations=[];
25+
if(!record.redirect){await page.addScriptTag({content:axe});violations=await page.evaluate(async()=> (await axe.run({runOnly:{type:'tag',values:['wcag2a','wcag2aa','wcag21aa']}})).violations.map(v=>({id:v.id,impact:v.impact,description:v.description,nodes:v.nodes.map(n=>({target:n.target,summary:n.failureSummary})).slice(0,8)})));
26+
for(const violation of violations)issues.push({width,route:active,type:'accessibility',...violation});
27+
}
28+
results.push({route:active,width,redirect:record.redirect,indexable:record.indexable,status:response.status(),...layout,violations:violations.length});
29+
if(['/','/tools/','/about/','/design/','/contributions/','/together/','/library/','/fr/library/','/figures/','/learn/','/history/','/tools/atfq/'].includes(active))await page.screenshot({path:`${out}/${active==='/'?'home':active.replaceAll('/','-').slice(1,-1)}-${width}.png`,fullPage:false});
30+
}catch(error){issues.push({width,route:active,type:'exception',message:String(error)});results.push({route:active,width,failed:true});}
31+
completed++;if(completed%40===0){console.log(`${completed}/${records.length*2} visits; ${issues.length} findings`);writeFileSync(out+'/progress.json',JSON.stringify({completed,total:records.length*2,issues},null,2));}
32+
}
33+
await page.close();
34+
}));await context.close();
35+
}
36+
writeFileSync(out+'/results.json',JSON.stringify({generatedAt:new Date().toISOString(),routes:records.length,visits:results.length,results,issues},null,2));
37+
const aggregate={};for(const issue of issues){const key=issue.type+':'+(issue.id??'');aggregate[key]=(aggregate[key]??0)+1;}
38+
console.log(JSON.stringify({routes:records.length,visits:results.length,findings:issues.length,aggregate,report:out+'/results.json'}));
39+
}finally{await browser.close();}
40+
if(issues.length)process.exitCode=1;
41+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Site UI/UX audit — 29 October 2026
2+
3+
The Library keeps the site's existing art direction: Inter, the near-black background, cyan/violet accents, gradient headings, glass panels, shared corner radii and light pill buttons. Its entry points are reorganized around search, three starting paths, an expandable subject index and history/figures/labs. Counts and course links come from the published content. Untranslated entries and the English search default are explicit.
4+
5+
## Scope and evidence
6+
7+
The production build contains 484 HTML documents: 24 main/tool pages, 233 Library documents, 153 book documents and 74 redirect documents. The full browser sweep made 968 visits at 1440px and 375px. Redirect destinations were checked; automated WCAG A/AA checks ran on the non-redirect documents. The sweep checks HTTP responses, main landmarks, one primary heading, horizontal overflow, runtime exceptions and automated accessibility findings. It does not constitute a manual WCAG certification or user research.
8+
9+
The initial sweep found 148 page/viewport occurrences of one issue class: non-focusable scrollable regions. The second sweep found zero accessibility or layout issues. Additionally, all 217 published article documents were checked on mobile with their native details panels expanded: no horizontal overflow or automated accessibility findings.
10+
11+
Representative screenshots were inspected for the home page, Tools, About and Library in desktop/mobile layouts. Existing designs and navigation conventions were retained.
12+
13+
## Corrections
14+
15+
- Library surfaces and controls use the shared glass treatment, colors and radii instead of a separate opaque violet palette.
16+
- Article contents on mobile are a native disclosure below the title. They remain available without JavaScript; the desktop contents rail is retained.
17+
- Installation commands, terminal regions and Omniscient's session examples can receive keyboard focus for scrolling.
18+
- All book code blocks become focusable during the build. The site's book stylesheet supplies their cyan focus outline. These adaptations also work without JavaScript and survive a fresh upstream book export followed by the site build.
19+
- Book arrow-key scrolling inside code does not trigger previous/next-page shortcuts. Closed book sidebars are inert, Escape closes the mobile sidebar, and dismissing search restores focus to its button.
20+
- Mobile auto-selection and incidental pointer hover on tool workflow cards no longer override keyboard-focused cards.
21+
22+
## Validation
23+
24+
- `npm test`: 74 tests pass.
25+
- `npm run build`: HTML, Pagefind, internal links and SEO checks pass. Two existing editorial SEO notices remain on History titles/descriptions.
26+
- `bench/navigation.ts`: 88 navigation layouts across desktop/tablet/phone widths, EN/FR, JavaScript on/off.
27+
- `bench/home.ts`: 12 home/catalog pairs, including 320px and no-JavaScript rendering.
28+
- `bench/contributions.ts`: eight desktop/mobile pages, downloads and bilingual navigation.
29+
- `bench/section-navigation.ts`: 16 layouts, centered content, desktop rail and mobile contents.
30+
- `bench/history.ts`: 44 page layout/accessibility checks plus chapter navigation, timeline filters, aliases and ten search targets.
31+
- Library hub: eight EN/FR viewport checks at 375, 768, 1024 and 1440px; 61 course links; keyboard disclosures; actual search submissions; automated accessibility.
32+
- Additional interaction scenarios: 23 passes covering terminal tabs, workflow cards, command copying, book search/sidebar/code scrolling, mobile article contents and no-JavaScript keyboard access.
33+
34+
The full generated-site sweep is reproducible after starting `npm run preview -- --host 127.0.0.1 --port 5178`:
35+
36+
```sh
37+
CHROME_PATH=/path/to/chrome node bench/site-ux.mjs
38+
```
39+
40+
`CHECK_BASE_URL` and `CHECK_OUTPUT` override the server and artifact directory. The command writes per-document results, findings and screenshots and exits unsuccessfully when findings remain. Session artifacts are in `/private/tmp/devutils-site-ux-audit/`; additional checks and captures are in the respective `/tmp/devutils-*-check/` directories and `/private/tmp/library-ux-*` files. Browser evidence is from headless Chrome with reduced motion; other browser engines were not exercised.
41+
42+
## Qualitative follow-up beyond Library
43+
44+
Hero buttons explored during the follow-up were removed after visual review with the site owner: the opening sections preserve space for the existing animation. The shared hero renderer and both home languages retain their original action-free composition.
45+
46+
- Contributions: Projects navigation leads to the actual project records rather than the preceding explanation. Evidence, metrics and dated upstream statuses are retained.
47+
- The 320px follow-up exposed overflowing ATFQ layer examples; their code regions now support keyboard scrolling.
48+
49+
Before the hero-button removal, the follow-up covered 24 main/tool pages in EN/FR at 1440, 375 and 320px, with 72 passing anchor, responsive and automated accessibility checks. Home and Contributions also passed their existing no-JavaScript and bilingual browser checks. These checks are not user research.

‎scripts/prerender.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
//
66
// Run after `vite build` and `vite build --ssr src/prerender.ts --outDir .ssr`.
77

8-
import { readFile, writeFile } from 'node:fs/promises'
8+
import { copyFile, readFile, readdir, writeFile } from 'node:fs/promises'
99
import { resolve } from 'node:path'
1010
import { fill } from '../src/fill.ts'
11+
import { focusableBookCode, initBookAccessibility } from '../src/atfq-book/accessibility.ts'
1112

1213
const { pages }: typeof import('../src/prerender.ts') = await import(resolve(import.meta.dirname, '../.ssr/prerender.js'))
1314
const dist = resolve(import.meta.dirname, '../dist')
@@ -17,3 +18,15 @@ for (const { file, parts } of pages) {
1718
await writeFile(path, fill(await readFile(path, 'utf8'), parts, file))
1819
console.log(`prerendered ${file}`)
1920
}
21+
22+
// Preserve upstream book content while applying the site's keyboard behavior
23+
// and stylesheet on every build, including after a fresh upstream export.
24+
const bookDir = resolve(dist, 'tools/atfq/book')
25+
for (const file of (await readdir(bookDir)).filter(file => file.endsWith('.html'))) {
26+
const path = resolve(bookDir, file)
27+
await writeFile(path, focusableBookCode(await readFile(path, 'utf8')))
28+
}
29+
await copyFile(resolve(import.meta.dirname, '../src/atfq-book/book.css'), resolve(bookDir, 'book.css'))
30+
const bookScript = resolve(bookDir, 'book.js')
31+
const enhancement = '\n/* devutils-book-accessibility */'
32+
await writeFile(bookScript, (await readFile(bookScript, 'utf8')).split(enhancement)[0] + `${enhancement}\n;(${initBookAccessibility.toString()})();\n`)

‎src/atfq-book/accessibility.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Site-owned adaptation of the exported ATFQ book. Applied at build time so
2+
// code blocks also remain keyboard-scrollable with JavaScript disabled.
3+
export function focusableBookCode(html: string) {
4+
return html.replace(/<pre\b([^>]*)>/gi, (tag, attributes: string) => /\btabindex\s*=/i.test(attributes) ? tag : `<pre${attributes} tabindex="0">`)
5+
}
6+
7+
// Kept self-contained: the build appends this function to the book's script.
8+
export function initBookAccessibility() {
9+
const root = document.documentElement
10+
const sidebar = document.getElementById('sidebar')
11+
const sidebarButton = document.getElementById('toggle-sidebar')
12+
const search = document.getElementById('search')
13+
const searchButton = document.getElementById('toggle-search')
14+
if (!sidebar || !sidebarButton || !search || !searchButton) return
15+
const narrow = matchMedia('(max-width: 900px)')
16+
const syncSidebar = () => {
17+
const visible = narrow.matches ? root.classList.contains('sidebar-open') : !root.classList.contains('sidebar-hidden')
18+
sidebar.inert = !visible
19+
sidebarButton.setAttribute('aria-expanded', String(visible))
20+
if (!visible && sidebar.contains(document.activeElement)) sidebarButton.focus()
21+
}
22+
new MutationObserver(syncSidebar).observe(root, { attributes: true, attributeFilter: ['class'] })
23+
narrow.addEventListener('change', syncSidebar)
24+
syncSidebar()
25+
search.setAttribute('role', 'search')
26+
search.setAttribute('aria-label', 'Search the book')
27+
let searchWasOpen = !search.hidden
28+
const syncSearch = () => {
29+
searchButton.setAttribute('aria-expanded', String(!search.hidden))
30+
if (searchWasOpen && search.hidden) searchButton.focus()
31+
searchWasOpen = !search.hidden
32+
}
33+
new MutationObserver(syncSearch).observe(search, { attributes: true, attributeFilter: ['hidden'] })
34+
syncSearch()
35+
document.addEventListener('keydown', event => {
36+
// Let native arrow-key scrolling work inside code; do not turn the page
37+
// through the book's document-level navigation shortcuts.
38+
if (event.target instanceof Element && event.target.closest('pre') && ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'h', 'j', 'k', 'l'].includes(event.key)) event.stopPropagation()
39+
if (event.key === 'Escape' && narrow.matches && root.classList.contains('sidebar-open')) {
40+
root.classList.remove('sidebar-open')
41+
syncSidebar()
42+
sidebarButton.focus()
43+
}
44+
}, true)
45+
}

‎src/atfq-book/book.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ body {
4949
background-attachment: fixed;
5050
}
5151
a { color: var(--accent); text-underline-offset: 3px; }
52-
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
52+
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, [tabindex]:focus-visible {
5353
outline: 2px solid var(--accent);
5454
outline-offset: 3px;
5555
border-radius: 6px;

‎src/contributions/content.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ export function contributionsPage(lang: Lang): Page {
2626
primary: t('Read the reports', 'Lire les rapports'),
2727
},
2828
sections: [
29-
{ type: 'intro', id: 'projects', scene: 'projects', eyebrow: t('THE PROJECTS', 'LES PROJETS'), title: [t('A project,', 'Un projet,'), t('a traceable contribution.', 'une contribution traçable.')], text: t('Each project has its own record: what it does, what was investigated, what changed and what remains proposed. RUG is the first published case.', 'Chaque projet a sa fiche : ce qu’il fait, ce qui a été étudié, ce qui change et ce qui reste proposé. RUG est le premier cas présenté.'), columns: [
29+
{ type: 'intro', id: 'overview', scene: 'projects', eyebrow: t('THE PROJECTS', 'LES PROJETS'), title: [t('A project,', 'Un projet,'), t('a traceable contribution.', 'une contribution traçable.')], text: t('Each project has its own record: what it does, what was investigated, what changed and what remains proposed. RUG is the first published case.', 'Chaque projet a sa fiche : ce qu’il fait, ce qui a été étudié, ce qui change et ce qui reste proposé. RUG est le premier cas présenté.'), columns: [
3030
[t('Analysis', 'Analyse'), t('A reproducible baseline, concrete workloads and tool capabilities verified before drawing conclusions.', 'Une référence reproductible, des charges concrètes et des capacités d’outils vérifiées avant de conclure.')],
3131
[t('Changes', 'Changements'), t('Focused fixes and measured optimizations, accompanied by regression tests and reproduction commands.', 'Des correctifs ciblés et des optimisations mesurées, accompagnés de tests et de commandes de reproduction.')],
3232
[t('Upstream status', 'Statut en amont'), t('An open pull request is a proposal. It is not a merged fix or a maintainer endorsement.', 'Une PR ouverte est une proposition. Ce n’est ni un correctif intégré, ni une approbation du mainteneur.')],
3333
] },
34-
{ type: 'html', scene: 'project-list', eyebrow: t('CONTRIBUTION RECORDS', 'DOSSIERS DE CONTRIBUTION'), title: [t('Start with the project.', 'Commencer par le projet.'), t('Follow the evidence.', 'Suivre les preuves.')], text: t('The reports and upstream contributions are linked from each project page.', 'Les rapports et les contributions en amont sont accessibles depuis chaque fiche.'), body: `<div class="contribution-projects">${projects.map(project => `<article class="contribution-project glass reveal"><div class="contribution-project-heading"><p class="eyebrow">${esc(project.language)} · ${esc(project.kind[lang])}</p><span class="contribution-status open">${project.evidence.pullRequests.length} ${t('proposals submitted', 'propositions soumises')}</span></div><h3><a href="${projectRoute(project.slug, lang)}">${esc(project.name)} ${icon('arrow-up-right')}</a></h3><p>${esc(project.description[lang])}</p><ul class="contribution-tags">${project.activities[lang].map(label => `<li>${esc(label)}</li>`).join('')}</ul><div class="contribution-project-actions"><a class="primary" href="${projectRoute(project.slug, lang)}">${t('Read the case', 'Lire le dossier')} ${esc(project.name)} ${icon('arrow-up-right')}</a>${link(project.repository, t('Upstream repository', 'Dépôt d’origine'))}</div></article>`).join('')}</div>` },
34+
{ type: 'html', id: 'projects', scene: 'project-list', eyebrow: t('CONTRIBUTION RECORDS', 'DOSSIERS DE CONTRIBUTION'), title: [t('Start with the project.', 'Commencer par le projet.'), t('Follow the evidence.', 'Suivre les preuves.')], text: t('The reports and upstream contributions are linked from each project page.', 'Les rapports et les contributions en amont sont accessibles depuis chaque fiche.'), body: `<div class="contribution-projects">${projects.map(project => `<article class="contribution-project glass reveal"><div class="contribution-project-heading"><p class="eyebrow">${esc(project.language)} · ${esc(project.kind[lang])}</p><span class="contribution-status open">${project.evidence.pullRequests.length} ${t('proposals submitted', 'propositions soumises')}</span></div><h3><a href="${projectRoute(project.slug, lang)}">${esc(project.name)} ${icon('arrow-up-right')}</a></h3><p>${esc(project.description[lang])}</p><ul class="contribution-tags">${project.activities[lang].map(label => `<li>${esc(label)}</li>`).join('')}</ul><div class="contribution-project-actions"><a class="primary" href="${projectRoute(project.slug, lang)}">${t('Read the case', 'Lire le dossier')} ${esc(project.name)} ${icon('arrow-up-right')}</a>${link(project.repository, t('Upstream repository', 'Dépôt d’origine'))}</div></article>`).join('')}</div>` },
3535
{ type: 'flow', id: 'approach', scene: 'approach', eyebrow: t('THE APPROACH', 'LA DÉMARCHE'), title: [t('Observe first.', 'Observer d’abord.'), t('Measure the change.', 'Mesurer le changement.')], text: t('Tools supply evidence; analysis connects the measurements to the code. Every result has a stated scope.', 'Les outils apportent des preuves ; l’analyse relie les mesures au code. Chaque résultat a un périmètre explicite.'), steps: [
3636
{ glyph: '01', label: t('Baseline', 'Référence'), title: t('Build and characterize', 'Compiler et caractériser'), text: t('Pin the source revision, reproduce the build, identify workload and constraints.', 'Fixer la révision, reproduire la compilation, identifier la charge et ses contraintes.') },
3737
{ glyph: '02', label: t('Investigation', 'Investigation'), title: t('Profile and explain', 'Profiler et expliquer'), text: t('Use the available sources, retain refusals and losses, test a source-based hypothesis.', 'Utiliser les sources disponibles, conserver refus et pertes, tester une hypothèse issue du code.') },

0 commit comments

Comments
 (0)