diff --git a/.github/upstream-state/modern-web-guidance/modern-web-guidance b/.github/upstream-state/modern-web-guidance/modern-web-guidance new file mode 100644 index 0000000..6cd70d9 --- /dev/null +++ b/.github/upstream-state/modern-web-guidance/modern-web-guidance @@ -0,0 +1 @@ +64a6d708f5a43f2cd3fde5d4d7db3905ba1bdf65 diff --git a/skills/modern-web-guidance/SKILL.md b/skills/modern-web-guidance/SKILL.md index fdab1a7..7483c78 100644 --- a/skills/modern-web-guidance/SKILL.md +++ b/skills/modern-web-guidance/SKILL.md @@ -14,13 +14,13 @@ Search and retrieve standardized modern web best practices at the **start** of i ### Step 1. Search Use Cases -Run `modern-web-guidance` directly with `npx` using a **2–5 word action-oriented query** for a **single web platform capability or UI pattern**: +Run `modern-web-guidance` directly with `npx` using a **2–5 word action-oriented English query** for a **single web platform capability or UI pattern**: - **Keep queries focused and generic**: Describe the user-visible capability (` + `, optionally paired with the target HTML/CSS/JS feature name if known). Omit framework/library names (`React`, `Vue`, `Tailwind`, etc.) and app/domain nouns (product, route, or component/file names). Split multi-feature tasks into separate `search` calls. - **Name implied UI primitives**: When the user's prompt expresses intent without naming the UI primitive (e.g. "confirm first", "delete with confirmation", "pick a date"), translate the domain intent into the implied UI component or platform mechanism (e.g. search `"confirmation modal dialog"` or `"confirm dialog"` rather than `"confirm destructive action"`, or `"date picker input"` rather than `"pick a date"`). - **Example**: Search `"light dismiss dialog"` or `"responsive data table"`, **not** `"dialog"` (too terse), `"responsive table dark mode"` (compound — split into two searches), or `"close React settings modal on outside click"` (framework/app noise). ```sh -npx -y modern-web-guidance@latest search "" --skill-version 2026_11_09-5bcc021b +npx -y modern-web-guidance@latest search "" --skill-version 2026_11_10-47b4c80e ``` > **Note**: Returns `[{ "id", "description" }, ...]`. Judge results by their `description` fields: diff --git a/skills/modern-web-guidance/guides/built-in-ai/translator.md b/skills/modern-web-guidance/guides/built-in-ai/translator.md index a9b8229..b3966bd 100644 --- a/skills/modern-web-guidance/guides/built-in-ai/translator.md +++ b/skills/modern-web-guidance/guides/built-in-ai/translator.md @@ -2,7 +2,6 @@ The **Translator API** allows developers to perform client-side text translation using built-in AI models in Chrome and Edge. This approach eliminates the need for cloud-based translation services for ephemeral content, reducing costs and improving privacy by keeping data on the user's device. - ## Prerequisites & Requirements ### API Surface & Global Scope @@ -38,6 +37,7 @@ To run Gemini Nano and associated models, the system needs: **User Gesture Requirement:** When calling `availability(options)` returns `'downloadable'` or `'downloading'`, calling `Translator.create()` triggers the download of the language pack and **strictly requires a user gesture** (such as a button click) to prevent a `NotAllowedError`. `Translator.availability(options)` returns one of four string statuses: + - `'available'`: The language pair model is already downloaded on the device and ready for immediate translation. - `'downloadable'`: The language pair is supported, but the model needs to be downloaded. A user gesture is required to initiate `Translator.create()`. - `'downloading'`: The language pack is currently in the process of downloading. Calling `Translator.create()` with a user gesture attaches to the download. @@ -152,12 +152,18 @@ The API supports a wide range of BCP 47 language codes: Here are the languages s - **zh**: Chinese - **zh-Hant**: Chinese (Traditional) +## Accessibility considerations + +**MANDATORY:** Apply the `lang` attribute to the container element for the translated content, and make sure that its value matches the BCP 47 language code for the target language, for example `lang="es"` for Spanish. + ## Security & Performance - **Permissions Policy:** Cross-origin iframes require explicit permission. + ```html ``` + - **Web Workers:** Currently **not supported** due to Permission Policy complexities. - **Privacy:** No data is sent to Google servers during the translation process @@ -179,9 +185,10 @@ if ('Translator' in self) { } ``` -If the `Translator` API is unsupported or availability checks return `'unavailable'`, you must gracefully fall back. +If the `Translator` API is unsupported or availability checks return `'unavailable'`, you must gracefully fall back. Recommended options: + 1. **Remote API Fallback**: Redirect the translation request to a server endpoint or cloud remote API (such as the Vertex AI Gemini API) to deliver translation functionality. 2. **Graceful Degradation**: Visually disable translation control elements or buttons while showing an end-user friendly note (e.g., `"Client-side translation is currently unsupported in this browser"`). Do not allow unhandled exceptions. 3. **Polyfill Fallback**: You can use community-maintained polyfills like `built-in-ai-task-apis-polyfills` or `prompt-api-polyfill` to emulate the API surface using remote services. diff --git a/skills/modern-web-guidance/guides/css/css-layout.md b/skills/modern-web-guidance/guides/css/css-layout.md index 4555879..086f7b7 100644 --- a/skills/modern-web-guidance/guides/css/css-layout.md +++ b/skills/modern-web-guidance/guides/css/css-layout.md @@ -216,8 +216,8 @@ Baseline status for Popover: Newly available. It's been Baseline since 2025-01-2 Supported by: Chrome 116 (Aug 2023), Edge 116 (Aug 2023), Firefox 125 (Apr 2024), Safari 17 (Sep 2023), and Safari iOS 18.3 (Jan 2025). Browser support for Anchor positioning: Limited availability. -Supported by: Safari 27 (Sep 2026). -Unsupported in: Chrome, Edge, and Firefox. +Supported by: Chrome 157 (Nov 2026), Edge 157 (Nov 2026), and Safari 27 (Sep 2026). +Unsupported in: Firefox. **When to use each overlay primitive:** @@ -228,7 +228,7 @@ Unsupported in: Chrome, Edge, and Firefox. **Anchor positioning (spatial layout of overlays):** - Use `position-area` (or `anchor()` on insets) and `anchor-size()` to position and size an overlay relative to its trigger. -- Use `position-try-fallbacks: flip-block` (or `flip-inline`) to let the browser reposition when the overlay overflows the viewport. +- Use `position-try-fallbacks` to let the browser reposition when the overlay overflows the viewport. `flip-block, flip-inline, flip-block flip-inline` is a reasonable default, or define use-case specific fallbacks. - Don't mix physical and logical keywords in a single `position-area` value — pick one coordinate system. - Feature-detect with `@supports (anchor-name: --x)` and provide an absolute-position fallback. @@ -288,7 +288,9 @@ Supported by: Chrome 108 (Nov 2022), Edge 108 (Dec 2022), Firefox 101 (May 2022) ## 8 Grid lanes (aka masonry) -Grid lanes is not natively supported by any major browser yet. +Browser support for Grid lanes: Limited availability. +Supported by: Safari 27.2. +Unsupported in: Chrome, Edge, and Firefox. The specification is in development under the name "grid lanes" (e.g., `display: grid-lanes`), while earlier experimental prototypes used `grid-template-rows: masonry`. diff --git a/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md b/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md index 1e1e8df..45eb863 100644 --- a/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md +++ b/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md @@ -42,7 +42,7 @@ Give each form submit button a value that says what it does. Use a clear, recogn Allow your users to enter their name using a single input, unless you have a good reason for separately storing given names, family names, honorifics, or other name parts. Using a single name input makes forms less complex, enables cut-and-paste, and makes autofill simpler. Use `autocomplete="name"` for a single input for name. ```html - + ``` Allow international names. For validation, avoid using regular expressions that only match Latin characters. Latin-only excludes users with names or addresses that include characters that aren't in the Latin alphabet. Allow Unicode letter matching instead—and ensure your backend supports Unicode securely as both input and output. Unicode in regular expressions is well supported by modern browsers. diff --git a/skills/modern-web-guidance/guides/forms/slider.md b/skills/modern-web-guidance/guides/forms/slider.md index 2e66a71..eb43e89 100644 --- a/skills/modern-web-guidance/guides/forms/slider.md +++ b/skills/modern-web-guidance/guides/forms/slider.md @@ -110,7 +110,9 @@ input[type="range"]::-moz-range-thumb { } ``` -Always provide a visible keyboard focus indicator after removing the native appearance. Do not use color alone: +Ensure the track color has a contrast of at least `3:1` with the background color. + +Always provide a visible keyboard focus indicator after removing the native appearance. Ensure the focus indicator has a contrast of at least `3:1` with the background color or the adjacent track. Do not use color alone: ```css input[type="range"]:focus-visible { diff --git a/skills/modern-web-guidance/guides/forms/switch.md b/skills/modern-web-guidance/guides/forms/switch.md index 5e5151f..9d4c608 100644 --- a/skills/modern-web-guidance/guides/forms/switch.md +++ b/skills/modern-web-guidance/guides/forms/switch.md @@ -18,7 +18,7 @@ Add the boolean `switch` attribute to a standard checkbox input: ## Styling -Customize the control's highlight color using `accent-color` (see `brand-consistent-forms` (via `npx -y modern-web-guidance@latest retrieve "brand-consistent-forms"`)) and ensure visible focus styling: +Customize the control's highlight color using `accent-color` (see `brand-consistent-forms` (via `npx -y modern-web-guidance@latest retrieve "brand-consistent-forms"`)) and ensure visible focus styling with a contrast ratio of at least 3:1 against adjacent colors (WCAG 1.4.11 Non-text Contrast): ```css input[type="checkbox"][switch] { @@ -28,7 +28,7 @@ input[type="checkbox"][switch] { } input[type="checkbox"][switch]:focus-visible { - outline: 3px solid var(--focus-color, #ff8c00); + outline: 3px solid var(--focus-color, #d35400); outline-offset: 4px; } ``` diff --git a/skills/modern-web-guidance/guides/html/custom-elements.md b/skills/modern-web-guidance/guides/html/custom-elements.md index 6d1a4b9..516e3d4 100644 --- a/skills/modern-web-guidance/guides/html/custom-elements.md +++ b/skills/modern-web-guidance/guides/html/custom-elements.md @@ -2,6 +2,8 @@ A custom element is a class registered against a tag name via `customElements.define()`. Registration and basic lifecycle are well understood; the rules below target the parts routinely implemented incorrectly. +A custom element has no role or keyboard behavior of its own. That's fine when its content already carries the meaning, for example a layout wrapper around headings and text. If it needs semantics or keyboard support, build it from native elements such as `