@reliability-design/web 1.4.6 → 1.4.8
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/CHANGELOG.md +246 -49
- package/dist/components/rel-accordion/README.md +133 -132
- package/dist/components/rel-alert/README.md +145 -141
- package/dist/components/rel-autocomplete/README.md +172 -61
- package/dist/components/rel-avatar/README.md +118 -130
- package/dist/components/rel-badge/README.md +97 -93
- package/dist/components/rel-breadcrumb/README.md +96 -102
- package/dist/components/rel-button/README.md +190 -130
- package/dist/components/rel-calendar/README.md +109 -109
- package/dist/components/rel-card/README.md +75 -94
- package/dist/components/rel-cardmedia/README.md +100 -127
- package/dist/components/rel-carousel/README.md +186 -166
- package/dist/components/rel-checkbox/README.md +96 -75
- package/dist/components/rel-chip/README.md +138 -121
- package/dist/components/rel-container/README.md +107 -99
- package/dist/components/rel-date-picker/README.md +200 -289
- package/dist/components/rel-divider/README.md +88 -100
- package/dist/components/rel-drawer/README.md +187 -200
- package/dist/components/rel-kbd/README.md +141 -151
- package/dist/components/rel-layout/README.md +34 -0
- package/dist/components/rel-menu/README.md +180 -151
- package/dist/components/rel-menubar/README.md +218 -329
- package/dist/components/rel-otp/README.md +171 -440
- package/dist/components/rel-pagination/README.md +100 -424
- package/dist/components/rel-popover/README.md +203 -568
- package/dist/components/rel-progress/README.md +88 -110
- package/dist/components/rel-radio/README.md +131 -138
- package/dist/components/rel-range-picker/README.md +165 -0
- package/dist/components/rel-resizable/README.md +199 -140
- package/dist/components/rel-segmented-button/README.md +156 -141
- package/dist/components/rel-select/README.md +156 -93
- package/dist/components/rel-sheet/README.md +168 -224
- package/dist/components/rel-skeleton/README.md +104 -0
- package/dist/components/rel-slider/README.md +131 -135
- package/dist/components/rel-snackbar/README.md +168 -134
- package/dist/components/rel-stepper/README.md +162 -160
- package/dist/components/rel-switch/README.md +117 -102
- package/dist/components/rel-tab/README.md +173 -163
- package/dist/components/rel-textfield/README.md +176 -69
- package/dist/components/rel-time-picker/README.md +122 -157
- package/dist/components/rel-toast/README.md +165 -148
- package/dist/components/rel-tooltip/README.md +119 -111
- package/dist/components/rel-upload/README.md +220 -0
- package/dist/index.d.mts +1726 -447
- package/dist/index.d.ts +1726 -447
- package/dist/index.js +13715 -10870
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14018 -11163
- package/dist/index.mjs.map +1 -1
- package/dist/styles/focus-ring.ts +84 -0
- package/dist/styles/vars.css +892 -866
- package/dist/{vars-XNMTSRVN.css → vars-DXX6QOAG.css} +892 -866
- package/package.json +3 -2
- package/dist/components/rel-accordion/rel-accordion.ts +0 -336
- package/dist/components/rel-alert/rel-alert.ts +0 -305
- package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -720
- package/dist/components/rel-avatar/rel-avatar.ts +0 -142
- package/dist/components/rel-badge/rel-badge.ts +0 -175
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
- package/dist/components/rel-button/rel-button.ts +0 -560
- package/dist/components/rel-calendar/index.ts +0 -1
- package/dist/components/rel-calendar/rel-calendar.ts +0 -565
- package/dist/components/rel-card/rel-card.ts +0 -88
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
- package/dist/components/rel-carousel/index.ts +0 -1
- package/dist/components/rel-carousel/rel-carousel.ts +0 -723
- package/dist/components/rel-chart/README.md +0 -286
- package/dist/components/rel-chart/index.ts +0 -1
- package/dist/components/rel-chart/rel-chart.ts +0 -754
- package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
- package/dist/components/rel-chip/rel-chip.ts +0 -483
- package/dist/components/rel-container/rel-container.ts +0 -95
- package/dist/components/rel-date-picker/date-format.test.ts +0 -43
- package/dist/components/rel-date-picker/date-format.ts +0 -47
- package/dist/components/rel-date-picker/date-parse.test.ts +0 -116
- package/dist/components/rel-date-picker/date-parse.ts +0 -178
- package/dist/components/rel-date-picker/index.ts +0 -1
- package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1676
- package/dist/components/rel-divider/rel-divider.ts +0 -54
- package/dist/components/rel-drawer/index.ts +0 -1
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
- package/dist/components/rel-drawer/rel-drawer.ts +0 -607
- package/dist/components/rel-kbd/rel-kbd.ts +0 -188
- package/dist/components/rel-layout/rel-layout.ts +0 -49
- package/dist/components/rel-menu/rel-menu.ts +0 -541
- package/dist/components/rel-menubar/index.ts +0 -2
- package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
- package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
- package/dist/components/rel-menubar/rel-menubar.ts +0 -777
- package/dist/components/rel-nav-menu/README.md +0 -289
- package/dist/components/rel-nav-menu/index.ts +0 -3
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
- package/dist/components/rel-navbar/README.md +0 -126
- package/dist/components/rel-navbar/rel-navbar.ts +0 -105
- package/dist/components/rel-otp/index.ts +0 -1
- package/dist/components/rel-otp/rel-otp.ts +0 -527
- package/dist/components/rel-pagination/index.ts +0 -1
- package/dist/components/rel-pagination/rel-pagination.ts +0 -522
- package/dist/components/rel-popover/index.ts +0 -2
- package/dist/components/rel-popover/rel-popover-content.ts +0 -81
- package/dist/components/rel-popover/rel-popover.ts +0 -475
- package/dist/components/rel-progress/rel-progress.ts +0 -234
- package/dist/components/rel-radio/rel-radio.ts +0 -481
- package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1688
- package/dist/components/rel-resizable/index.ts +0 -3
- package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
- package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
- package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -217
- package/dist/components/rel-select/rel-select.ts +0 -1416
- package/dist/components/rel-sheet/rel-sheet.ts +0 -610
- package/dist/components/rel-sidebar/README.md +0 -209
- package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1191
- package/dist/components/rel-skeleton/rel-skeleton.ts +0 -143
- package/dist/components/rel-slider/rel-slider.ts +0 -673
- package/dist/components/rel-snackbar/rel-snackbar.ts +0 -329
- package/dist/components/rel-stepper/rel-stepper.ts +0 -567
- package/dist/components/rel-switch/rel-switch.ts +0 -199
- package/dist/components/rel-tab/rel-tab.ts +0 -264
- package/dist/components/rel-table/README.md +0 -178
- package/dist/components/rel-table/rel-table-body.ts +0 -22
- package/dist/components/rel-table/rel-table-caption.ts +0 -30
- package/dist/components/rel-table/rel-table-cell.ts +0 -43
- package/dist/components/rel-table/rel-table-footer.ts +0 -24
- package/dist/components/rel-table/rel-table-head.ts +0 -47
- package/dist/components/rel-table/rel-table-header.ts +0 -22
- package/dist/components/rel-table/rel-table-row.ts +0 -37
- package/dist/components/rel-table/rel-table.ts +0 -62
- package/dist/components/rel-textfield/rel-textfield.ts +0 -1054
- package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1482
- package/dist/components/rel-time-picker/time-parse.test.ts +0 -67
- package/dist/components/rel-time-picker/time-parse.ts +0 -85
- package/dist/components/rel-toast/rel-toast.ts +0 -206
- package/dist/components/rel-tooltip/rel-tooltip.ts +0 -193
- package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
- package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar.ts +0 -446
- package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
- package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
- package/dist/components/rel-upload/rel-upload.ts +0 -968
|
@@ -1,93 +1,97 @@
|
|
|
1
|
-
# rel-badge
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!-- Number badges -->
|
|
9
|
-
<rel-badge number="5"></rel-badge>
|
|
10
|
-
<rel-badge number="12" size="md"></rel-badge>
|
|
11
|
-
<rel-badge number="99+" size="lg"></rel-badge>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<rel-badge variant="dot"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<rel-badge
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<rel-badge
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
###
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
- The
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
1
|
+
# rel-badge
|
|
2
|
+
|
|
3
|
+
`<rel-badge>` is the Figma "Badge" count indicator: a small `number` pill ("5", "99+") or an unlabeled `dot`, in four sizes (S/M/L/XL), filled with the danger token by default and overridable per instance through `color` / `text-color`. Use it to flag unread counts or unseen activity on an icon, tab, avatar or navigation item — you position it over the target yourself. It is not a text tag (use `rel-chip`) and not a status message (use `rel-alert` or `rel-toast`); it only carries a count or a "something is new" signal.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Number badges -->
|
|
9
|
+
<rel-badge number="5"></rel-badge>
|
|
10
|
+
<rel-badge number="12" size="md"></rel-badge>
|
|
11
|
+
<rel-badge number="99+" size="lg"></rel-badge>
|
|
12
|
+
<rel-badge number="120" size="xl"></rel-badge>
|
|
13
|
+
|
|
14
|
+
<!-- Dot badges (no text) -->
|
|
15
|
+
<rel-badge variant="dot"></rel-badge>
|
|
16
|
+
|
|
17
|
+
<!-- Positioned over an icon button -->
|
|
18
|
+
<div style="position: relative; display: inline-block;">
|
|
19
|
+
<button aria-label="Notifications">🔔</button>
|
|
20
|
+
<rel-badge number="3" size="sm" style="position: absolute; top: -8px; right: -8px;"></rel-badge>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<!-- Accessible-name control -->
|
|
24
|
+
<rel-badge number="3" suffix="unread messages"></rel-badge>
|
|
25
|
+
<rel-badge variant="dot" arialabel="New activity"></rel-badge>
|
|
26
|
+
|
|
27
|
+
<!-- Colour overrides: any CSS colour, including a token via var() -->
|
|
28
|
+
<rel-badge number="3" color="#7d7d7d"></rel-badge>
|
|
29
|
+
<rel-badge number="3" color="teal" text-color="#1a1a1a"></rel-badge>
|
|
30
|
+
<rel-badge variant="dot" color="seagreen"></rel-badge>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<!-- readme-gen:start -->
|
|
34
|
+
|
|
35
|
+
<!-- Generated from rel-badge.ts — do not edit; run readme-generate.mjs -->
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### Attributes / Properties
|
|
40
|
+
|
|
41
|
+
| Property | Attribute | Type | Default | Description |
|
|
42
|
+
| --- | --- | --- | --- | --- |
|
|
43
|
+
| `number` | `number` | `string` | `""` | Text shown in the `number` variant (a count such as "5" or "99+"); not rendered by `variant="dot"` but still used to build the accessible name. |
|
|
44
|
+
| `ariaLabel` | `arialabel` | `string` | `""` | Explicit accessible name; when empty it is composed as "<number> <suffix>" or, with no number, "New <suffix>". Attribute is `arialabel`. |
|
|
45
|
+
| `suffix` | `suffix` | `string` | `"notifications"` | Noun appended to the count in the generated accessible name, e.g. "3 notifications". |
|
|
46
|
+
| `size` | `size` | `"small" \| "medium" \| "large" \| "extra-large" \| "sm" \| "md" \| "lg" \| "xl"` | `"medium"` | Badge scale (Figma Badge S/M/L/XL): number badges are 20 / 24 / 28 / 40px tall. `sm` / `md` / `lg` / `xl` are accepted and normalised to the full words. Ignored when `variant="dot"` — Figma models `Dot` as a fifth option of the same Size axis, so a dot has one size. Reflected. |
|
|
47
|
+
| `variant` | `variant` | `"dot" \| "number"` | `"number"` | `number` renders the `number` text in a pill that widens with its content; `dot` renders a 6px disc with no text (Figma `Size=Dot`), ignoring `size`. Reflected. |
|
|
48
|
+
| `color` | `color` | `string` | `""` | Direct CSS color override for the badge background. Accepts any valid CSS color value: hex, rgb(...), hsl(...), named color, or var(--token). Clear it (set to `''`) to fall back to the default token. Reflected. |
|
|
49
|
+
| `textColor` | `text-color` | `string` | `""` | Direct CSS color override for the badge text/icon color. Accepts any valid CSS color value: hex, rgb(...), hsl(...), named color, or var(--token). Clear it (set to `''`) to fall back to the default (white). Reflected. |
|
|
50
|
+
|
|
51
|
+
## Events
|
|
52
|
+
|
|
53
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| — | — | — | This element emits no custom events. |
|
|
56
|
+
|
|
57
|
+
## Slots
|
|
58
|
+
|
|
59
|
+
| Slot | Description |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| — | This element has no slots. |
|
|
62
|
+
|
|
63
|
+
## CSS Parts
|
|
64
|
+
|
|
65
|
+
| Part | Description |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `base` | The `role="status"` pill / dot that carries the size, variant and colour overrides |
|
|
68
|
+
|
|
69
|
+
## Tokens / CSS Variables
|
|
70
|
+
|
|
71
|
+
### Component hooks
|
|
72
|
+
|
|
73
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
74
|
+
|
|
75
|
+
| Custom property | Default | Description |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `--rel-badge-bg` | `var(--rel-bg-danger)` | Background colour of the badge; the `color` prop writes this on the host |
|
|
78
|
+
| `--rel-badge-color` | `var(--rel-text-static-light)` | Text colour of the count; the `text-color` prop writes this on the host |
|
|
79
|
+
| `--rel-badge-dot-size` | `6px` | Diameter of the `dot` variant; default 6px, the single dot size Figma draws. Set it to restore the larger discs shipped previously. |
|
|
80
|
+
|
|
81
|
+
<!-- readme-gen:end -->
|
|
82
|
+
|
|
83
|
+
## Accessibility
|
|
84
|
+
|
|
85
|
+
- The pill (`base` part) renders with `role="status"` and an `aria-label`. The label is `ariaLabel` when set; otherwise it is composed as `"<number> <suffix>"` (e.g. "3 notifications") or, when `number` is empty (dot badges), `"New <suffix>"` (e.g. "New notifications"). Set `suffix` so the announcement names the right thing, or `arialabel` for full control.
|
|
86
|
+
- `role="status"` is an implicit polite live region, so a change to `number` may be announced without the badge ever taking focus; verify the behaviour with your target screen reader before relying on it.
|
|
87
|
+
- The host is not focusable and handles no keys. Interactive meaning ("open notifications") belongs to the element the badge decorates — give that element its own accessible name.
|
|
88
|
+
- A dot badge has no visible text; the generated name is the only thing a screen reader gets, and sighted users get colour alone. Pair it with nearby text when the meaning is not obvious from context.
|
|
89
|
+
|
|
90
|
+
## Notes / Edge Cases
|
|
91
|
+
|
|
92
|
+
- Number badge heights are 20 / 24 / 28 / 40px for `sm` / `md` / `lg` / `xl`; dot badges are 8 / 10 / 12 / 12px (`lg` and `xl` dots are the same size). The number badge sets `min-width`, not `width`, so a two-digit count stays a circle while "999+" grows into a pill.
|
|
93
|
+
- The corner radius is a fixed `999px`, not `50%`, which is what lets wide content become a pill instead of clipping.
|
|
94
|
+
- In `variant="dot"` the `number` text is not rendered but still feeds the accessible name ("3 notifications" for a dot with `number="3"`).
|
|
95
|
+
- `color` and `text-color` are applied by writing `--rel-badge-bg` / `--rel-badge-color` as inline custom properties on the host; clearing the prop removes the inline value and falls back to whatever the hook resolves to (the danger / static-light tokens unless you set the hook in your own CSS).
|
|
96
|
+
- The accessible-name property is `ariaLabel` with the attribute `arialabel` (no hyphen). A plain `aria-label` attribute on the host is not read by the component, and because the host has no role it does not reach the `role="status"` element either — use `arialabel`.
|
|
97
|
+
- The host is `display: inline-flex`; the usual pattern is an absolutely positioned badge inside a `position: relative` wrapper around the decorated element.
|
|
@@ -1,102 +1,96 @@
|
|
|
1
|
-
#rel-breadcrumbs
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!-- Basic
|
|
9
|
-
<rel-breadcrumbs id="
|
|
10
|
-
<script>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{ label: '
|
|
14
|
-
{ label: '
|
|
15
|
-
{ label: '
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{ label: '
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
- Chevron
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
- Chevrons are 16px × 16px with 10px horizontal margins
|
|
98
|
-
- Chevron color inherits `currentColor` from parent
|
|
99
|
-
- Links have `text-decoration: none` by default, `underline` on hover
|
|
100
|
-
- The current page label is bold and not clickable (`cursor: default`)
|
|
101
|
-
- The component is `display: block` and takes full width
|
|
102
|
-
- The ordered list uses `flex-wrap: wrap` to handle overflow gracefully
|
|
1
|
+
# rel-breadcrumbs
|
|
2
|
+
|
|
3
|
+
Breadcrumb trail (element `<rel-breadcrumbs>`, folder `rel-breadcrumb`): a `<nav aria-label="Breadcrumb">` ordered list built from an `items` array, with chevron separators and the last entry rendered as the non-link current page. Use it to show where the current page sits in a hierarchy and to jump back up it; do not use it as primary navigation or for a single-level site.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Basic trail: every item but the last is a link -->
|
|
9
|
+
<rel-breadcrumbs id="trail"></rel-breadcrumbs>
|
|
10
|
+
<script>
|
|
11
|
+
document.getElementById('trail').items = [
|
|
12
|
+
{ label: 'Home', url: '/' },
|
|
13
|
+
{ label: 'Products', url: '/products' },
|
|
14
|
+
{ label: 'Electronics', url: '/products/electronics' },
|
|
15
|
+
{ label: 'Laptops' } // current page — no url needed
|
|
16
|
+
];
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<!-- Two levels -->
|
|
20
|
+
<rel-breadcrumbs id="short"></rel-breadcrumbs>
|
|
21
|
+
<script>
|
|
22
|
+
document.getElementById('short').items = [
|
|
23
|
+
{ label: 'Dashboard', url: '/dashboard' },
|
|
24
|
+
{ label: 'Settings' }
|
|
25
|
+
];
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<!-- Restyle the current-page text through its part -->
|
|
29
|
+
<style>
|
|
30
|
+
.muted::part(label) {
|
|
31
|
+
color: gray;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
34
|
+
<rel-breadcrumbs class="muted" id="muted"></rel-breadcrumbs>
|
|
35
|
+
<script>
|
|
36
|
+
document.getElementById('muted').items = [
|
|
37
|
+
{ label: 'Docs', url: '/docs' },
|
|
38
|
+
{ label: 'Components', url: '/docs/components' },
|
|
39
|
+
{ label: 'Breadcrumbs' }
|
|
40
|
+
];
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The `BreadcrumbItem` shape is `{ label: string; url?: string }`; the type is exported from the package.
|
|
45
|
+
|
|
46
|
+
<!-- readme-gen:start -->
|
|
47
|
+
|
|
48
|
+
<!-- Generated from rel-breadcrumb.ts — do not edit; run readme-generate.mjs -->
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### Attributes / Properties
|
|
53
|
+
|
|
54
|
+
| Property | Attribute | Type | Default | Description |
|
|
55
|
+
| --- | --- | --- | --- | --- |
|
|
56
|
+
| `items` | `items` | `BreadcrumbItem[]` | `[]` | Ordered trail, root first: `{ label: string; url?: string }[]`. Items with a `url` render as links except the last one, which is always the current page (and never a link). Set as a property — arrays do not survive attribute serialisation. |
|
|
57
|
+
|
|
58
|
+
## Events
|
|
59
|
+
|
|
60
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
61
|
+
| --- | --- | --- | --- |
|
|
62
|
+
| — | — | — | This element emits no custom events. |
|
|
63
|
+
|
|
64
|
+
## Slots
|
|
65
|
+
|
|
66
|
+
| Slot | Description |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| — | This element has no slots. |
|
|
69
|
+
|
|
70
|
+
## CSS Parts
|
|
71
|
+
|
|
72
|
+
| Part | Description |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `base` | The `<nav>` landmark wrapping the ordered list. |
|
|
75
|
+
| `label` | The non-link current-page text (`aria-current="page"`), also used for any item without a `url`. |
|
|
76
|
+
|
|
77
|
+
<!-- readme-gen:end -->
|
|
78
|
+
|
|
79
|
+
## Accessibility
|
|
80
|
+
|
|
81
|
+
- Semantic `<nav aria-label="Breadcrumb">` landmark (the `base` part) containing an `<ol>`, so the trail is announced as an ordered list within a named navigation region.
|
|
82
|
+
- The last item is a `<span aria-current="page">` (the `label` part), never a link, so the current page is identified without being actionable.
|
|
83
|
+
- Chevron separators are inline SVGs with `aria-hidden="true"`.
|
|
84
|
+
- Links show a 2px focus outline with 2px offset on `:focus-visible`.
|
|
85
|
+
|
|
86
|
+
| Key | Action |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `Tab` / `Shift+Tab` | Move between the breadcrumb links |
|
|
89
|
+
| `Enter` | Follow the focused link (native anchor behaviour) |
|
|
90
|
+
|
|
91
|
+
## Notes / Edge Cases
|
|
92
|
+
|
|
93
|
+
- **The last item is always the current page**, even if it has a `url` — it renders as text, not a link. Any earlier item *without* a `url` also renders as text (and reuses the `label` part and `aria-current="page"`, so give every ancestor a `url`).
|
|
94
|
+
- `items` must be assigned as a property (it is an array); setting an `items` attribute in HTML does not work.
|
|
95
|
+
- Separators are 16px chevrons with 10px horizontal margins inheriting `currentColor`; the list wraps onto new lines when it runs out of width.
|
|
96
|
+
- Links are plain anchors: navigation happens natively and no custom event is emitted. Intercept `click` on the host if you route client-side.
|