a11y-elements 0.3.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 +343 -22
- package/dist/a11y-dark.css +31 -0
- package/dist/a11y.css +396 -154
- package/dist/all.d.ts +39 -0
- package/dist/all.js +39 -0
- package/dist/all.js.map +1 -0
- package/dist/browser/all.js +155 -0
- package/dist/browser/all.js.map +1 -0
- package/dist/browser/chunk-32FZURPA.js +19 -0
- package/dist/browser/chunk-32FZURPA.js.map +1 -0
- package/dist/browser/chunk-46DKJF7A.js +41 -0
- package/dist/browser/chunk-46DKJF7A.js.map +1 -0
- package/dist/browser/chunk-4A7L5TW6.js +170 -0
- package/dist/browser/chunk-4A7L5TW6.js.map +1 -0
- package/dist/browser/chunk-4KU26VOY.js +16 -0
- package/dist/browser/chunk-4KU26VOY.js.map +1 -0
- package/dist/browser/chunk-5ERYLJ24.js +179 -0
- package/dist/browser/chunk-5ERYLJ24.js.map +1 -0
- package/dist/browser/chunk-6DXBSCNO.js +72 -0
- package/dist/browser/chunk-6DXBSCNO.js.map +1 -0
- package/dist/browser/chunk-6Q5EEBYM.js +125 -0
- package/dist/browser/chunk-6Q5EEBYM.js.map +1 -0
- package/dist/browser/chunk-6XDUSEPL.js +52 -0
- package/dist/browser/chunk-6XDUSEPL.js.map +1 -0
- package/dist/browser/chunk-7QBDJCWN.js +81 -0
- package/dist/browser/chunk-7QBDJCWN.js.map +1 -0
- package/dist/browser/chunk-AEUQEMRJ.js +82 -0
- package/dist/browser/chunk-AEUQEMRJ.js.map +1 -0
- package/dist/browser/chunk-AFEWHFFA.js +122 -0
- package/dist/browser/chunk-AFEWHFFA.js.map +1 -0
- package/dist/browser/chunk-AGSRNTSW.js +106 -0
- package/dist/browser/chunk-AGSRNTSW.js.map +1 -0
- package/dist/browser/chunk-EJZPHR4Z.js +43 -0
- package/dist/browser/chunk-EJZPHR4Z.js.map +1 -0
- package/dist/browser/chunk-ETTLTMRE.js +123 -0
- package/dist/browser/chunk-ETTLTMRE.js.map +1 -0
- package/dist/browser/chunk-F47DDMFE.js +39 -0
- package/dist/browser/chunk-F47DDMFE.js.map +1 -0
- package/dist/browser/chunk-FAEA66RR.js +29 -0
- package/dist/browser/chunk-FAEA66RR.js.map +1 -0
- package/dist/browser/chunk-H4U5TGR6.js +137 -0
- package/dist/browser/chunk-H4U5TGR6.js.map +1 -0
- package/dist/browser/chunk-H5HLB3X6.js +449 -0
- package/dist/browser/chunk-H5HLB3X6.js.map +1 -0
- package/dist/browser/chunk-HAYNMWNF.js +67 -0
- package/dist/browser/chunk-HAYNMWNF.js.map +1 -0
- package/dist/browser/chunk-HEV3NTM6.js +40 -0
- package/dist/browser/chunk-HEV3NTM6.js.map +1 -0
- package/dist/browser/chunk-HZBBOI27.js +24 -0
- package/dist/browser/chunk-HZBBOI27.js.map +1 -0
- package/dist/browser/chunk-IXBSR3RY.js +400 -0
- package/dist/browser/chunk-IXBSR3RY.js.map +1 -0
- package/dist/browser/chunk-J5JL2LV4.js +48 -0
- package/dist/browser/chunk-J5JL2LV4.js.map +1 -0
- package/dist/browser/chunk-JPQMMJFO.js +169 -0
- package/dist/browser/chunk-JPQMMJFO.js.map +1 -0
- package/dist/browser/chunk-K62Y2QZ4.js +76 -0
- package/dist/browser/chunk-K62Y2QZ4.js.map +1 -0
- package/dist/browser/chunk-KPLZJOV4.js +249 -0
- 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-MLHDJFAO.js +68 -0
- package/dist/browser/chunk-MLHDJFAO.js.map +1 -0
- package/dist/browser/chunk-OOIGBD2C.js +138 -0
- package/dist/browser/chunk-OOIGBD2C.js.map +1 -0
- package/dist/browser/chunk-QN7QZKRL.js +547 -0
- package/dist/browser/chunk-QN7QZKRL.js.map +1 -0
- package/dist/browser/chunk-QRO7M2WV.js +19 -0
- package/dist/browser/chunk-QRO7M2WV.js.map +1 -0
- package/dist/browser/chunk-SUYBZFH7.js +39 -0
- package/dist/browser/chunk-SUYBZFH7.js.map +1 -0
- package/dist/browser/chunk-T2CQXIHN.js +66 -0
- package/dist/browser/chunk-T2CQXIHN.js.map +1 -0
- package/dist/browser/chunk-UAPYZK4I.js +412 -0
- package/dist/browser/chunk-UAPYZK4I.js.map +1 -0
- package/dist/browser/chunk-ULMVOYTV.js +72 -0
- package/dist/browser/chunk-ULMVOYTV.js.map +1 -0
- package/dist/browser/chunk-WCCLCAYH.js +51 -0
- package/dist/browser/chunk-WCCLCAYH.js.map +1 -0
- package/dist/browser/chunk-WNLXSUPC.js +73 -0
- package/dist/browser/chunk-WNLXSUPC.js.map +1 -0
- package/dist/browser/chunk-WOK76CEK.js +76 -0
- package/dist/browser/chunk-WOK76CEK.js.map +1 -0
- package/dist/browser/chunk-WOMR3M72.js +56 -0
- package/dist/browser/chunk-WOMR3M72.js.map +1 -0
- package/dist/browser/chunk-XH66G6MU.js +78 -0
- package/dist/browser/chunk-XH66G6MU.js.map +1 -0
- package/dist/browser/chunk-YGWMBM3X.js +100 -0
- package/dist/browser/chunk-YGWMBM3X.js.map +1 -0
- package/dist/browser/chunk-ZCMKKXSE.js +204 -0
- package/dist/browser/chunk-ZCMKKXSE.js.map +1 -0
- package/dist/browser/chunk-ZHK7NWCK.js +189 -0
- package/dist/browser/chunk-ZHK7NWCK.js.map +1 -0
- package/dist/browser/components/anchor/define.js +9 -322
- package/dist/browser/components/anchor/define.js.map +1 -1
- package/dist/browser/components/avatar/define.js +7 -258
- package/dist/browser/components/avatar/define.js.map +1 -1
- package/dist/browser/components/card-link/define.js +16 -0
- package/dist/browser/components/card-link/define.js.map +1 -0
- package/dist/browser/components/checkbox/define.js +9 -277
- package/dist/browser/components/checkbox/define.js.map +1 -1
- package/dist/browser/components/checkbox-group/define.js +9 -388
- package/dist/browser/components/checkbox-group/define.js.map +1 -1
- package/dist/browser/components/file-input/define.js +13 -1062
- package/dist/browser/components/file-input/define.js.map +1 -1
- package/dist/browser/components/focusable/define.js +7 -205
- package/dist/browser/components/focusable/define.js.map +1 -1
- package/dist/browser/components/input/define.js +13 -690
- package/dist/browser/components/input/define.js.map +1 -1
- package/dist/browser/components/label/define.js +9 -268
- package/dist/browser/components/label/define.js.map +1 -1
- package/dist/browser/components/picture/define.js +9 -405
- package/dist/browser/components/picture/define.js.map +1 -1
- package/dist/browser/components/progress/define.js +7 -233
- package/dist/browser/components/progress/define.js.map +1 -1
- package/dist/browser/components/radio-group/define.js +9 -298
- package/dist/browser/components/radio-group/define.js.map +1 -1
- package/dist/browser/components/select/define.js +9 -276
- package/dist/browser/components/select/define.js.map +1 -1
- package/dist/browser/components/skeleton/define.js +7 -228
- package/dist/browser/components/skeleton/define.js.map +1 -1
- package/dist/browser/components/spinner/define.js +7 -254
- package/dist/browser/components/spinner/define.js.map +1 -1
- package/dist/browser/components/switch/define.js +9 -284
- package/dist/browser/components/switch/define.js.map +1 -1
- 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 +13 -690
- package/dist/browser/components/textarea/define.js.map +1 -1
- package/dist/browser/components/visually-hidden/define.js +7 -189
- package/dist/browser/components/visually-hidden/define.js.map +1 -1
- package/dist/browser/overlays/blocking-loader/define.js +14 -512
- package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
- package/dist/browser/overlays/context-menu/define.js +16 -944
- package/dist/browser/overlays/context-menu/define.js.map +1 -1
- package/dist/browser/overlays/drawer/define.js +15 -714
- package/dist/browser/overlays/drawer/define.js.map +1 -1
- package/dist/browser/overlays/dropdown/define.js +16 -940
- package/dist/browser/overlays/dropdown/define.js.map +1 -1
- package/dist/browser/overlays/emergency-dialog/define.js +15 -710
- package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/browser/overlays/floating/define.js +21 -0
- package/dist/browser/overlays/floating/define.js.map +1 -0
- package/dist/browser/overlays/modal/define.js +17 -707
- package/dist/browser/overlays/modal/define.js.map +1 -1
- package/dist/browser/overlays/notification-banner/define.js +14 -449
- package/dist/browser/overlays/notification-banner/define.js.map +1 -1
- package/dist/browser/overlays/popover/define.js +15 -794
- package/dist/browser/overlays/popover/define.js.map +1 -1
- package/dist/browser/overlays/snackbar/define.js +14 -405
- package/dist/browser/overlays/snackbar/define.js.map +1 -1
- package/dist/browser/overlays/tooltip/define.js +16 -890
- package/dist/browser/overlays/tooltip/define.js.map +1 -1
- package/dist/components/anchor/define.d.ts +1 -1
- package/dist/components/anchor/define.js +3 -5
- package/dist/components/anchor/define.js.map +1 -1
- package/dist/components/avatar/define.d.ts +1 -1
- package/dist/components/avatar/define.js +3 -5
- package/dist/components/avatar/define.js.map +1 -1
- package/dist/components/card-link/card-link.element.d.ts +47 -0
- package/dist/components/card-link/card-link.element.js +129 -0
- package/dist/components/card-link/card-link.element.js.map +1 -0
- package/dist/components/card-link/define.d.ts +8 -0
- package/dist/components/card-link/define.js +6 -0
- package/dist/components/card-link/define.js.map +1 -0
- package/dist/components/checkbox/define.d.ts +1 -1
- package/dist/components/checkbox/define.js +3 -5
- package/dist/components/checkbox/define.js.map +1 -1
- package/dist/components/checkbox-group/define.d.ts +1 -1
- package/dist/components/checkbox-group/define.js +3 -5
- package/dist/components/checkbox-group/define.js.map +1 -1
- package/dist/components/file-input/define.d.ts +1 -1
- package/dist/components/file-input/define.js +3 -5
- package/dist/components/file-input/define.js.map +1 -1
- package/dist/components/focusable/define.d.ts +1 -1
- package/dist/components/focusable/define.js +3 -5
- package/dist/components/focusable/define.js.map +1 -1
- package/dist/components/focusable/focusable.element.d.ts +1 -1
- package/dist/components/focusable/focusable.element.js +3 -3
- package/dist/components/focusable/focusable.element.js.map +1 -1
- package/dist/components/input/define.d.ts +1 -1
- package/dist/components/input/define.js +3 -5
- package/dist/components/input/define.js.map +1 -1
- package/dist/components/label/define.d.ts +1 -1
- package/dist/components/label/define.js +3 -5
- package/dist/components/label/define.js.map +1 -1
- package/dist/components/picture/define.d.ts +1 -1
- package/dist/components/picture/define.js +3 -5
- package/dist/components/picture/define.js.map +1 -1
- package/dist/components/progress/define.d.ts +1 -1
- package/dist/components/progress/define.js +3 -5
- package/dist/components/progress/define.js.map +1 -1
- package/dist/components/radio-group/define.d.ts +1 -1
- package/dist/components/radio-group/define.js +3 -5
- package/dist/components/radio-group/define.js.map +1 -1
- package/dist/components/select/define.d.ts +1 -1
- package/dist/components/select/define.js +3 -5
- package/dist/components/select/define.js.map +1 -1
- package/dist/components/skeleton/define.d.ts +1 -1
- package/dist/components/skeleton/define.js +3 -5
- package/dist/components/skeleton/define.js.map +1 -1
- package/dist/components/skeleton/skeleton.element.js +2 -2
- package/dist/components/skeleton/skeleton.element.js.map +1 -1
- package/dist/components/spinner/define.d.ts +1 -1
- package/dist/components/spinner/define.js +3 -5
- package/dist/components/spinner/define.js.map +1 -1
- package/dist/components/switch/define.d.ts +1 -1
- package/dist/components/switch/define.js +3 -5
- package/dist/components/switch/define.js.map +1 -1
- 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/components/textarea/define.d.ts +1 -1
- package/dist/components/textarea/define.js +3 -5
- package/dist/components/textarea/define.js.map +1 -1
- package/dist/components/visually-hidden/define.d.ts +1 -1
- package/dist/components/visually-hidden/define.js +3 -5
- package/dist/components/visually-hidden/define.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.element.d.ts +1 -1
- package/dist/components/visually-hidden/visually-hidden.element.js +3 -4
- package/dist/components/visually-hidden/visually-hidden.element.js.map +1 -1
- package/dist/core/a11y-element.d.ts +14 -6
- package/dist/core/a11y-element.js +7 -3
- package/dist/core/a11y-element.js.map +1 -1
- 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/define-element.d.ts +6 -0
- package/dist/core/define-element.js +10 -0
- package/dist/core/define-element.js.map +1 -0
- 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/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.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/sanitize.d.ts +21 -0
- package/dist/core/sanitize.js +107 -0
- package/dist/core/sanitize.js.map +1 -0
- package/dist/core/strings.d.ts +5 -1
- package/dist/core/strings.js +5 -3
- package/dist/core/strings.js.map +1 -1
- package/dist/core/template.d.ts +37 -7
- package/dist/core/template.js +211 -17
- package/dist/core/template.js.map +1 -1
- package/dist/core/zero-build-exports.d.ts +1 -0
- package/dist/core/zero-build-exports.js +3 -0
- package/dist/core/zero-build-exports.js.map +1 -0
- package/dist/overlays/blocking-loader/blocking-loader.element.js +2 -2
- package/dist/overlays/blocking-loader/blocking-loader.element.js.map +1 -1
- package/dist/overlays/blocking-loader/define.d.ts +1 -2
- package/dist/overlays/blocking-loader/define.js +3 -6
- package/dist/overlays/blocking-loader/define.js.map +1 -1
- package/dist/overlays/context-menu/define.d.ts +1 -2
- package/dist/overlays/context-menu/define.js +3 -6
- package/dist/overlays/context-menu/define.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 +30 -5
- package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-passive-overlay-element.d.ts +3 -1
- package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
- package/dist/overlays/core/zero-build-exports.d.ts +2 -0
- package/dist/overlays/core/zero-build-exports.js +4 -0
- package/dist/overlays/core/zero-build-exports.js.map +1 -0
- package/dist/overlays/drawer/define.d.ts +1 -2
- package/dist/overlays/drawer/define.js +3 -6
- package/dist/overlays/drawer/define.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/dropdown/define.d.ts +1 -2
- package/dist/overlays/dropdown/define.js +3 -6
- package/dist/overlays/dropdown/define.js.map +1 -1
- package/dist/overlays/emergency-dialog/define.d.ts +1 -2
- package/dist/overlays/emergency-dialog/define.js +3 -6
- package/dist/overlays/emergency-dialog/define.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/define.d.ts +8 -0
- package/dist/overlays/floating/define.js +6 -0
- package/dist/overlays/floating/define.js.map +1 -0
- package/dist/overlays/floating/floating.element.d.ts +125 -0
- package/dist/overlays/floating/floating.element.js +621 -0
- package/dist/overlays/floating/floating.element.js.map +1 -0
- 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 +2 -2
- package/dist/overlays/modal/define.js +4 -6
- 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/define.d.ts +3 -3
- package/dist/overlays/notification-banner/define.js +3 -6
- package/dist/overlays/notification-banner/define.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +3 -2
- package/dist/overlays/notification-banner/notification-banner.element.js +2 -2
- package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
- package/dist/overlays/popover/define.d.ts +1 -2
- package/dist/overlays/popover/define.js +3 -6
- package/dist/overlays/popover/define.js.map +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/dist/overlays/snackbar/define.d.ts +3 -3
- package/dist/overlays/snackbar/define.js +3 -6
- package/dist/overlays/snackbar/define.js.map +1 -1
- package/dist/overlays/snackbar/snackbar.element.d.ts +2 -1
- package/dist/overlays/snackbar/snackbar.element.js +2 -2
- package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
- package/dist/overlays/tooltip/define.d.ts +1 -2
- package/dist/overlays/tooltip/define.js +3 -6
- package/dist/overlays/tooltip/define.js.map +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@ 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
|
|
|
11
11
|
### Zero-build
|
|
12
12
|
|
|
13
|
-
Load a component's
|
|
13
|
+
Load a component's browser bundle directly, no bundler required:
|
|
14
14
|
|
|
15
15
|
```html
|
|
16
16
|
<link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y.css" />
|
|
@@ -19,8 +19,9 @@ Load a component's standalone browser bundle directly, no bundler required:
|
|
|
19
19
|
<a11y-spinner></a11y-spinner>
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
* Each component has its own `define.js` under `dist/browser/**`.
|
|
23
|
-
*
|
|
22
|
+
* Each component has its own `define.js` under `dist/browser/**`. Load only the ones you use.
|
|
23
|
+
* They share their common code through `chunk-*.js` files in `dist/browser/`, so the browser fetches it once however many you load. Serve them from the package's `dist/browser/` folder as is: a `define.js` copied on its own won't load.
|
|
24
|
+
* `dist/browser/all.js` registers every element at once and exports everything the individual bundles do.
|
|
24
25
|
* Page-wide state is shared between bundles, so mixing several on one page is safe.
|
|
25
26
|
* Overlay bundles also export `dismissAllOverlays()`:
|
|
26
27
|
|
|
@@ -44,6 +45,7 @@ import { A11yElement } from 'a11y-elements/core';
|
|
|
44
45
|
|
|
45
46
|
* There's no default export: `import 'a11y-elements'` alone will fail.
|
|
46
47
|
* Import the component you want: `/element` gets you the class itself when you need it
|
|
48
|
+
* `import 'a11y-elements/all'` registers every element at once, and exports every element class plus `setStrings()`, `dismissAllOverlays()`, `notify()` and the other helpers the individual entries export.
|
|
47
49
|
* See [Elements](#elements) for every component.
|
|
48
50
|
|
|
49
51
|
Importing a component's subpath also adds its tag to TypeScript's `HTMLElementTagNameMap`, so exact-tag lookups such as `document.createElement('a11y-checkbox')` or `document.querySelector('a11y-checkbox')` come back typed as `CheckboxElement` without a cast.
|
|
@@ -54,7 +56,6 @@ A few English strings end up in accessible names and announcements. Replace them
|
|
|
54
56
|
|
|
55
57
|
```js
|
|
56
58
|
import { setStrings } from 'a11y-elements/core';
|
|
57
|
-
// or: import { setStrings } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
|
|
58
59
|
|
|
59
60
|
setStrings({
|
|
60
61
|
closeDialog: 'Fermer la boîte de dialogue',
|
|
@@ -67,8 +68,9 @@ setStrings({
|
|
|
67
68
|
| --- | --- | --- | --- |
|
|
68
69
|
| `opensInNewTab` | `(opens in new tab)` | `<a11y-anchor>` new-tab links | `new-tab-label` |
|
|
69
70
|
| `navigatedTo` | `Navigated to {name}` | `<a11y-anchor>` jump announcement (`{name}` is the target's name) | `navigated-label` |
|
|
70
|
-
| `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>` | `close-label` |
|
|
71
|
-
| `
|
|
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
|
+
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item and of a `dismissible` `<a11y-floating>` | `dismiss-label` |
|
|
72
74
|
| `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
|
|
73
75
|
| `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
|
|
74
76
|
| `avatar` | `Avatar` | `<a11y-avatar>` with no `alt` or `initials` | `alt` / `initials` |
|
|
@@ -96,9 +98,9 @@ Each section shows an example, the element's own attributes/properties/methods,
|
|
|
96
98
|
|
|
97
99
|
Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
98
100
|
|
|
99
|
-
**Accessibility components:** [`<a11y-anchor>`](#a11y-anchor) · [`<a11y-avatar>`](#a11y-avatar) · [`<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)
|
|
100
102
|
|
|
101
|
-
**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-modal>`](#a11y-modal) · [`<a11y-notification-banner>`](#a11y-notification-banner) · [`<a11y-popover>`](#a11y-popover) · [`<a11y-snackbar>`](#a11y-snackbar) · [`<a11y-tooltip>`](#a11y-tooltip)
|
|
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)
|
|
102
104
|
|
|
103
105
|
Import paths follow the folder names: `a11y-elements/components/<name>` or `a11y-elements/overlays/<name>` (add `/element` for the class), and `dist/browser/<group>/<name>/define.js` for zero-build.
|
|
104
106
|
|
|
@@ -144,6 +146,8 @@ An avatar image with an initials fallback. When the image is missing or fails to
|
|
|
144
146
|
| `size` | attribute | — | Sets `--a11y-avatar-size`. |
|
|
145
147
|
| `shape` | attribute / property | `circle` | `circle` or `square`. |
|
|
146
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
|
+
|
|
147
151
|
<details>
|
|
148
152
|
<summary>CSS variables</summary>
|
|
149
153
|
|
|
@@ -161,6 +165,44 @@ An avatar image with an initials fallback. When the image is missing or fails to
|
|
|
161
165
|
|
|
162
166
|
</details>
|
|
163
167
|
|
|
168
|
+
#### `a11y-card-link`
|
|
169
|
+
|
|
170
|
+
Makes a whole card go to one page through a real `<a href>` inside it (usually around the title). The link stays the card's only tab stop and its accessible name, so screen readers announce a link named by the title, Enter follows it, Space scrolls the page, and middle-click, "Open in new tab" and "Copy link address" work on it.
|
|
171
|
+
|
|
172
|
+
A click anywhere else on the card is forwarded to the link with a real `click()`, so your own click handlers on the link (an SPA router's) run for it too. Clicks aren't forwarded when they land on another control in the card (a button, a second link, an input…), when the user was selecting text, or when something already called `preventDefault()`. Cmd/Ctrl/Shift-click and middle-click on the card open the link in a new tab.
|
|
173
|
+
|
|
174
|
+
The card gets no `role` or `tabindex`. Use it for cards that navigate; for cards that perform an action, use a `<button>` or [`<a11y-focusable>`](#a11y-focusable).
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<a11y-card-link describe>
|
|
178
|
+
<div class="card">
|
|
179
|
+
<svg aria-hidden="true">…</svg>
|
|
180
|
+
<h3><a href="/articles/why-nutin">Why Nutin?</a></h3>
|
|
181
|
+
<p data-card-description>The idea behind the framework…</p>
|
|
182
|
+
</div>
|
|
183
|
+
</a11y-card-link>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
| Name | Kind | Default | Description |
|
|
187
|
+
| --- | --- | --- | --- |
|
|
188
|
+
| `describe` | attribute (boolean) | — | Adds the `data-card-description` element to the link's `aria-describedby` (giving it an id if it has none), so it's read after the title. |
|
|
189
|
+
| `data-card-link` | attribute, on an `<a href>` inside | — | The link to use when the card has several. Otherwise the first `<a href>` is used. Without one, a console warning is logged. |
|
|
190
|
+
| `data-card-description` | attribute, on an element inside | — | The description `describe` points to. |
|
|
191
|
+
| `link` | property (read-only) | — | The link the card navigates through. |
|
|
192
|
+
|
|
193
|
+
The whole card is outlined while its link has keyboard focus (`:has(:focus-visible)`). In browsers without `:has()`, the link keeps its own focus ring.
|
|
194
|
+
|
|
195
|
+
<details>
|
|
196
|
+
<summary>CSS variables</summary>
|
|
197
|
+
|
|
198
|
+
| Variable | Default |
|
|
199
|
+
| --- | --- |
|
|
200
|
+
| `--a11y-card-link-focus-outline-color` | `#2563eb` |
|
|
201
|
+
| `--a11y-card-link-focus-outline-offset` | `2px` |
|
|
202
|
+
| `--a11y-card-link-focus-outline-width` | `2px` |
|
|
203
|
+
|
|
204
|
+
</details>
|
|
205
|
+
|
|
164
206
|
#### `a11y-checkbox`
|
|
165
207
|
|
|
166
208
|
Wraps a real `<input type="checkbox">` in a `<label>` with a visible label text. The input stays yours: `name`, `checked`, `disabled`, `required` are plain HTML attributes on it.
|
|
@@ -350,6 +392,8 @@ The hint and error use the [shared field variables](#a11y-input).
|
|
|
350
392
|
|
|
351
393
|
Makes a non-button element behave like a button: `role="button"`, `tabindex="0"`, and Enter/Space fire a real `click`, so one `click` listener covers mouse and keyboard. Prefer a real `<button>` whenever you can.
|
|
352
394
|
|
|
395
|
+
It's for **actions**. Cards that go to another page should use [`<a11y-card-link>`](#a11y-card-link) or a plain `<a href>`: a button role, Space activation and no `href` mislead screen-reader users and break "Open in new tab".
|
|
396
|
+
|
|
353
397
|
```html
|
|
354
398
|
<a11y-focusable aria-label="Expand menu">
|
|
355
399
|
<svg aria-hidden="true">…</svg> Menu
|
|
@@ -720,6 +764,8 @@ Wraps a real `<select>` in a `<label>` with a visible label text. Options and ke
|
|
|
720
764
|
| `onChange` | callback | — | `(value: string) => void`, called on every `change`. |
|
|
721
765
|
| `getValue()` / `setValue(value)` | method | — | Reads / sets the selected value. |
|
|
722
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
|
+
|
|
723
769
|
<details>
|
|
724
770
|
<summary>CSS variables</summary>
|
|
725
771
|
|
|
@@ -735,7 +781,7 @@ Wraps a real `<select>` in a `<label>` with a visible label text. Options and ke
|
|
|
735
781
|
| `--a11y-select-color-text-muted` | `#6b7280` |
|
|
736
782
|
| `--a11y-select-control-border-radius` | `4px` |
|
|
737
783
|
| `--a11y-select-control-border-width` | `1px` |
|
|
738
|
-
| `--a11y-select-control-font-family` | `
|
|
784
|
+
| `--a11y-select-control-font-family` | `inherit` |
|
|
739
785
|
| `--a11y-select-control-font-size` | `1rem` |
|
|
740
786
|
| `--a11y-select-control-line-height` | `1.4` |
|
|
741
787
|
| `--a11y-select-control-padding-x` | `1rem` |
|
|
@@ -870,6 +916,61 @@ Like `<a11y-checkbox>`, but the input gets `role="switch"`.
|
|
|
870
916
|
|
|
871
917
|
</details>
|
|
872
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
|
+
|
|
873
974
|
#### `a11y-textarea`
|
|
874
975
|
|
|
875
976
|
`<a11y-input>` for a real `<textarea>`: same parts, attributes, properties, validation and states.
|
|
@@ -918,8 +1019,23 @@ No attributes or CSS variables. The class `a11y-visually-hidden` is also usable
|
|
|
918
1019
|
|
|
919
1020
|
* **Open/close** with the `open` attribute or property, or `show()` / `close()`.
|
|
920
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.
|
|
921
|
-
* **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`.
|
|
922
1037
|
* **`dismissAllOverlays()`** closes every open overlay (e.g. on navigation). It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
1038
|
+
* **Except `<a11y-floating>`**, which is visible by default and has no `open`: `dismissAllOverlays()` only collapses its expanded panel. See [`a11y-floating`](#a11y-floating).
|
|
923
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.
|
|
924
1040
|
|
|
925
1041
|
##### Overlays in a framework
|
|
@@ -949,14 +1065,19 @@ If the bundle loads after rendering, the same query does find it, so the result
|
|
|
949
1065
|
* bind events on the overlay element itself, or delegate from it;
|
|
950
1066
|
* put final text into the markup before injecting it, rather than in a pass after rendering.
|
|
951
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
|
+
|
|
952
1072
|
<a id="dialogs"></a>
|
|
953
1073
|
|
|
954
1074
|
##### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
|
|
955
1075
|
|
|
956
1076
|
They also share:
|
|
957
1077
|
|
|
958
|
-
* 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.
|
|
959
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.
|
|
960
1081
|
* The dialog is named after its first heading (`aria-labelledby`), or `dialog-label`.
|
|
961
1082
|
|
|
962
1083
|
| Name | Kind | Default | Description |
|
|
@@ -964,8 +1085,9 @@ They also share:
|
|
|
964
1085
|
| `non-dismissible` | attribute | absent | No close button, no Escape, no backdrop click: close it from code. |
|
|
965
1086
|
| `dialog-label` | attribute | — | Accessible name (`aria-label`) when there's no heading. |
|
|
966
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. |
|
|
967
1089
|
| `dismissible` | property (read-only) | `true` | Inverse of `non-dismissible`. |
|
|
968
|
-
| `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). |
|
|
969
1091
|
|
|
970
1092
|
<a id="anchored-overlays"></a>
|
|
971
1093
|
|
|
@@ -1087,7 +1209,7 @@ A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dia
|
|
|
1087
1209
|
| --- | --- | --- | --- |
|
|
1088
1210
|
| `edge` | attribute / property (read-only) | `right` | `left`, `right`, `top` or `bottom`. Read when the drawer opens. |
|
|
1089
1211
|
|
|
1090
|
-
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()`.
|
|
1091
1213
|
|
|
1092
1214
|
<details>
|
|
1093
1215
|
<summary>CSS variables</summary>
|
|
@@ -1171,6 +1293,89 @@ From the shared [dialog](#dialogs) options, only `dialog-label` and `onClose` ap
|
|
|
1171
1293
|
|
|
1172
1294
|
</details>
|
|
1173
1295
|
|
|
1296
|
+
#### `a11y-floating`
|
|
1297
|
+
|
|
1298
|
+
Content pinned to a corner or edge of the viewport: a floating button that opens a drawer, an info bubble, a help launcher. It's visible by default: there's no `open` attribute. Hide it with `hidden` or `dismiss()`. Several in the same position stack instead of overlapping.
|
|
1299
|
+
|
|
1300
|
+
It works in one of two modes:
|
|
1301
|
+
|
|
1302
|
+
* **Controls mode:** with `controls="<id>"`, its trigger opens and closes that overlay. The trigger is a `[data-floating-trigger]` child, else the first button. It gets `aria-controls`, an `aria-expanded` kept in sync with the overlay however it closes, and `aria-haspopup` (`dialog` for a modal, drawer, emergency dialog or `interactive` popover; `menu` for a dropdown or context menu). A popover or dropdown with no anchor is anchored to the trigger.
|
|
1303
|
+
* **Expandable mode:** with `expandable`, its content goes into a panel (`role="dialog"`, not modal) that a launcher button expands. The launcher is a `[data-floating-trigger]` child, else a generated button showing `label`. Expanding moves focus to the panel's first control. Escape, a click outside, the panel's × or the launcher collapse it, and focus returns to the launcher. The panel is named by `panel-label`, else its first heading, else `label`.
|
|
1304
|
+
|
|
1305
|
+
```html
|
|
1306
|
+
<!-- Opens a drawer -->
|
|
1307
|
+
<a11y-floating controls="nav-drawer"><button>Menu</button></a11y-floating>
|
|
1308
|
+
<a11y-drawer id="nav-drawer"><h2>Navigation</h2>…</a11y-drawer>
|
|
1309
|
+
|
|
1310
|
+
<!-- Info bubble -->
|
|
1311
|
+
<a11y-floating position="bottom-left" label="What's new" dismissible hide-on-scroll>
|
|
1312
|
+
<p>Dark mode is here.</p>
|
|
1313
|
+
</a11y-floating>
|
|
1314
|
+
|
|
1315
|
+
<!-- Help panel -->
|
|
1316
|
+
<a11y-floating expandable label="Help">
|
|
1317
|
+
<h2>Need help?</h2>
|
|
1318
|
+
<a href="/faq">Read the FAQ</a>
|
|
1319
|
+
</a11y-floating>
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
| Name | Kind | Default | Description |
|
|
1323
|
+
| --- | --- | --- | --- |
|
|
1324
|
+
| `position` | attribute / property | `bottom-right` | `top`, `bottom`, `top-left`, `top-right`, `bottom-left` or `bottom-right`. |
|
|
1325
|
+
| `controls` | attribute | — | Id of the overlay its trigger toggles. |
|
|
1326
|
+
| `controlsElement` | property | — | The same, as an element. |
|
|
1327
|
+
| `expandable` | attribute | absent | Expandable mode. Ignored with `controls`. |
|
|
1328
|
+
| `expanded` | attribute / property | absent | Whether the panel is expanded. `expand()`, `collapse()` and `toggle()` set it. |
|
|
1329
|
+
| `label` | attribute | — | Text of the generated launcher. Outside expandable mode, makes the element a `role="region"` landmark with this name. |
|
|
1330
|
+
| `panel-label` | attribute | first heading | Accessible name of the panel. |
|
|
1331
|
+
| `close-label` | attribute | `Close dialog` | Accessible name of the panel's × button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1332
|
+
| `trap-focus` | attribute | absent | Traps focus in the expanded panel. |
|
|
1333
|
+
| `dismissible` | attribute | absent | Adds a × button that calls `dismiss()`. |
|
|
1334
|
+
| `dismiss-label` | attribute | `Dismiss` | Accessible name of that button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1335
|
+
| `announce` | attribute | absent | Makes the element a polite `role="status"` live region, so content shown with `show()` is announced. |
|
|
1336
|
+
| `hide-on-scroll` | attribute | absent | Slides it out of view while the page scrolls down and back on scroll up. It stays in the Tab order and comes back when focused. |
|
|
1337
|
+
| `scroll-threshold` | attribute | `16` | Pixels of scrolling before `hide-on-scroll` reacts. |
|
|
1338
|
+
| `dismiss()` | method | — | Fires a cancelable `a11y-floating-dismiss` event, then animates out and sets `hidden`. Focus goes back to where it was before it entered. |
|
|
1339
|
+
| `show()` | method | — | Shows it again (`hidden = false`). |
|
|
1340
|
+
| `onClose` | callback | — | Called when the panel collapses or the element is dismissed. |
|
|
1341
|
+
|
|
1342
|
+
Events on the element: `a11y-floating-expand`, `a11y-floating-collapse`, `a11y-floating-dismiss` (cancelable). The panel also fires `a11y-overlay-open` / `a11y-overlay-close` on `document`, and `dismissAllOverlays()` collapses it but leaves the element showing. Like every overlay it moves itself out of where it was authored (into `.a11y-floating-stack[data-position]` on `<body>`); see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`. Being last in `<body>`, it comes last in the Tab order.
|
|
1343
|
+
|
|
1344
|
+
Classes: `.a11y-floating-launcher`, `.a11y-floating-panel`, `.a11y-floating-panel-close`, `.a11y-floating-dismiss`. The element itself has no background, so style your bubble's content directly.
|
|
1345
|
+
|
|
1346
|
+
<details>
|
|
1347
|
+
<summary>CSS variables</summary>
|
|
1348
|
+
|
|
1349
|
+
Offsets add the device's safe-area inset (`env(safe-area-inset-*)`). The stacking order comes from `--a11y-z-floating-button` (see [Shared tokens](#shared-tokens)).
|
|
1350
|
+
|
|
1351
|
+
| Variable | Default |
|
|
1352
|
+
| --- | --- |
|
|
1353
|
+
| `--a11y-floating-close-font-size` | `1.25rem` |
|
|
1354
|
+
| `--a11y-floating-content-gap` | `0.5rem` |
|
|
1355
|
+
| `--a11y-floating-gap` | `0.75rem` |
|
|
1356
|
+
| `--a11y-floating-launcher-border-radius` | `999px` |
|
|
1357
|
+
| `--a11y-floating-launcher-color-background` | `#111827` |
|
|
1358
|
+
| `--a11y-floating-launcher-color-text` | `#ffffff` |
|
|
1359
|
+
| `--a11y-floating-launcher-padding` | `0 1rem` |
|
|
1360
|
+
| `--a11y-floating-launcher-size` | `3rem` |
|
|
1361
|
+
| `--a11y-floating-max-width` | `calc(100vw - 2rem)` |
|
|
1362
|
+
| `--a11y-floating-offset` | `1rem` |
|
|
1363
|
+
| `--a11y-floating-offset-x` / `--a11y-floating-offset-y` | `--a11y-floating-offset` |
|
|
1364
|
+
| `--a11y-floating-panel-border-radius` | `0.5rem` |
|
|
1365
|
+
| `--a11y-floating-panel-color-background` | `#ffffff` |
|
|
1366
|
+
| `--a11y-floating-panel-color-text` | `#111827` |
|
|
1367
|
+
| `--a11y-floating-panel-initial-scale` | `0.97` |
|
|
1368
|
+
| `--a11y-floating-panel-max-height` | `min(480px, 70vh)` |
|
|
1369
|
+
| `--a11y-floating-panel-offset` | `0.5rem` |
|
|
1370
|
+
| `--a11y-floating-panel-padding` | `1rem` |
|
|
1371
|
+
| `--a11y-floating-panel-shadow-blur` | `10px` |
|
|
1372
|
+
| `--a11y-floating-panel-shadow-fade` | `80%` |
|
|
1373
|
+
| `--a11y-floating-panel-shadow-offset-y` | `2px` |
|
|
1374
|
+
| `--a11y-floating-panel-width` | `min(320px, calc(100vw - 2rem))` |
|
|
1375
|
+
| `--a11y-floating-transition-duration` | `0.2s` |
|
|
1376
|
+
|
|
1377
|
+
</details>
|
|
1378
|
+
|
|
1174
1379
|
#### `a11y-modal`
|
|
1175
1380
|
|
|
1176
1381
|
A centered dialog. Your content is its children. See [Dialogs](#dialogs).
|
|
@@ -1198,9 +1403,43 @@ document.getElementById('open-settings').addEventListener('click', () => {
|
|
|
1198
1403
|
| --- | --- | --- | --- |
|
|
1199
1404
|
| `fullscreen` | attribute | absent | Fills the viewport, without the backdrop gutter. Read when the modal opens. |
|
|
1200
1405
|
|
|
1201
|
-
|
|
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()`
|
|
1202
1413
|
|
|
1203
|
-
|
|
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. |
|
|
1431
|
+
|
|
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
|
+
```
|
|
1204
1443
|
|
|
1205
1444
|
<details>
|
|
1206
1445
|
<summary>CSS variables</summary>
|
|
@@ -1218,12 +1457,16 @@ Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-lab
|
|
|
1218
1457
|
| `--a11y-modal-footer-button-padding` | `0.5rem 1rem` |
|
|
1219
1458
|
| `--a11y-modal-footer-gap` | `1rem` |
|
|
1220
1459
|
| `--a11y-modal-footer-margin-top` | `1.5rem` |
|
|
1460
|
+
| `--a11y-modal-height` | `auto` |
|
|
1221
1461
|
| `--a11y-modal-initial-scale` | `0.95` |
|
|
1462
|
+
| `--a11y-modal-max-height` | `100%` |
|
|
1463
|
+
| `--a11y-modal-max-width` | `100%` |
|
|
1222
1464
|
| `--a11y-modal-overlay-padding` | `clamp(1rem, 10vmin, 6rem)` |
|
|
1223
1465
|
| `--a11y-modal-shadow-blur` | `2px` |
|
|
1224
1466
|
| `--a11y-modal-shadow-fade` | `80%` |
|
|
1225
1467
|
| `--a11y-modal-shadow-offset-y` | `2px` |
|
|
1226
1468
|
| `--a11y-modal-transition-duration` | `0.3s` |
|
|
1469
|
+
| `--a11y-modal-width` | `min(32rem, 100%)` |
|
|
1227
1470
|
|
|
1228
1471
|
</details>
|
|
1229
1472
|
|
|
@@ -1262,13 +1505,13 @@ It's a page region, not an open/close overlay: it fires no open/close events and
|
|
|
1262
1505
|
|
|
1263
1506
|
| Option | Default | Description |
|
|
1264
1507
|
| --- | --- | --- |
|
|
1265
|
-
| `type` | `info` | `info`, `success` or `error` (`error` uses `role="alert"`). |
|
|
1508
|
+
| `type` | `info` | `info`, `success`, `warning` or `error` (`error` uses `role="alert"`). |
|
|
1266
1509
|
| `position` | `top` | `top` or `bottom`. |
|
|
1267
1510
|
| `actionText` / `onAction` | — | Adds an action button; clicking it runs `onAction` and dismisses the banner. |
|
|
1268
1511
|
| `onClose` | — | Called when the banner is dismissed. |
|
|
1269
1512
|
| `maxStack` | — | Sets `max-stack` on the region (sticky for later banners). |
|
|
1270
1513
|
|
|
1271
|
-
Classes: `.a11y-notification-banner--info` / `--success` / `--error`, `__message`, `__action`, `__close`.
|
|
1514
|
+
Classes: `.a11y-notification-banner--info` / `--success` / `--warning` / `--error`, `__message`, `__action`, `__close`.
|
|
1272
1515
|
|
|
1273
1516
|
<details>
|
|
1274
1517
|
<summary>CSS variables</summary>
|
|
@@ -1336,10 +1579,12 @@ Toast notifications that dismiss themselves: after 3 s by default, or 10 s when
|
|
|
1336
1579
|
|
|
1337
1580
|
```js
|
|
1338
1581
|
import { notify } from 'a11y-elements/overlays/snackbar';
|
|
1582
|
+
import { raw } from 'a11y-elements/core';
|
|
1339
1583
|
|
|
1340
1584
|
notify('Saved');
|
|
1341
1585
|
notify('Upload failed', { type: 'error', actionText: 'Retry', onAction: retryUpload });
|
|
1342
1586
|
notify('Copied to clipboard', { position: 'top', duration: 1500 });
|
|
1587
|
+
notify(raw('Saved. <a href="/files">View files</a>')); // markup: sanitized, see below
|
|
1343
1588
|
```
|
|
1344
1589
|
|
|
1345
1590
|
| Name | Kind | Default | Description |
|
|
@@ -1350,6 +1595,8 @@ notify('Copied to clipboard', { position: 'top', duration: 1500 });
|
|
|
1350
1595
|
|
|
1351
1596
|
It's a page region, not an open/close overlay: it fires no open/close events and `dismissAllOverlays()` leaves it alone. Like every overlay it moves itself to `<body>`; see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`.
|
|
1352
1597
|
|
|
1598
|
+
A `message` is text: a string is escaped. For markup, pass `raw(markup)` from `a11y-elements/core`. It's sanitized (no scripts, styles, event handlers or `javascript:` URLs), so it's safe with user data in it. `trustedRaw(markup)` skips that, for markup you wrote yourself. The same goes for `<a11y-notification-banner>`.
|
|
1599
|
+
|
|
1353
1600
|
`notify()` options (method and convenience export):
|
|
1354
1601
|
|
|
1355
1602
|
| Option | Default | Description |
|
|
@@ -1417,16 +1664,22 @@ Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` /
|
|
|
1417
1664
|
|
|
1418
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.
|
|
1419
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
|
+
|
|
1420
1669
|
<details>
|
|
1421
1670
|
<summary>CSS variables</summary>
|
|
1422
1671
|
|
|
1423
1672
|
| Variable | Default |
|
|
1424
1673
|
| --- | --- |
|
|
1425
|
-
| `--a11y-color-success` | `
|
|
1426
|
-
| `--a11y-color-error` | `
|
|
1427
|
-
| `--a11y-color-info` | `
|
|
1428
|
-
| `--a11y-color-warning` | `
|
|
1674
|
+
| `--a11y-color-success` | `#2e7d32` |
|
|
1675
|
+
| `--a11y-color-error` | `#c62828` |
|
|
1676
|
+
| `--a11y-color-info` | `#1565c0` |
|
|
1677
|
+
| `--a11y-color-warning` | `#f9a825` |
|
|
1429
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` |
|
|
1430
1683
|
| `--a11y-z-base` | `0` |
|
|
1431
1684
|
| `--a11y-z-sticky-header` | `100` |
|
|
1432
1685
|
| `--a11y-z-sticky-footer` | `110` |
|
|
@@ -1484,6 +1737,65 @@ Override at `:root` (or `body`) and every instance of that component on the page
|
|
|
1484
1737
|
}
|
|
1485
1738
|
```
|
|
1486
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
|
+
|
|
1487
1799
|
### Scope to one instance
|
|
1488
1800
|
|
|
1489
1801
|
The same custom properties follow ordinary CSS cascade/inheritance, so you can target just one element instead. Two equivalent ways to do it:
|
|
@@ -1504,10 +1816,19 @@ The same custom properties follow ordinary CSS cascade/inheritance, so you can t
|
|
|
1504
1816
|
|
|
1505
1817
|
Either way, only that element changes — every other `<a11y-spinner>` on the page keeps its default (or globally-rethemed) look.
|
|
1506
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
|
+
|
|
1507
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.
|
|
1508
1822
|
|
|
1509
1823
|
The full list of tokens, with their defaults, is in the shipped `dist/a11y.css` — search it for `--a11y-<component>-`.
|
|
1510
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
|
+
|
|
1511
1832
|
## License
|
|
1512
1833
|
|
|
1513
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
|
+
}
|