a11y-elements 0.4.0 → 0.5.0
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 +207 -16
- package/dist/a11y-dark.css +31 -0
- package/dist/a11y.css +238 -160
- package/dist/all.d.ts +2 -1
- package/dist/all.js +2 -1
- package/dist/all.js.map +1 -1
- package/dist/browser/all.js +48 -42
- package/dist/browser/{chunk-HLID3PP5.js → chunk-32FZURPA.js} +3 -3
- package/dist/browser/{chunk-LQ34M47I.js → chunk-46DKJF7A.js} +2 -2
- package/dist/browser/{chunk-VY6BZLCJ.js → chunk-4A7L5TW6.js} +3 -3
- package/dist/browser/{chunk-NTNPE4TH.js → chunk-5ERYLJ24.js} +28 -11
- package/dist/browser/chunk-5ERYLJ24.js.map +1 -0
- package/dist/browser/{chunk-GUKQIHPM.js → chunk-6DXBSCNO.js} +3 -3
- package/dist/browser/{chunk-UCAUEEED.js → chunk-6Q5EEBYM.js} +5 -5
- package/dist/browser/{chunk-UCAUEEED.js.map → chunk-6Q5EEBYM.js.map} +1 -1
- package/dist/browser/{chunk-CXUZEGZY.js → chunk-6XDUSEPL.js} +2 -2
- package/dist/browser/{chunk-FXHJKL3U.js → chunk-7QBDJCWN.js} +3 -3
- package/dist/browser/{chunk-SYKTM7WJ.js → chunk-AEUQEMRJ.js} +3 -3
- package/dist/browser/{chunk-2YF57VSU.js → chunk-AFEWHFFA.js} +3 -3
- package/dist/browser/{chunk-HGPHWR3R.js → chunk-AGSRNTSW.js} +3 -3
- package/dist/browser/{chunk-3UC2S6JJ.js → chunk-EJZPHR4Z.js} +5 -4
- package/dist/browser/chunk-EJZPHR4Z.js.map +1 -0
- package/dist/browser/{chunk-EAASMTBS.js → chunk-ETTLTMRE.js} +3 -3
- package/dist/browser/chunk-ETTLTMRE.js.map +1 -0
- package/dist/browser/{chunk-6Q6VW435.js → chunk-H4U5TGR6.js} +19 -7
- package/dist/browser/chunk-H4U5TGR6.js.map +1 -0
- package/dist/browser/{chunk-NI7PACR4.js → chunk-H5HLB3X6.js} +3 -3
- package/dist/browser/{chunk-GKNBHWGY.js → chunk-HAYNMWNF.js} +3 -3
- package/dist/browser/{chunk-ZMCETLOQ.js → chunk-HEV3NTM6.js} +5 -4
- package/dist/browser/chunk-HEV3NTM6.js.map +1 -0
- package/dist/browser/{chunk-3RRJOPEF.js → chunk-HZBBOI27.js} +2 -2
- package/dist/browser/{chunk-6BOK3R6K.js → chunk-IXBSR3RY.js} +3 -3
- package/dist/browser/{chunk-R4OVZULJ.js → chunk-J5JL2LV4.js} +2 -2
- package/dist/browser/chunk-JPQMMJFO.js +169 -0
- package/dist/browser/chunk-JPQMMJFO.js.map +1 -0
- package/dist/browser/{chunk-A32U5MX7.js → chunk-K62Y2QZ4.js} +3 -3
- package/dist/browser/{chunk-O4AJULBZ.js → chunk-KPLZJOV4.js} +8 -8
- package/dist/browser/chunk-KPLZJOV4.js.map +1 -0
- package/dist/browser/chunk-LIMTK2JM.js +77 -0
- package/dist/browser/chunk-LIMTK2JM.js.map +1 -0
- package/dist/browser/{chunk-HPTH4SJ2.js → chunk-MLHDJFAO.js} +3 -3
- package/dist/browser/{chunk-P42KF3NM.js → chunk-OOIGBD2C.js} +3 -3
- package/dist/browser/{chunk-4FHDXZ3L.js → chunk-QN7QZKRL.js} +6 -6
- package/dist/browser/{chunk-4FHDXZ3L.js.map → chunk-QN7QZKRL.js.map} +1 -1
- package/dist/browser/{chunk-ISWQOJT7.js → chunk-QRO7M2WV.js} +3 -3
- package/dist/browser/{chunk-A5CV54CT.js → chunk-SUYBZFH7.js} +5 -4
- package/dist/browser/chunk-SUYBZFH7.js.map +1 -0
- package/dist/browser/{chunk-I4KOJO4B.js → chunk-T2CQXIHN.js} +3 -3
- package/dist/browser/{chunk-46SIA3RI.js → chunk-UAPYZK4I.js} +3 -1
- package/dist/browser/chunk-UAPYZK4I.js.map +1 -0
- package/dist/browser/{chunk-KUTHJLZ5.js → chunk-ULMVOYTV.js} +2 -2
- package/dist/browser/{chunk-S7GPESLQ.js → chunk-WCCLCAYH.js} +2 -2
- package/dist/browser/{chunk-ACOSO5NE.js → chunk-WNLXSUPC.js} +21 -12
- package/dist/browser/chunk-WNLXSUPC.js.map +1 -0
- package/dist/browser/{chunk-SIQUYA37.js → chunk-WOK76CEK.js} +2 -2
- package/dist/browser/{chunk-ABTLBDUK.js → chunk-WOMR3M72.js} +3 -3
- package/dist/browser/{chunk-4IURHUQU.js → chunk-XH66G6MU.js} +5 -5
- package/dist/browser/{chunk-GDJTILU4.js → chunk-YGWMBM3X.js} +3 -3
- package/dist/browser/{chunk-TTP33GXU.js → chunk-ZCMKKXSE.js} +32 -5
- package/dist/browser/chunk-ZCMKKXSE.js.map +1 -0
- package/dist/browser/{chunk-QT7Z23GS.js → chunk-ZHK7NWCK.js} +3 -3
- package/dist/browser/components/anchor/define.js +3 -3
- package/dist/browser/components/avatar/define.js +2 -2
- package/dist/browser/components/card-link/define.js +3 -3
- package/dist/browser/components/checkbox/define.js +3 -3
- package/dist/browser/components/checkbox-group/define.js +3 -3
- package/dist/browser/components/file-input/define.js +4 -4
- package/dist/browser/components/focusable/define.js +2 -2
- package/dist/browser/components/input/define.js +4 -4
- package/dist/browser/components/label/define.js +3 -3
- package/dist/browser/components/picture/define.js +3 -3
- package/dist/browser/components/progress/define.js +2 -2
- package/dist/browser/components/radio-group/define.js +3 -3
- package/dist/browser/components/select/define.js +3 -3
- package/dist/browser/components/skeleton/define.js +2 -2
- package/dist/browser/components/spinner/define.js +2 -2
- package/dist/browser/components/switch/define.js +3 -3
- package/dist/browser/components/tabs/define.js +16 -0
- package/dist/browser/components/tabs/define.js.map +1 -0
- package/dist/browser/components/textarea/define.js +4 -4
- package/dist/browser/components/visually-hidden/define.js +2 -2
- package/dist/browser/overlays/blocking-loader/define.js +6 -6
- package/dist/browser/overlays/context-menu/define.js +7 -7
- package/dist/browser/overlays/drawer/define.js +6 -6
- package/dist/browser/overlays/dropdown/define.js +7 -7
- package/dist/browser/overlays/emergency-dialog/define.js +6 -6
- package/dist/browser/overlays/floating/define.js +4 -4
- package/dist/browser/overlays/modal/define.js +9 -7
- package/dist/browser/overlays/notification-banner/define.js +4 -4
- package/dist/browser/overlays/popover/define.js +6 -6
- package/dist/browser/overlays/snackbar/define.js +4 -4
- package/dist/browser/overlays/tooltip/define.js +6 -6
- package/dist/components/tabs/define.d.ts +8 -0
- package/dist/components/tabs/define.js +6 -0
- package/dist/components/tabs/define.js.map +1 -0
- package/dist/components/tabs/tabs.element.d.ts +60 -0
- package/dist/components/tabs/tabs.element.js +207 -0
- package/dist/components/tabs/tabs.element.js.map +1 -0
- package/dist/core/a11y-overlay-element.d.ts +10 -2
- package/dist/core/a11y-overlay-element.js +17 -4
- package/dist/core/a11y-overlay-element.js.map +1 -1
- package/dist/core/focus-trap.d.ts +7 -0
- package/dist/core/focus-trap.js +39 -3
- package/dist/core/focus-trap.js.map +1 -1
- package/dist/core/overlay-registry.d.ts +25 -8
- package/dist/core/overlay-registry.js +32 -9
- package/dist/core/overlay-registry.js.map +1 -1
- package/dist/core/strings.d.ts +4 -0
- package/dist/core/strings.js +2 -0
- package/dist/core/strings.js.map +1 -1
- package/dist/overlays/core/a11y-anchored-overlay-element.js +3 -3
- package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-menu-overlay-element.js +2 -2
- package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-modal-overlay-element.d.ts +7 -0
- package/dist/overlays/core/a11y-modal-overlay-element.js +29 -4
- package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
- package/dist/overlays/drawer/drawer.element.d.ts +2 -1
- package/dist/overlays/drawer/drawer.element.js +2 -1
- package/dist/overlays/drawer/drawer.element.js.map +1 -1
- package/dist/overlays/emergency-dialog/emergency-dialog.element.d.ts +2 -1
- package/dist/overlays/emergency-dialog/emergency-dialog.element.js +2 -1
- package/dist/overlays/emergency-dialog/emergency-dialog.element.js.map +1 -1
- package/dist/overlays/floating/floating.element.js +2 -2
- package/dist/overlays/floating/floating.element.js.map +1 -1
- package/dist/overlays/modal/confirm-dialog.d.ts +24 -0
- package/dist/overlays/modal/confirm-dialog.js +46 -0
- package/dist/overlays/modal/confirm-dialog.js.map +1 -0
- package/dist/overlays/modal/define.d.ts +1 -0
- package/dist/overlays/modal/define.js +1 -0
- package/dist/overlays/modal/define.js.map +1 -1
- package/dist/overlays/modal/modal.element.d.ts +3 -2
- package/dist/overlays/modal/modal.element.js +2 -1
- package/dist/overlays/modal/modal.element.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +1 -1
- package/dist/overlays/popover/popover.element.d.ts +2 -1
- package/dist/overlays/popover/popover.element.js +2 -1
- package/dist/overlays/popover/popover.element.js.map +1 -1
- package/package.json +3 -2
- package/dist/browser/chunk-3UC2S6JJ.js.map +0 -1
- package/dist/browser/chunk-46SIA3RI.js.map +0 -1
- package/dist/browser/chunk-6Q6VW435.js.map +0 -1
- package/dist/browser/chunk-A5CV54CT.js.map +0 -1
- package/dist/browser/chunk-ACOSO5NE.js.map +0 -1
- package/dist/browser/chunk-EAASMTBS.js.map +0 -1
- package/dist/browser/chunk-GH53G7MU.js +0 -35
- package/dist/browser/chunk-GH53G7MU.js.map +0 -1
- package/dist/browser/chunk-NTNPE4TH.js.map +0 -1
- package/dist/browser/chunk-O4AJULBZ.js.map +0 -1
- package/dist/browser/chunk-TTP33GXU.js.map +0 -1
- package/dist/browser/chunk-ZMCETLOQ.js.map +0 -1
- /package/dist/browser/{chunk-HLID3PP5.js.map → chunk-32FZURPA.js.map} +0 -0
- /package/dist/browser/{chunk-LQ34M47I.js.map → chunk-46DKJF7A.js.map} +0 -0
- /package/dist/browser/{chunk-VY6BZLCJ.js.map → chunk-4A7L5TW6.js.map} +0 -0
- /package/dist/browser/{chunk-GUKQIHPM.js.map → chunk-6DXBSCNO.js.map} +0 -0
- /package/dist/browser/{chunk-CXUZEGZY.js.map → chunk-6XDUSEPL.js.map} +0 -0
- /package/dist/browser/{chunk-FXHJKL3U.js.map → chunk-7QBDJCWN.js.map} +0 -0
- /package/dist/browser/{chunk-SYKTM7WJ.js.map → chunk-AEUQEMRJ.js.map} +0 -0
- /package/dist/browser/{chunk-2YF57VSU.js.map → chunk-AFEWHFFA.js.map} +0 -0
- /package/dist/browser/{chunk-HGPHWR3R.js.map → chunk-AGSRNTSW.js.map} +0 -0
- /package/dist/browser/{chunk-NI7PACR4.js.map → chunk-H5HLB3X6.js.map} +0 -0
- /package/dist/browser/{chunk-GKNBHWGY.js.map → chunk-HAYNMWNF.js.map} +0 -0
- /package/dist/browser/{chunk-3RRJOPEF.js.map → chunk-HZBBOI27.js.map} +0 -0
- /package/dist/browser/{chunk-6BOK3R6K.js.map → chunk-IXBSR3RY.js.map} +0 -0
- /package/dist/browser/{chunk-R4OVZULJ.js.map → chunk-J5JL2LV4.js.map} +0 -0
- /package/dist/browser/{chunk-A32U5MX7.js.map → chunk-K62Y2QZ4.js.map} +0 -0
- /package/dist/browser/{chunk-HPTH4SJ2.js.map → chunk-MLHDJFAO.js.map} +0 -0
- /package/dist/browser/{chunk-P42KF3NM.js.map → chunk-OOIGBD2C.js.map} +0 -0
- /package/dist/browser/{chunk-ISWQOJT7.js.map → chunk-QRO7M2WV.js.map} +0 -0
- /package/dist/browser/{chunk-I4KOJO4B.js.map → chunk-T2CQXIHN.js.map} +0 -0
- /package/dist/browser/{chunk-KUTHJLZ5.js.map → chunk-ULMVOYTV.js.map} +0 -0
- /package/dist/browser/{chunk-S7GPESLQ.js.map → chunk-WCCLCAYH.js.map} +0 -0
- /package/dist/browser/{chunk-SIQUYA37.js.map → chunk-WOK76CEK.js.map} +0 -0
- /package/dist/browser/{chunk-ABTLBDUK.js.map → chunk-WOMR3M72.js.map} +0 -0
- /package/dist/browser/{chunk-4IURHUQU.js.map → chunk-XH66G6MU.js.map} +0 -0
- /package/dist/browser/{chunk-GDJTILU4.js.map → chunk-YGWMBM3X.js.map} +0 -0
- /package/dist/browser/{chunk-QT7Z23GS.js.map → chunk-ZHK7NWCK.js.map} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Framework-agnostic accessibility Custom Elements (Web Components). A behavior la
|
|
|
4
4
|
|
|
5
5
|
Every element is Light DOM only (no Shadow DOM), so you always style real markup with your own CSS.
|
|
6
6
|
|
|
7
|
-
See a [demo of the elements](https://nutin.
|
|
7
|
+
See a [demo of the elements](https://nutin.dev/a11y-elements/elements) - See a [demo of the overlays](https://nutin.org/a11y-elements/overlays)
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
@@ -56,7 +56,6 @@ A few English strings end up in accessible names and announcements. Replace them
|
|
|
56
56
|
|
|
57
57
|
```js
|
|
58
58
|
import { setStrings } from 'a11y-elements/core';
|
|
59
|
-
// or: import { setStrings } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
|
|
60
59
|
|
|
61
60
|
setStrings({
|
|
62
61
|
closeDialog: 'Fermer la boîte de dialogue',
|
|
@@ -70,6 +69,7 @@ setStrings({
|
|
|
70
69
|
| `opensInNewTab` | `(opens in new tab)` | `<a11y-anchor>` new-tab links | `new-tab-label` |
|
|
71
70
|
| `navigatedTo` | `Navigated to {name}` | `<a11y-anchor>` jump announcement (`{name}` is the target's name) | `navigated-label` |
|
|
72
71
|
| `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`, an expandable `<a11y-floating>`'s panel | `close-label` |
|
|
72
|
+
| `confirm` / `cancel` | `OK` / `Cancel` | the buttons of `confirmDialog()` | `confirmLabel` / `cancelLabel` |
|
|
73
73
|
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item and of a `dismissible` `<a11y-floating>` | `dismiss-label` |
|
|
74
74
|
| `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
|
|
75
75
|
| `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
|
|
@@ -98,7 +98,7 @@ Each section shows an example, the element's own attributes/properties/methods,
|
|
|
98
98
|
|
|
99
99
|
Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
100
100
|
|
|
101
|
-
**Accessibility components:** [`<a11y-anchor>`](#a11y-anchor) · [`<a11y-avatar>`](#a11y-avatar) · [`<a11y-card-link>`](#a11y-card-link) · [`<a11y-checkbox>`](#a11y-checkbox) · [`<a11y-checkbox-group>`](#a11y-checkbox-group) · [`<a11y-file-input>`](#a11y-file-input) · [`<a11y-focusable>`](#a11y-focusable) · [`<a11y-input>`](#a11y-input) · [`<a11y-label>`](#a11y-label) · [`<a11y-picture>`](#a11y-picture) · [`<a11y-progress>`](#a11y-progress) · [`<a11y-radio-group>`](#a11y-radio-group) · [`<a11y-select>`](#a11y-select) · [`<a11y-skeleton>`](#a11y-skeleton) · [`<a11y-spinner>`](#a11y-spinner) · [`<a11y-switch>`](#a11y-switch) · [`<a11y-textarea>`](#a11y-textarea) · [`<a11y-visually-hidden>`](#a11y-visually-hidden)
|
|
101
|
+
**Accessibility components:** [`<a11y-anchor>`](#a11y-anchor) · [`<a11y-avatar>`](#a11y-avatar) · [`<a11y-card-link>`](#a11y-card-link) · [`<a11y-checkbox>`](#a11y-checkbox) · [`<a11y-checkbox-group>`](#a11y-checkbox-group) · [`<a11y-file-input>`](#a11y-file-input) · [`<a11y-focusable>`](#a11y-focusable) · [`<a11y-input>`](#a11y-input) · [`<a11y-label>`](#a11y-label) · [`<a11y-picture>`](#a11y-picture) · [`<a11y-progress>`](#a11y-progress) · [`<a11y-radio-group>`](#a11y-radio-group) · [`<a11y-select>`](#a11y-select) · [`<a11y-skeleton>`](#a11y-skeleton) · [`<a11y-spinner>`](#a11y-spinner) · [`<a11y-switch>`](#a11y-switch) · [`<a11y-tabs>`](#a11y-tabs) · [`<a11y-textarea>`](#a11y-textarea) · [`<a11y-visually-hidden>`](#a11y-visually-hidden)
|
|
102
102
|
|
|
103
103
|
**Overlays:** [`<a11y-blocking-loader>`](#a11y-blocking-loader) · [`<a11y-context-menu>`](#a11y-context-menu) · [`<a11y-drawer>`](#a11y-drawer) · [`<a11y-dropdown>`](#a11y-dropdown) · [`<a11y-emergency-dialog>`](#a11y-emergency-dialog) · [`<a11y-floating>`](#a11y-floating) · [`<a11y-modal>`](#a11y-modal) · [`<a11y-notification-banner>`](#a11y-notification-banner) · [`<a11y-popover>`](#a11y-popover) · [`<a11y-snackbar>`](#a11y-snackbar) · [`<a11y-tooltip>`](#a11y-tooltip)
|
|
104
104
|
|
|
@@ -146,6 +146,8 @@ An avatar image with an initials fallback. When the image is missing or fails to
|
|
|
146
146
|
| `size` | attribute | — | Sets `--a11y-avatar-size`. |
|
|
147
147
|
| `shape` | attribute / property | `circle` | `circle` or `square`. |
|
|
148
148
|
|
|
149
|
+
The initials are set in Arial rather than the page font, so they fit the circle the same way everywhere. Set `--a11y-avatar-font-family` to use your own font.
|
|
150
|
+
|
|
149
151
|
<details>
|
|
150
152
|
<summary>CSS variables</summary>
|
|
151
153
|
|
|
@@ -762,6 +764,8 @@ Wraps a real `<select>` in a `<label>` with a visible label text. Options and ke
|
|
|
762
764
|
| `onChange` | callback | — | `(value: string) => void`, called on every `change`. |
|
|
763
765
|
| `getValue()` / `setValue(value)` | method | — | Reads / sets the selected value. |
|
|
764
766
|
|
|
767
|
+
The native `<select>` inside stays the source of truth: its `change` events and `.value` work as usual. A framework that binds events on the native element can use those and skip `onChange` / `getValue()`.
|
|
768
|
+
|
|
765
769
|
<details>
|
|
766
770
|
<summary>CSS variables</summary>
|
|
767
771
|
|
|
@@ -777,7 +781,7 @@ Wraps a real `<select>` in a `<label>` with a visible label text. Options and ke
|
|
|
777
781
|
| `--a11y-select-color-text-muted` | `#6b7280` |
|
|
778
782
|
| `--a11y-select-control-border-radius` | `4px` |
|
|
779
783
|
| `--a11y-select-control-border-width` | `1px` |
|
|
780
|
-
| `--a11y-select-control-font-family` | `
|
|
784
|
+
| `--a11y-select-control-font-family` | `inherit` |
|
|
781
785
|
| `--a11y-select-control-font-size` | `1rem` |
|
|
782
786
|
| `--a11y-select-control-line-height` | `1.4` |
|
|
783
787
|
| `--a11y-select-control-padding-x` | `1rem` |
|
|
@@ -912,6 +916,61 @@ Like `<a11y-checkbox>`, but the input gets `role="switch"`.
|
|
|
912
916
|
|
|
913
917
|
</details>
|
|
914
918
|
|
|
919
|
+
#### `a11y-tabs`
|
|
920
|
+
|
|
921
|
+
Turns your own tab buttons and panels into the WAI-ARIA Tabs pattern (automatic activation). Tabs are the `[data-tab]` elements inside the `[data-tablist]` child, each one showing the `[data-panel]` with the same name.
|
|
922
|
+
|
|
923
|
+
```html
|
|
924
|
+
<a11y-tabs label="Projects" selected="apps">
|
|
925
|
+
<div data-tablist>
|
|
926
|
+
<button data-tab="tools">Tools</button>
|
|
927
|
+
<button data-tab="apps">Apps</button>
|
|
928
|
+
</div>
|
|
929
|
+
<section data-panel="tools">…</section>
|
|
930
|
+
<section data-panel="apps">…</section>
|
|
931
|
+
</a11y-tabs>
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
* Sets the roles, `aria-selected`, `aria-controls`/`aria-labelledby` (ids generated when missing) and a roving `tabindex`. Hidden panels get `hidden`. A panel gets `tabindex="0"` unless it already has a `tabindex`.
|
|
935
|
+
* Arrow keys move the selection and focus (Left/Right, or Up/Down with `orientation="vertical"`, mirrored in right-to-left text). Home/End go to the first/last tab. Disabled tabs (`disabled` or `aria-disabled="true"`) are skipped.
|
|
936
|
+
* A same-page link (`<a href="#id">`, with or without `<a11y-anchor>`) whose target is in a hidden panel selects that panel first. So do `hashchange` and the page's initial hash, even when its target is added after the element connects (it's then scrolled into view).
|
|
937
|
+
* Tabs and panels inside a nested `<a11y-tabs>` belong to it.
|
|
938
|
+
|
|
939
|
+
| Name | Kind | Default | Description |
|
|
940
|
+
| --- | --- | --- | --- |
|
|
941
|
+
| `label` | attribute | — | The tablist's accessible name (`aria-label`), unless the tablist has `aria-labelledby`. |
|
|
942
|
+
| `selected` | attribute / property | first enabled tab | The selected tab's `data-tab`. Unknown or disabled names fall back to the first enabled tab. |
|
|
943
|
+
| `orientation` | attribute | `horizontal` | `vertical` stacks the tabs and uses Up/Down. |
|
|
944
|
+
| `onChange` | callback | — | `(name: string) => void`, called when the user changes the tab (click, keyboard, link or hash). Not called by `select()` or `selected`. |
|
|
945
|
+
| `select(name)` | method | — | Selects a tab. |
|
|
946
|
+
| `reveal(element)` | method | — | Selects the panel containing `element`. Returns `false` if it isn't in one of this element's panels. |
|
|
947
|
+
|
|
948
|
+
<details>
|
|
949
|
+
<summary>CSS variables</summary>
|
|
950
|
+
|
|
951
|
+
| Variable | Default |
|
|
952
|
+
| --- | --- |
|
|
953
|
+
| `--a11y-tabs-border-width` | `1px` |
|
|
954
|
+
| `--a11y-tabs-color-border` | `#d1d5db` |
|
|
955
|
+
| `--a11y-tabs-color-disabled` | `#9ca3af` |
|
|
956
|
+
| `--a11y-tabs-color-focus` | `#2563eb` |
|
|
957
|
+
| `--a11y-tabs-color-selected` | `#2563eb` |
|
|
958
|
+
| `--a11y-tabs-color-text` | `#4b5563` |
|
|
959
|
+
| `--a11y-tabs-color-text-hover` | `#111827` |
|
|
960
|
+
| `--a11y-tabs-focus-outline-offset` | `2px` |
|
|
961
|
+
| `--a11y-tabs-focus-outline-width` | `2px` |
|
|
962
|
+
| `--a11y-tabs-gap` | `0.25rem` |
|
|
963
|
+
| `--a11y-tabs-indicator-width` | `2px` |
|
|
964
|
+
| `--a11y-tabs-tab-background` | `transparent` |
|
|
965
|
+
| `--a11y-tabs-tab-border-radius` | `0` |
|
|
966
|
+
| `--a11y-tabs-tab-font-size` | `1rem` |
|
|
967
|
+
| `--a11y-tabs-tab-font-weight` | `500` |
|
|
968
|
+
| `--a11y-tabs-tab-line-height` | `1.4` |
|
|
969
|
+
| `--a11y-tabs-tab-padding` | `0.5rem 1rem` |
|
|
970
|
+
| `--a11y-tabs-transition-duration` | `0.2s` |
|
|
971
|
+
|
|
972
|
+
</details>
|
|
973
|
+
|
|
915
974
|
#### `a11y-textarea`
|
|
916
975
|
|
|
917
976
|
`<a11y-input>` for a real `<textarea>`: same parts, attributes, properties, validation and states.
|
|
@@ -960,7 +1019,21 @@ No attributes or CSS variables. The class `a11y-visually-hidden` is also usable
|
|
|
960
1019
|
|
|
961
1020
|
* **Open/close** with the `open` attribute or property, or `show()` / `close()`.
|
|
962
1021
|
* **Before the element is defined** (lazy-loaded bundles), setting `.open = true`, `onClose` or any other property works: it's applied once the element upgrades. `setAttribute('open', '')` works too.
|
|
963
|
-
* **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on `document`,
|
|
1022
|
+
* **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on the overlay element and bubble to `document`, so you can listen on either. `event.detail` has `name` (the tag name) and `element` (the overlay). On `a11y-overlay-close`, `detail.reason` says why it closed:
|
|
1023
|
+
|
|
1024
|
+
| `reason` | Closed by |
|
|
1025
|
+
| --- | --- |
|
|
1026
|
+
| `escape` | the Escape key |
|
|
1027
|
+
| `backdrop` | a click on a dialog's backdrop |
|
|
1028
|
+
| `close-button` | a dialog's × button |
|
|
1029
|
+
| `outside-click` | a click outside an anchored overlay |
|
|
1030
|
+
| `focus-out` | focus leaving a menu |
|
|
1031
|
+
| `item` | activating a menu item |
|
|
1032
|
+
| `dismiss-all` | `dismissAllOverlays()` |
|
|
1033
|
+
| `removed` | removing the element while open (the event then fires on `document`) |
|
|
1034
|
+
| `api` | `close()`, `open = false` or removing `open` |
|
|
1035
|
+
|
|
1036
|
+
`close(reason)` also takes a reason, for your own close buttons. `<a11y-floating>` passes `element` but no `reason`.
|
|
964
1037
|
* **`dismissAllOverlays()`** closes every open overlay (e.g. on navigation). It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
965
1038
|
* **Except `<a11y-floating>`**, which is visible by default and has no `open`: `dismissAllOverlays()` only collapses its expanded panel. See [`a11y-floating`](#a11y-floating).
|
|
966
1039
|
* **Body mounting:** every overlay (including the snackbar and notification-banner regions) moves itself to `<body>` when connected, so a `position: fixed` layer isn't clipped by an ancestor. See [Overlays in a framework](#overlays-in-a-framework) below.
|
|
@@ -992,14 +1065,19 @@ If the bundle loads after rendering, the same query does find it, so the result
|
|
|
992
1065
|
* bind events on the overlay element itself, or delegate from it;
|
|
993
1066
|
* put final text into the markup before injecting it, rather than in a pass after rendering.
|
|
994
1067
|
|
|
1068
|
+
##### Bind overlay events yourself.
|
|
1069
|
+
|
|
1070
|
+
Framework template bindings (event directives, declarative listeners) usually run over the component's subtree after it's inserted. By then the overlay has already moved to `<body>`, so its bindings never attach. Get the overlay with `getElementById`, call `addEventListener` on it (or delegate from it) after each render, and remove the listener on unmount.
|
|
1071
|
+
|
|
995
1072
|
<a id="dialogs"></a>
|
|
996
1073
|
|
|
997
1074
|
##### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
|
|
998
1075
|
|
|
999
1076
|
They also share:
|
|
1000
1077
|
|
|
1001
|
-
* A focus trap (Tab stays inside, focus returns to the trigger on close) and a page scroll lock (`html.a11y-no-scroll`).
|
|
1078
|
+
* A focus trap (Tab stays inside, focus returns to the trigger on close) and a page scroll lock (`html.a11y-no-scroll`, `overflow: hidden`). If the page had a classic scrollbar, the lock also adds `html.a11y-no-scroll--gutter` (`scrollbar-gutter: stable`), so the page keeps its width while the scrollbar is gone.
|
|
1002
1079
|
* Escape, a click on the backdrop, or the × close button close it, unless it's `non-dismissible`.
|
|
1080
|
+
* On open, focus moves to `initial-focus` if set, else to a descendant with `autofocus`, else to the first focusable element. That's the × close button when it's dismissible.
|
|
1003
1081
|
* The dialog is named after its first heading (`aria-labelledby`), or `dialog-label`.
|
|
1004
1082
|
|
|
1005
1083
|
| Name | Kind | Default | Description |
|
|
@@ -1007,8 +1085,9 @@ They also share:
|
|
|
1007
1085
|
| `non-dismissible` | attribute | absent | No close button, no Escape, no backdrop click: close it from code. |
|
|
1008
1086
|
| `dialog-label` | attribute | — | Accessible name (`aria-label`) when there's no heading. |
|
|
1009
1087
|
| `close-label` | attribute | `Close dialog` | Accessible name of the × close button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1088
|
+
| `initial-focus` | attribute | — | The element to focus on open: an `id`, else a selector, looked up inside the dialog. Ignored if it's missing or can't take focus. |
|
|
1010
1089
|
| `dismissible` | property (read-only) | `true` | Inverse of `non-dismissible`. |
|
|
1011
|
-
| `onClose` | callback | — | Called once the close transition has finished. |
|
|
1090
|
+
| `onClose` | callback | — | Called once the close transition has finished, with the close [`reason`](#common-to-all-overlays). |
|
|
1012
1091
|
|
|
1013
1092
|
<a id="anchored-overlays"></a>
|
|
1014
1093
|
|
|
@@ -1130,7 +1209,7 @@ A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dia
|
|
|
1130
1209
|
| --- | --- | --- | --- |
|
|
1131
1210
|
| `edge` | attribute / property (read-only) | `right` | `left`, `right`, `top` or `bottom`. Read when the drawer opens. |
|
|
1132
1211
|
|
|
1133
|
-
Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1212
|
+
Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `initial-focus`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1134
1213
|
|
|
1135
1214
|
<details>
|
|
1136
1215
|
<summary>CSS variables</summary>
|
|
@@ -1324,9 +1403,43 @@ document.getElementById('open-settings').addEventListener('click', () => {
|
|
|
1324
1403
|
| --- | --- | --- | --- |
|
|
1325
1404
|
| `fullscreen` | attribute | absent | Fills the viewport, without the backdrop gutter. Read when the modal opens. |
|
|
1326
1405
|
|
|
1327
|
-
|
|
1406
|
+
**Size:** the dialog is as tall as its content and up to `32rem` wide, inside the backdrop's padding (`--a11y-modal-overlay-padding`). Longer content scrolls inside it. Change the size with `--a11y-modal-width`, `--a11y-modal-height`, `--a11y-modal-max-width` and `--a11y-modal-max-height`. Set `--a11y-modal-width` and `--a11y-modal-height` to `100%` to fill the padded area, as before 0.5.0. `<a11y-emergency-dialog>` is sized the same way.
|
|
1407
|
+
|
|
1408
|
+
Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `initial-focus`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1409
|
+
|
|
1410
|
+
`.a11y-modal-buttons` is an optional footer-row class for your own buttons. It lays them out in a row, and gives plain `<button>`s a default look (padding, font size, hover colors). Those styles have zero specificity (`:where()`), so any class on your buttons overrides them.
|
|
1411
|
+
|
|
1412
|
+
##### Confirmation dialogs: `confirmDialog()`
|
|
1413
|
+
|
|
1414
|
+
`confirmDialog()` asks a yes/no question in a temporary modal, and resolves `true` only when the confirm button is pressed. Every other close (Cancel, Escape, the backdrop, ×, `dismissAllOverlays()`) resolves `false`. Focus starts on Cancel, so a stray Enter doesn't confirm. The modal is removed once closed.
|
|
1415
|
+
|
|
1416
|
+
```js
|
|
1417
|
+
import { confirmDialog } from 'a11y-elements/overlays/modal';
|
|
1418
|
+
|
|
1419
|
+
if (await confirmDialog({ title: 'Delete all notes?', message: 'This can’t be undone.', confirmLabel: 'Delete', danger: true })) {
|
|
1420
|
+
deleteAll();
|
|
1421
|
+
}
|
|
1422
|
+
```
|
|
1423
|
+
|
|
1424
|
+
| Option | Default | Description |
|
|
1425
|
+
| --- | --- | --- |
|
|
1426
|
+
| `title` | — | The heading, which also names the dialog. |
|
|
1427
|
+
| `message` | — | Text under the heading. Escaped; use `raw()` for markup. |
|
|
1428
|
+
| `confirmLabel` | `OK` | Confirm button text, else `setStrings({ confirm })`. |
|
|
1429
|
+
| `cancelLabel` | `Cancel` | Cancel button text, else `setStrings({ cancel })`. |
|
|
1430
|
+
| `danger` | `false` | Adds `a11y-confirm__confirm--danger` to the confirm button. |
|
|
1328
1431
|
|
|
1329
|
-
`.a11y-
|
|
1432
|
+
The modal has the class `a11y-confirm`. Its parts are `.a11y-confirm__title`, `.a11y-confirm__message`, and `.a11y-confirm__cancel` and `.a11y-confirm__confirm` in a `.a11y-modal-buttons` footer. Style them with your own CSS.
|
|
1433
|
+
|
|
1434
|
+
To build your own instead, set `initial-focus` on Cancel, let your buttons record the answer before calling `modal.close()`, and treat every other close as Cancel:
|
|
1435
|
+
|
|
1436
|
+
```js
|
|
1437
|
+
let answer = false;
|
|
1438
|
+
confirmButton.addEventListener('click', () => { answer = true; modal.close(); });
|
|
1439
|
+
cancelButton.addEventListener('click', () => modal.close());
|
|
1440
|
+
modal.onClose = () => resolve(answer); // Escape, backdrop, × … leave it false
|
|
1441
|
+
modal.open = true;
|
|
1442
|
+
```
|
|
1330
1443
|
|
|
1331
1444
|
<details>
|
|
1332
1445
|
<summary>CSS variables</summary>
|
|
@@ -1344,12 +1457,16 @@ Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-lab
|
|
|
1344
1457
|
| `--a11y-modal-footer-button-padding` | `0.5rem 1rem` |
|
|
1345
1458
|
| `--a11y-modal-footer-gap` | `1rem` |
|
|
1346
1459
|
| `--a11y-modal-footer-margin-top` | `1.5rem` |
|
|
1460
|
+
| `--a11y-modal-height` | `auto` |
|
|
1347
1461
|
| `--a11y-modal-initial-scale` | `0.95` |
|
|
1462
|
+
| `--a11y-modal-max-height` | `100%` |
|
|
1463
|
+
| `--a11y-modal-max-width` | `100%` |
|
|
1348
1464
|
| `--a11y-modal-overlay-padding` | `clamp(1rem, 10vmin, 6rem)` |
|
|
1349
1465
|
| `--a11y-modal-shadow-blur` | `2px` |
|
|
1350
1466
|
| `--a11y-modal-shadow-fade` | `80%` |
|
|
1351
1467
|
| `--a11y-modal-shadow-offset-y` | `2px` |
|
|
1352
1468
|
| `--a11y-modal-transition-duration` | `0.3s` |
|
|
1469
|
+
| `--a11y-modal-width` | `min(32rem, 100%)` |
|
|
1353
1470
|
|
|
1354
1471
|
</details>
|
|
1355
1472
|
|
|
@@ -1388,13 +1505,13 @@ It's a page region, not an open/close overlay: it fires no open/close events and
|
|
|
1388
1505
|
|
|
1389
1506
|
| Option | Default | Description |
|
|
1390
1507
|
| --- | --- | --- |
|
|
1391
|
-
| `type` | `info` | `info`, `success` or `error` (`error` uses `role="alert"`). |
|
|
1508
|
+
| `type` | `info` | `info`, `success`, `warning` or `error` (`error` uses `role="alert"`). |
|
|
1392
1509
|
| `position` | `top` | `top` or `bottom`. |
|
|
1393
1510
|
| `actionText` / `onAction` | — | Adds an action button; clicking it runs `onAction` and dismisses the banner. |
|
|
1394
1511
|
| `onClose` | — | Called when the banner is dismissed. |
|
|
1395
1512
|
| `maxStack` | — | Sets `max-stack` on the region (sticky for later banners). |
|
|
1396
1513
|
|
|
1397
|
-
Classes: `.a11y-notification-banner--info` / `--success` / `--error`, `__message`, `__action`, `__close`.
|
|
1514
|
+
Classes: `.a11y-notification-banner--info` / `--success` / `--warning` / `--error`, `__message`, `__action`, `__close`.
|
|
1398
1515
|
|
|
1399
1516
|
<details>
|
|
1400
1517
|
<summary>CSS variables</summary>
|
|
@@ -1547,16 +1664,22 @@ Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` /
|
|
|
1547
1664
|
|
|
1548
1665
|
Status colors and the z-index scale, defined on `:root` (in `overlays/core/overlay-variables.css`). Override them globally, or override a component's own token instead.
|
|
1549
1666
|
|
|
1667
|
+
Each status color has a text color drawn on it (`--a11y-color-text-on-<type>`). Every default pair passes WCAG AA (4.5:1): success 5.13:1, info 5.75:1, error 5.62:1, warning 9.00:1. Warning is amber with dark text, since white on it is only 1.97:1. If you change a status color, check its contrast with its text color.
|
|
1668
|
+
|
|
1550
1669
|
<details>
|
|
1551
1670
|
<summary>CSS variables</summary>
|
|
1552
1671
|
|
|
1553
1672
|
| Variable | Default |
|
|
1554
1673
|
| --- | --- |
|
|
1555
|
-
| `--a11y-color-success` | `
|
|
1556
|
-
| `--a11y-color-error` | `
|
|
1557
|
-
| `--a11y-color-info` | `
|
|
1558
|
-
| `--a11y-color-warning` | `
|
|
1674
|
+
| `--a11y-color-success` | `#2e7d32` |
|
|
1675
|
+
| `--a11y-color-error` | `#c62828` |
|
|
1676
|
+
| `--a11y-color-info` | `#1565c0` |
|
|
1677
|
+
| `--a11y-color-warning` | `#f9a825` |
|
|
1559
1678
|
| `--a11y-color-text` | `white` |
|
|
1679
|
+
| `--a11y-color-text-on-success` | `var(--a11y-color-text)` |
|
|
1680
|
+
| `--a11y-color-text-on-error` | `var(--a11y-color-text)` |
|
|
1681
|
+
| `--a11y-color-text-on-info` | `var(--a11y-color-text)` |
|
|
1682
|
+
| `--a11y-color-text-on-warning` | `#111827` |
|
|
1560
1683
|
| `--a11y-z-base` | `0` |
|
|
1561
1684
|
| `--a11y-z-sticky-header` | `100` |
|
|
1562
1685
|
| `--a11y-z-sticky-footer` | `110` |
|
|
@@ -1614,6 +1737,65 @@ Override at `:root` (or `body`) and every instance of that component on the page
|
|
|
1614
1737
|
}
|
|
1615
1738
|
```
|
|
1616
1739
|
|
|
1740
|
+
### Theme with semantic variables
|
|
1741
|
+
|
|
1742
|
+
Every component color, and the form controls' radius and font, falls back to a global semantic variable before its shipped default:
|
|
1743
|
+
|
|
1744
|
+
```css
|
|
1745
|
+
/* from input.css */
|
|
1746
|
+
color: var(--a11y-input-color-text, var(--a11y-color-text-default, #111827));
|
|
1747
|
+
```
|
|
1748
|
+
|
|
1749
|
+
So a dozen variables theme every element, and the per-component ones still win where you set them:
|
|
1750
|
+
|
|
1751
|
+
| Variable | Default | Used for |
|
|
1752
|
+
| --- | --- | --- |
|
|
1753
|
+
| `--a11y-color-surface` | `#ffffff` | control and overlay backgrounds, text on primary or inverted surfaces |
|
|
1754
|
+
| `--a11y-color-surface-muted` | `#f3f4f6` | tracks, skeletons, avatar and select fills, the drop zone highlight |
|
|
1755
|
+
| `--a11y-color-surface-disabled` | `#e5e7eb` | disabled control backgrounds |
|
|
1756
|
+
| `--a11y-color-text-default` | `#111827` | text, the tooltip and floating launcher backgrounds |
|
|
1757
|
+
| `--a11y-color-text-muted` | `#6b7280` (`#4b5563` for hovers) | hints, secondary text, menu item and modal button hover backgrounds |
|
|
1758
|
+
| `--a11y-color-text-disabled` | `#9ca3af` | disabled text |
|
|
1759
|
+
| `--a11y-color-border` | `#d1d5db` | control borders |
|
|
1760
|
+
| `--a11y-color-border-strong` | `#9ca3af` | hovered borders, unchecked checkboxes and radios |
|
|
1761
|
+
| `--a11y-color-primary` | `#2563eb` | checked, active and focused states, links |
|
|
1762
|
+
| `--a11y-color-focus` | `--a11y-color-primary` | focus outlines |
|
|
1763
|
+
| `--a11y-color-danger` | `#b91c1c` | errors and required markers |
|
|
1764
|
+
| `--a11y-radius` | `4px` | input, textarea, select and file-input button radius |
|
|
1765
|
+
| `--a11y-font-family` | `inherit` | input, textarea and select text |
|
|
1766
|
+
|
|
1767
|
+
They aren't set anywhere by default. The defaults pass WCAG AA for text (4.5:1) in the pairs the elements use. If you change them, keep text on its surface at 4.5:1. Status colors are separate (see [Shared tokens](#shared-tokens)).
|
|
1768
|
+
|
|
1769
|
+
### Dark mode
|
|
1770
|
+
|
|
1771
|
+
Load the opt-in dark theme after `a11y.css`:
|
|
1772
|
+
|
|
1773
|
+
```html
|
|
1774
|
+
<link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y.css" />
|
|
1775
|
+
<link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y-dark.css" />
|
|
1776
|
+
```
|
|
1777
|
+
|
|
1778
|
+
```js
|
|
1779
|
+
import 'a11y-elements/a11y.css';
|
|
1780
|
+
import 'a11y-elements/a11y-dark.css';
|
|
1781
|
+
```
|
|
1782
|
+
|
|
1783
|
+
It redefines only the semantic variables above and sets `color-scheme: dark`, so native parts (scrollbars, `<select>` popups) follow. It applies under `prefers-color-scheme: dark`. `data-theme="dark"` or `data-theme="light"` on `<html>` forces a theme. Status colors keep their values: they pass AA with their text in both themes.
|
|
1784
|
+
|
|
1785
|
+
To use your own palette instead, set the semantic variables yourself under your dark selector:
|
|
1786
|
+
|
|
1787
|
+
```css
|
|
1788
|
+
@media (prefers-color-scheme: dark) {
|
|
1789
|
+
:root {
|
|
1790
|
+
--a11y-color-surface: var(--my-surface);
|
|
1791
|
+
--a11y-color-text-default: var(--my-text);
|
|
1792
|
+
/* … */
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
```
|
|
1796
|
+
|
|
1797
|
+
Set them on `:root`, not on a dark-themed wrapper: overlays move to `<body>`, out of the wrapper (see below).
|
|
1798
|
+
|
|
1617
1799
|
### Scope to one instance
|
|
1618
1800
|
|
|
1619
1801
|
The same custom properties follow ordinary CSS cascade/inheritance, so you can target just one element instead. Two equivalent ways to do it:
|
|
@@ -1634,10 +1816,19 @@ The same custom properties follow ordinary CSS cascade/inheritance, so you can t
|
|
|
1634
1816
|
|
|
1635
1817
|
Either way, only that element changes — every other `<a11y-spinner>` on the page keeps its default (or globally-rethemed) look.
|
|
1636
1818
|
|
|
1819
|
+
**Overlays are the exception for ancestors:** they move to `<body>` when connected, so variables set on a wrapper around one (`.dark-section { --a11y-modal-color-background: … }`) no longer reach it. Set overlay variables on `:root` / `body`, or on the overlay element itself (an inline style or a class on `<a11y-modal>`).
|
|
1820
|
+
|
|
1637
1821
|
Attributes that map to a custom property (`<a11y-spinner color="…" size="…">`, `<a11y-avatar size="…">`, `<a11y-skeleton width="…" height="…">`) take precedence over your inline value only while they're set; removing the attribute brings your inline value back.
|
|
1638
1822
|
|
|
1639
1823
|
The full list of tokens, with their defaults, is in the shipped `dist/a11y.css` — search it for `--a11y-<component>-`.
|
|
1640
1824
|
|
|
1825
|
+
## Testing
|
|
1826
|
+
|
|
1827
|
+
* **Elements exist only once their `define` entry is imported.** In a test that doesn't import it, an `<a11y-checkbox>` stays a plain unknown element. Read its attributes (`label`, …), and don't expect overlays to move to `<body>`, build their chrome or fire their events.
|
|
1828
|
+
* **The elements run under jsdom** once defined. This library's own suite does, with a small polyfill for `ElementInternals` validity (`setValidity()`, `validity`), which jsdom lacks and the form fields use. Expect no layout: positioning and transitions resolve immediately.
|
|
1829
|
+
* **Stub `notify()`** through your own wrapper (a service that calls it), and replace the wrapper in tests.
|
|
1830
|
+
* **Simulate a user closing an overlay:** with the element defined, call `close('escape')` (or `'backdrop'`, …): it fires `a11y-overlay-close` and `onClose` with that reason. Without it, set `open = false` and dispatch the event yourself: `document.dispatchEvent(new CustomEvent('a11y-overlay-close', { detail: { name: 'a11y-modal', element: modal, reason: 'escape' } }))`.
|
|
1831
|
+
|
|
1641
1832
|
## License
|
|
1642
1833
|
|
|
1643
1834
|
MIT — see [`LICENSE.txt`](./LICENSE.txt).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* src/a11y-dark.css */
|
|
2
|
+
@media (prefers-color-scheme: dark) {
|
|
3
|
+
:root:not([data-theme=light]) {
|
|
4
|
+
color-scheme: dark;
|
|
5
|
+
--a11y-color-surface: #1f2937;
|
|
6
|
+
--a11y-color-surface-muted: #374151;
|
|
7
|
+
--a11y-color-surface-disabled: #374151;
|
|
8
|
+
--a11y-color-text-default: #f9fafb;
|
|
9
|
+
--a11y-color-text-muted: #9ca3af;
|
|
10
|
+
--a11y-color-text-disabled: #6b7280;
|
|
11
|
+
--a11y-color-border: #4b5563;
|
|
12
|
+
--a11y-color-border-strong: #6b7280;
|
|
13
|
+
--a11y-color-primary: #60a5fa;
|
|
14
|
+
--a11y-color-focus: #93c5fd;
|
|
15
|
+
--a11y-color-danger: #f87171;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
:root[data-theme=dark] {
|
|
19
|
+
color-scheme: dark;
|
|
20
|
+
--a11y-color-surface: #1f2937;
|
|
21
|
+
--a11y-color-surface-muted: #374151;
|
|
22
|
+
--a11y-color-surface-disabled: #374151;
|
|
23
|
+
--a11y-color-text-default: #f9fafb;
|
|
24
|
+
--a11y-color-text-muted: #9ca3af;
|
|
25
|
+
--a11y-color-text-disabled: #6b7280;
|
|
26
|
+
--a11y-color-border: #4b5563;
|
|
27
|
+
--a11y-color-border-strong: #6b7280;
|
|
28
|
+
--a11y-color-primary: #60a5fa;
|
|
29
|
+
--a11y-color-focus: #93c5fd;
|
|
30
|
+
--a11y-color-danger: #f87171;
|
|
31
|
+
}
|