@worldresources/wri-design-systems 2.191.19 → 2.191.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,6 +38,8 @@ npm i @chakra-ui/react @emotion/react
38
38
 
39
39
  Run the DS CLI to set up AI tooling for this design system in your project root (the directory where you run the command).
40
40
 
41
+ For the full setup guide see [docs/ai-tooling.md](docs/ai-tooling.md).
42
+
41
43
  ```
42
44
  ds setup-ai
43
45
  ```
package/agents/AGENTS.md CHANGED
@@ -37,6 +37,7 @@ Key rules (full details in the instructions file):
37
37
  3. **No style overrides** — do not use `sx`, `css`, or inline styles to override WRI DS component styles.
38
38
  4. **Tokens only** — use `getThemed*` from `@worldresources/wri-design-systems`. No hardcoded `#hex`, `rem`, `px`.
39
39
  5. **No Chakra v2 API** — v3 has breaking changes. Verify props via Chakra MCP.
40
+ 6. **Accessibility first** — always provide `aria-*` props (like `aria-label` or `aria-describedby`), explicit `role` attributes, and ensure keyboard focus navigation context when consuming components.
40
41
 
41
42
  ## Design Tokens — Source of Truth
42
43
 
@@ -68,10 +69,3 @@ Full token tables: `agents/spacing.md`, `agents/radius.md`, `agents/border-width
68
69
 
69
70
  - **Storybook MCP** — WRI DS components, props, and usage patterns
70
71
  - **Chakra UI MCP** — Chakra v3 component props and migration guidance
71
-
72
- ## MCP Session Caveat
73
-
74
- The setup command writes IDE-specific MCP config files such as `.vscode/mcp.json` and `.cursor/mcp.json`.
75
- Those files help supported editors attach MCP servers, but they do **not** guarantee that every agent runtime or terminal session will automatically inherit those tools.
76
-
77
- If an agent cannot access Figma or Storybook in a given session, verify the MCP tools are actually exposed in that session before assuming the repo config is broken.
@@ -0,0 +1,68 @@
1
+ ---
2
+ description: 'Accessibility rules for WRI DS consumers. Auto-attached when editing .tsx files. Covers required aria props, per-component type rules, and common mistakes.'
3
+ applyTo: '**/*.tsx'
4
+ ---
5
+
6
+ # WRI DS — Accessibility for Consumers
7
+
8
+ When using `@worldresources/wri-design-systems`, always pass the required accessibility props.
9
+ The components handle ARIA roles, focus management, and keyboard interactions internally —
10
+ but only if you provide the right props at the call site.
11
+
12
+ ## Core Rules
13
+
14
+ 1. **Icon-only actions always need `aria-label`** — `IconButton`, `CloseButton`, and any `Button` with no visible text must receive `aria-label`.
15
+ 2. **Form fields always need a label** — pass the `label` prop, or provide `aria-label`/`aria-labelledby` if no visible label is shown.
16
+ 3. **Error states need two signals** — set `aria-invalid` and wire `aria-describedby` to the error message in addition to any color change.
17
+ 4. **Never suppress focus** — do not add `tabIndex={-1}` or `outline: none` to interactive WRI DS components.
18
+ 5. **Navigation regions need `aria-label`** — when using `Navbar` or any `<nav>` wrapper, pass `aria-label` to distinguish multiple nav landmarks on the page.
19
+
20
+ ## Per-Component Quick Reference
21
+
22
+ | Component type | What you must provide at the call site |
23
+ | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
24
+ | `IconButton`, `CloseButton` | `aria-label` (required — no default) |
25
+ | `Button` with no visible text | `aria-label` |
26
+ | Toggle `Button` | `aria-pressed={isPressed}` |
27
+ | `Button` that opens a panel / menu | `aria-expanded={isOpen}` + `aria-controls="<panel-id>"` |
28
+ | `TextInput`, `Select`, `Checkbox`, `Radio`, `Switch` | `label` prop or `aria-label`/`aria-labelledby`; `aria-required` for required fields |
29
+ | Fields with validation errors | `aria-invalid={true}` + `aria-describedby="<error-id>"` |
30
+ | `Modal`, `Panel`, `Sheet` | `title` prop (maps to `aria-labelledby`) or `aria-label` when no visible title |
31
+ | `Navbar`, `Footer`, nav wrappers | `aria-label` to distinguish landmarks (e.g. `"Main navigation"`, `"Footer"`) |
32
+ | `Table` | `aria-label` or a `<caption>` child; `aria-sort` on sortable column headers |
33
+ | `AlertBanner`, `Toast`, `InlineMessage` | Ensure `role="alert"` (critical) or `role="status"` (informational) — check the component's default and override if needed |
34
+
35
+ ## Common Mistakes
36
+
37
+ ```tsx
38
+ // ❌ Icon-only button with no accessible name
39
+ <IconButton icon={<DeleteIcon />} onClick={fn} />
40
+
41
+ // ✅
42
+ <IconButton icon={<DeleteIcon aria-hidden="true" />} aria-label="Delete item" onClick={fn} />
43
+
44
+ // ❌ Form field with no label — placeholder is not an accessible label
45
+ <TextInput placeholder="Search..." />
46
+
47
+ // ✅
48
+ <TextInput label="Search" placeholder="Search..." />
49
+
50
+ // ❌ Error state using only color — screen readers won't know it's invalid
51
+ <TextInput label="Email" style={{ borderColor: 'red' }} />
52
+
53
+ // ✅
54
+ <TextInput
55
+ label="Email"
56
+ error="Enter a valid email address"
57
+ aria-invalid={true}
58
+ aria-describedby="email-error"
59
+ />
60
+
61
+ // ❌ Multiple nav regions with no distinguishing label
62
+ <Navbar />
63
+ <nav>{footerLinks}</nav>
64
+
65
+ // ✅
66
+ <Navbar aria-label="Main navigation" />
67
+ <nav aria-label="Footer">{footerLinks}</nav>
68
+ ```
@@ -12,6 +12,41 @@ applyTo: '**/*.tsx'
12
12
  3. **No style overrides** — do not use `sx`, `css`, `style`, or `className` to override WRI DS component styles.
13
13
  4. **Tokens only** — all values via `getThemed*` from `@worldresources/wri-design-systems`. No hardcoded `#hex`, `rem`, `px`.
14
14
  5. **No Chakra v2 API** — verify props via Chakra MCP before using any Chakra component.
15
+ 6. **Accessibility check** — confirm that necessary `aria-*` props, roles, and keyboard navigation considerations are explicitly added.
16
+
17
+ ## Accessibility (A11y) — Mandatory
18
+
19
+ When consuming WRI DS components, always ensure that accessibility context is preserved and passed correctly.
20
+
21
+ 1. **Name every control:** If a control has no visible text label (icon-only, or label is visually hidden), you **must** provide an accessible name via `aria-label` (or `aria-labelledby`).
22
+ 2. **Connect helper/error text:** When there is helper text or validation errors, connect it using `aria-describedby` (and `aria-errormessage` if the component supports it). Prefer the component’s built-in props for this (verify via Storybook MCP) instead of custom DOM glue.
23
+ 3. **State must be announced:** For toggles/menus/expanders, reflect state with `aria-expanded`, `aria-controls`, `aria-pressed`, `aria-selected` as appropriate (again: verify the DS component API first).
24
+ 4. **Keyboard support is non‑negotiable:** Any custom wrapper around DS components must preserve focusability and keyboard activation (Enter/Space for buttons; Arrow keys where applicable). Do not remove focus outlines.
25
+ 5. **Tables and lists:** Provide structure (`caption`, correct header cells, sort state announcements like `aria-sort`) when using tabular components. If you can’t confirm the right props, stop and query Storybook MCP.
26
+
27
+ ### A11y Defaults When Using Common DS Components
28
+
29
+ These rules apply when consuming components; **do not invent prop names**—verify each component’s actual a11y-related props with Storybook MCP.
30
+
31
+ - **`Button`, `IconButton`, `CloseButton`**
32
+ - Icon-only actions: require `aria-label` (localized).
33
+ - Destructive actions: ensure the visible label is explicit (“Delete”, “Remove”, etc.) and confirm focus/disabled states still announce correctly.
34
+ - **`Tooltip`**
35
+ - Tooltip is not a label replacement. Keep `aria-label`/visible label on the trigger when the action is otherwise unlabeled.
36
+ - **`Menu` (trigger + items)**
37
+ - Icon-only trigger: require `aria-label`.
38
+ - If the trigger opens/closes, ensure state is represented (often `aria-expanded` is handled by the component—verify).
39
+ - **`Modal` / `Sheet`**
40
+ - Provide a clear, unique title and ensure it is announced (typically via `aria-labelledby` or a `title` prop depending on the DS API).
41
+ - Ensure close action is reachable and labeled (`aria-label` on close icon buttons).
42
+ - **Form controls (`TextInput`, `Select`, `Textarea`, `Checkbox`, `Radio`, etc.)**
43
+ - Prefer the DS `label` prop (or label slot) for accessible naming.
44
+ - If a field is required/invalid/disabled, ensure the correct state is exposed via props (verify which props exist).
45
+ - **`Table`**
46
+ - Sortable headers must communicate sort state (`aria-sort` or DS equivalent). Do not rely on icon color alone.
47
+ - Provide row selection announcements where selection exists.
48
+ - **`Toast`, `InlineMessage`, `AlertBanner`**
49
+ - Status messages must be announced appropriately (`role="status"` / `role="alert"` behavior). Prefer DS defaults; if composing custom status UI, add the correct roles and `aria-live` semantics.
15
50
 
16
51
  ## Component Hierarchy (never skip a level)
17
52