diff --git a/CHANGELOG.md b/CHANGELOG.md index 62ce81fd5..7f73ed19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,16 @@ ## unreleased -- The first-website tutorial now lets you choose an installation target, copy a command, or download an archive for macOS, Windows, Linux, or AWS Lambda. -- Missing component pages on the official site return HTTP 404 and link to the catalog. Action buttons in colored alerts stay readable. +- Big number title links have a larger target for touch and pointer users. +- Carousel slide indicators and pagination arrows now have accessible names. Keyboard users can activate carousel arrows and enabled pagination links. Screen readers announce the current page. +- Button, card, carousel, and login images accept alternative text. Embedded card frames use their own title or the card title. +- Inline links are underlined so they stand out without relying on color. The documentation search button has a clear accessible name separate from its shortcut hint. +- Disabled buttons expose their state to assistive technology and cannot be activated. +- Tracking blocks without links now expose their titles to screen readers. - The `shell` sidebar now uses `navbar_title` and preserves the colors of the supplied logo in dark mode. - Chart export menus, tooltips, and series colors now follow the theme surrounding each chart, including in custom shells. Chart labels on colored marks have a contrasting outline that carries over to SVG downloads. - Map marker popups follow the surrounding theme so their titles and links stay readable. - Each `login` component’s labels target its own fields. Set `false AS autofocus` to keep the username field from taking focus when the page opens. -- The official documentation now connects tutorials, component examples, and the function reference through shared navigation. Browse by task, open search with Ctrl+K or ⌘K, and share a link to a specific parameter. Code blocks have copy controls. Wide examples show SQL beside the live result. -- Improved contrast for text and controls across the official SQLPage site. - JSON `shell` menu items with a link are now links in the accessibility tree instead of being announced as buttons; only submenu toggles keep `role="button"`. - The new [`status_bar` component](https://sql-page.com/component.sql?component=status_bar) displays short status messages and links along the bottom of the screen or inline with page content. - A file input with `multiple` now keeps every selected file, instead of only the last one. The new [`sqlpage.persist_uploaded_files`](https://sql-page.com/functions.sql?function=persist_uploaded_files) function saves them all and returns a JSON array with the `path`, original `name`, `mime_type` and `size` of each file. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e55e268c6..128ef1568 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,6 +67,10 @@ built executable. Component suites use `fixtures//{index.sql,test.ts}` an import the shared `fixture.ts` harness; root-level `*.spec.ts` files cover the official site. +Run `npx playwright test --grep @accessibility` from `tests/end-to-end` to audit +the official site's component documentation and its live examples in SQLPage's +stock light and dark themes with axe-core. The normal Playwright suite also runs it. + To show that an issue exists before you fix it, put the reproduction in a fixture and run it against releases with one command, such as `nix run .#reproduce -- repro_721 postgres v0.35.0 v0.36.1 tree`. The second argument is `sqlite` or `postgres`, and `tree` is your working tree. It prints Playwright's output for each version, then a table you can paste into the issue or pull request. Releases run from their Docker images, from v0.29.0 onwards, and Postgres from `docker compose`. Without Nix, run `npm run reproduce --` in `tests/end-to-end` instead. To run a whole suite against a release instead, set `SQLPAGE_RELEASE` to its tag, such as `SQLPAGE_RELEASE=v0.47.0 npx playwright test fixtures/tracking`. Both servers then run that release's Docker image against the same fixtures, on ports 18080 and 18081, so the test fails on the release and passes on your working tree. Add `--ui` to watch the page in each step. diff --git a/examples/official-site/README.md b/examples/official-site/README.md index 5c5fa9440..f44983a13 100644 --- a/examples/official-site/README.md +++ b/examples/official-site/README.md @@ -22,6 +22,10 @@ Run SQLPage from that directory, or run `docker compose -f examples/official-site/docker-compose.yml up --build` from the repository root. +Add `theme=light` or `theme=dark` to a component reference URL to preview its +live examples using SQLPage's stock theme. For example, visit +`/component.sql?component=form&theme=light`. + ## Landing page The home page is rendered by `index.sql` and the `landing-page` custom template. diff --git a/examples/official-site/assets/docs/shell.css b/examples/official-site/assets/docs/shell.css index ffcf594d0..376e4f0f1 100644 --- a/examples/official-site/assets/docs/shell.css +++ b/examples/official-site/assets/docs/shell.css @@ -40,6 +40,11 @@ } .docs-search kbd { + position: absolute; + z-index: 5; + inset-inline-end: 2.25rem; + align-self: center; + pointer-events: none; font: var(--tblr-font-size-h5) var(--tblr-font-monospace); } @@ -49,6 +54,12 @@ } } +@media (width >= 62rem) and (not (pointer: coarse)) { + .docs-search:has(kbd:not([hidden])) input { + padding-inline-end: 3rem; + } +} + .docs-columns { display: flex; flex-direction: column; @@ -111,6 +122,10 @@ } @media (min-width: 62rem) { + .docs-search:has(kbd:not([hidden])) input { + padding-inline-end: 3rem; + } + .docs-columns { flex-direction: row; align-items: flex-start; diff --git a/examples/official-site/sqlpage/docs-shell.sql b/examples/official-site/sqlpage/docs-shell.sql index ded481c17..364127321 100644 --- a/examples/official-site/sqlpage/docs-shell.sql +++ b/examples/official-site/sqlpage/docs-shell.sql @@ -7,6 +7,10 @@ select 'shell-docs' as component, $options->>'title' as title, $options->>'description' as description, $options->>'css' as css, + case sqlpage.variables('get')->>'theme' + when 'light' then 'light' + when 'dark' then 'dark' + end as stock_theme, $section as section, cast($catalog as integer) as catalog, coalesce($kind || 's', 'guides') as topic_label, diff --git a/examples/official-site/sqlpage/migrations/18_button.sql b/examples/official-site/sqlpage/migrations/18_button.sql index 94104ca1b..4cfd80e88 100644 --- a/examples/official-site/sqlpage/migrations/18_button.sql +++ b/examples/official-site/sqlpage/migrations/18_button.sql @@ -117,3 +117,6 @@ INSERT INTO example(component, description, properties) VALUES "image":"https://upload.wikimedia.org/wikipedia/commons/f/fa/Globe.svg" }]') ); + +INSERT INTO parameter(component, name, description, type, top_level, optional) VALUES + ('button', 'image_alt', 'Alternative text for an informative button image. Leave empty if decorative or repeated by the button title.', 'TEXT', FALSE, TRUE); diff --git a/examples/official-site/sqlpage/migrations/31_card_docs_update.sql b/examples/official-site/sqlpage/migrations/31_card_docs_update.sql index 44633ee2c..25e79b5f2 100644 --- a/examples/official-site/sqlpage/migrations/31_card_docs_update.sql +++ b/examples/official-site/sqlpage/migrations/31_card_docs_update.sql @@ -70,9 +70,9 @@ INSERT INTO example(component, description, properties) VALUES ('card', 'A gallery of images.', json('[ {"component":"card", "title":"My favorite animals in pictures", "columns": 3}, - {"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Lynx_lynx_-_05.jpg/330px-Lynx_lynx_-_05.jpg", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true, "icon":"star" }, - {"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/American_squirrel_eating_nut%2C_13_Jun_2013.JPG/330px-American_squirrel_eating_nut%2C_13_Jun_2013.JPG", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true }, - {"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Australian_orb_weaver_spinning_web.jpg/330px-Australian_orb_weaver_spinning_web.jpg", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true } + {"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image_alt": "A Eurasian lynx", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Lynx_lynx_-_05.jpg/330px-Lynx_lynx_-_05.jpg", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true, "icon":"star" }, + {"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image_alt": "A squirrel eating a nut", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/American_squirrel_eating_nut%2C_13_Jun_2013.JPG/330px-American_squirrel_eating_nut%2C_13_Jun_2013.JPG", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true }, + {"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image_alt": "An orb weaver spinning a web", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Australian_orb_weaver_spinning_web.jpg/330px-Australian_orb_weaver_spinning_web.jpg", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true } ]')), ('card', 'Beautifully colored cards with variable width. The blue card (width 6) takes half the screen, whereas of the red and green cards have the default width of 3', json('[ @@ -87,3 +87,7 @@ INSERT INTO example(component, description, properties) VALUES {"title": "Embedded Chart", "embed": "/examples/chart.sql?_sqlpage_embed" }, {"title": "Embedded Video", "embed": "https://www.youtube.com/embed/mXdgmSdaXkg", "allow": "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share", "embed_mode": "iframe", "height": "350" } ]')); + +INSERT INTO parameter(component, name, description, type, top_level, optional) VALUES + ('card', 'top_image_alt', 'Alternative text for an informative card image. Leave empty if decorative.', 'TEXT', FALSE, TRUE), + ('card', 'embed_title', 'Accessible name of the iframe. Defaults to the card title, or Embedded content if no title is set.', 'TEXT', FALSE, TRUE); diff --git a/examples/official-site/sqlpage/migrations/34_carousel.sql b/examples/official-site/sqlpage/migrations/34_carousel.sql index 2de411174..70f74b53b 100644 --- a/examples/official-site/sqlpage/migrations/34_carousel.sql +++ b/examples/official-site/sqlpage/migrations/34_carousel.sql @@ -134,6 +134,9 @@ VALUES FALSE, TRUE ); +INSERT INTO parameter(component, name, description, type, top_level, optional) VALUES + ('carousel', 'image_alt', 'Alternative text describing the slide image. Leave empty if the image is decorative or its caption already describes it.', 'TEXT', FALSE, TRUE); + -- Insert example(s) for the component INSERT INTO example(component, description, properties) VALUES ( @@ -142,8 +145,8 @@ VALUES ( JSON( '[ {"component":"carousel","name":"cats1","title":"Famous Database Animals"}, - {"image":"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Elefantes_africanos_de_sabana_%28Loxodonta_africana%29%2C_Elephant_Sands%2C_Botsuana%2C_2018-07-28%2C_DD_114-117_PAN.jpg/1280px-Elefantes_africanos_de_sabana_%28Loxodonta_africana%29%2C_Elephant_Sands%2C_Botsuana%2C_2018-07-28%2C_DD_114-117_PAN.jpg"}, - {"image":"https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Penguin_Island_panorama_with_ferry_and_dolphins_in_foreground%2C_March_2023_06.jpg/1280px-Penguin_Island_panorama_with_ferry_and_dolphins_in_foreground%2C_March_2023_06.jpg"} + {"image_alt":"African elephants at a watering hole","image":"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Elefantes_africanos_de_sabana_%28Loxodonta_africana%29%2C_Elephant_Sands%2C_Botsuana%2C_2018-07-28%2C_DD_114-117_PAN.jpg/1280px-Elefantes_africanos_de_sabana_%28Loxodonta_africana%29%2C_Elephant_Sands%2C_Botsuana%2C_2018-07-28%2C_DD_114-117_PAN.jpg"}, + {"image_alt":"A panoramic view of Penguin Island","image":"https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Penguin_Island_panorama_with_ferry_and_dolphins_in_foreground%2C_March_2023_06.jpg/1280px-Penguin_Island_panorama_with_ferry_and_dolphins_in_foreground%2C_March_2023_06.jpg"} ]' ) ), diff --git a/examples/official-site/sqlpage/migrations/68_login.sql b/examples/official-site/sqlpage/migrations/68_login.sql index 12a6d4867..11d29de18 100644 --- a/examples/official-site/sqlpage/migrations/68_login.sql +++ b/examples/official-site/sqlpage/migrations/68_login.sql @@ -74,3 +74,6 @@ There, you will have access to the variables: ) ), ('login', 'Basic login form', JSON('[{"component": "login", "username": "Username", "password": "Password", "autofocus": false}]')); + +INSERT INTO parameter(component, name, description, type, top_level, optional) VALUES + ('login', 'image_alt', 'Alternative text for an informative login image. Leave empty if decorative.', 'TEXT', TRUE, TRUE); diff --git a/examples/official-site/sqlpage/templates/shell-docs.handlebars b/examples/official-site/sqlpage/templates/shell-docs.handlebars index 30dfc4a1f..a4687a922 100644 --- a/examples/official-site/sqlpage/templates/shell-docs.handlebars +++ b/examples/official-site/sqlpage/templates/shell-docs.handlebars @@ -1,5 +1,5 @@ - + @@ -12,7 +12,9 @@ - + {{#unless stock_theme}} + + {{/unless}} {{#if catalog}} @@ -49,8 +51,9 @@ {{#unless (eq section "Search")}} {{/unless}} diff --git a/frontend/src/sqlpage.css b/frontend/src/sqlpage.css index bd653bc3a..8f49f8b4c 100644 --- a/frontend/src/sqlpage.css +++ b/frontend/src/sqlpage.css @@ -227,3 +227,10 @@ See https://github.com/tabler/tabler/issues/2404 color: inherit; text-decoration: underline; } + +/* Keep inline prose links identifiable without relying on color. */ +:is(p, .markdown li, .remove-bottom-margin li) > a:not([class]), +.form-hint a, +.form-label-description a { + text-decoration: underline; +} diff --git a/package-lock.json b/package-lock.json index d6d8f9697..3491092d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,22 @@ "typescript": "^7.0.2" } }, + "node_modules/@axe-core/playwright": { + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.14.0.tgz", + "integrity": "sha512-SGUhG5PIHd2eMdpgBF2PyQLOhX+qyDR2PT4cmoS4Qk2ak+jX/rrSvst9l0PGv5WTHolKpUMvVmoHpr4cZgf1RQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "axe-core": "~4.14.0" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "playwright-core": ">= 1.0.0" + } + }, "node_modules/@biomejs/biome": { "version": "2.6.6", "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.6.6.tgz", @@ -1069,10 +1085,33 @@ "node": "^20.19.0 || ^22.12.0 || >=24.0.0" } }, + "node_modules/axe-core": { + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.14.1.tgz", + "integrity": "sha512-FHfa+lmNjQZfJz1q8wKqIDwC6DExcHt/pkjNQb09a3NPjCKg2rhu5qb2S4r76ASyFNNtuFooJpZe37OgudVGtQ==", + "dev": true, + "license": "MPL-2.0", + "engines": { + "node": ">=4" + } + }, "node_modules/end-to-end": { "resolved": "tests/end-to-end", "link": true }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/rolldown": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.3.1.tgz", @@ -1179,6 +1218,7 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { + "@axe-core/playwright": "^4.14.0", "@playwright/test": "~1.64.1" } }, @@ -1213,19 +1253,6 @@ "engines": { "node": ">=20" } - }, - "tests/end-to-end/node_modules/playwright-core": { - "version": "1.64.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", - "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "playwright-core": "cli.js" - }, - "engines": { - "node": ">=20" - } } } } diff --git a/sqlpage/templates/big_number.handlebars b/sqlpage/templates/big_number.handlebars index 8f469376f..aa2656f4c 100644 --- a/sqlpage/templates/big_number.handlebars +++ b/sqlpage/templates/big_number.handlebars @@ -15,7 +15,7 @@
{{~#if embed ~}} {{~#if (eq embed_mode "iframe")}} -