@reliability-design/web 1.4.6 → 1.4.7
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 +211 -49
- package/dist/components/rel-accordion/README.md +132 -132
- package/dist/components/rel-alert/README.md +145 -141
- package/dist/components/rel-autocomplete/README.md +156 -61
- package/dist/components/rel-avatar/README.md +116 -130
- package/dist/components/rel-badge/README.md +98 -93
- package/dist/components/rel-breadcrumb/README.md +96 -102
- package/dist/components/rel-button/README.md +160 -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 +184 -166
- package/dist/components/rel-checkbox/README.md +93 -75
- package/dist/components/rel-chip/README.md +132 -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 +78 -100
- package/dist/components/rel-drawer/README.md +187 -200
- package/dist/components/rel-kbd/README.md +141 -151
- package/dist/components/rel-menu/README.md +178 -151
- package/dist/components/rel-menubar/README.md +218 -329
- package/dist/components/rel-otp/README.md +170 -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 +162 -0
- package/dist/components/rel-resizable/README.md +199 -140
- package/dist/components/rel-segmented-button/README.md +155 -141
- package/dist/components/rel-select/README.md +154 -93
- package/dist/components/rel-sheet/README.md +168 -224
- package/dist/components/rel-skeleton/README.md +103 -0
- package/dist/components/rel-slider/README.md +130 -135
- package/dist/components/rel-snackbar/README.md +162 -134
- package/dist/components/rel-stepper/README.md +158 -160
- package/dist/components/rel-switch/README.md +108 -102
- package/dist/components/rel-tab/README.md +171 -163
- package/dist/components/rel-textfield/README.md +159 -69
- package/dist/components/rel-time-picker/README.md +122 -157
- package/dist/components/rel-toast/README.md +157 -148
- package/dist/components/rel-tooltip/README.md +108 -111
- package/dist/components/rel-upload/README.md +220 -0
- package/dist/index.d.mts +1147 -340
- package/dist/index.d.ts +1147 -340
- package/dist/index.js +3451 -3163
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3416 -3118
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +877 -866
- package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -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,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.
|
|
@@ -1,130 +1,160 @@
|
|
|
1
|
-
# rel-button
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!--
|
|
9
|
-
<rel-button variant="
|
|
10
|
-
<rel-button variant="
|
|
11
|
-
<rel-button variant="
|
|
12
|
-
<rel-button variant="
|
|
13
|
-
<rel-button variant="
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<!-- Tones (
|
|
19
|
-
<rel-button variant="primary" tone="
|
|
20
|
-
<rel-button variant="primary" tone="
|
|
21
|
-
<rel-button variant="primary" tone="
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<rel-button size="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<rel-button border="
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<rel-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<rel-button
|
|
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
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-
|
|
117
|
-
|
|
118
|
-
##
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
1
|
+
# rel-button
|
|
2
|
+
|
|
3
|
+
Action button implementing the Figma "Button" component: a native `<button>` with the Figma **Style** (`variant`), **Tone** (`tone`) and **Size** axes, an independent **Icon Only** mode, a **Loading** state and an optional corner badge. Use it for every clickable action (submit, confirm, open, delete). Do not use it for navigation to another page — use a link instead.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Styles (Figma "Style") -->
|
|
9
|
+
<rel-button variant="primary">Primary</rel-button>
|
|
10
|
+
<rel-button variant="secondary">Secondary</rel-button>
|
|
11
|
+
<rel-button variant="ghost">Ghost</rel-button>
|
|
12
|
+
<rel-button variant="link">Link style</rel-button>
|
|
13
|
+
<rel-button variant="default">Neutral fill</rel-button>
|
|
14
|
+
<div style="background: #1f2937; padding: 8px;">
|
|
15
|
+
<rel-button variant="static">Static (on dark surfaces)</rel-button>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<!-- Tones (Figma "Tone") -->
|
|
19
|
+
<rel-button variant="primary" tone="brand">Save</rel-button>
|
|
20
|
+
<rel-button variant="primary" tone="neutral">Cancel</rel-button>
|
|
21
|
+
<rel-button variant="primary" tone="destructive">Delete</rel-button>
|
|
22
|
+
<rel-button variant="secondary" tone="destructive">Remove</rel-button>
|
|
23
|
+
<rel-button variant="ghost" tone="destructive">Discard</rel-button>
|
|
24
|
+
|
|
25
|
+
<!-- Sizes: 32 / 40 / 48px -->
|
|
26
|
+
<rel-button size="small">Small</rel-button>
|
|
27
|
+
<rel-button size="medium">Medium</rel-button>
|
|
28
|
+
<rel-button size="large">Large</rel-button>
|
|
29
|
+
|
|
30
|
+
<!-- Corner radius -->
|
|
31
|
+
<rel-button border="corner-radius">Pill</rel-button>
|
|
32
|
+
<rel-button border="small-corner-radius">Small radius</rel-button>
|
|
33
|
+
<rel-button border="no-corner-radius">Square</rel-button>
|
|
34
|
+
|
|
35
|
+
<!-- Icon + label, and icon-only (needs an accessible name) -->
|
|
36
|
+
<rel-button variant="primary">
|
|
37
|
+
<rel-icon name="plus"></rel-icon>
|
|
38
|
+
Add item
|
|
39
|
+
</rel-button>
|
|
40
|
+
<rel-button variant="secondary" icon-only aria-label="Settings">
|
|
41
|
+
<rel-icon name="settings"></rel-icon>
|
|
42
|
+
</rel-button>
|
|
43
|
+
<rel-button variant="ghost" icon-only size="small" aria-label="Close">
|
|
44
|
+
<rel-icon name="x"></rel-icon>
|
|
45
|
+
</rel-button>
|
|
46
|
+
|
|
47
|
+
<!-- States -->
|
|
48
|
+
<rel-button variant="primary" loading>Saving</rel-button>
|
|
49
|
+
<rel-button variant="primary" disabled>Unavailable</rel-button>
|
|
50
|
+
|
|
51
|
+
<!-- Corner badges -->
|
|
52
|
+
<rel-button variant="secondary" badge="3">Inbox</rel-button>
|
|
53
|
+
<rel-button variant="ghost" icon-only badge-dot aria-label="Notifications">
|
|
54
|
+
<rel-icon name="bell"></rel-icon>
|
|
55
|
+
</rel-button>
|
|
56
|
+
|
|
57
|
+
<!-- Listen for clicks (native click bubbles through the shadow root) -->
|
|
58
|
+
<rel-button id="save" variant="primary">Save</rel-button>
|
|
59
|
+
<script>
|
|
60
|
+
document.getElementById('save').addEventListener('click', () => {
|
|
61
|
+
console.log('saved');
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<!-- Per-instance minimum width -->
|
|
66
|
+
<rel-button variant="primary" style="--rel-button-min-width: 160px;">Wide</rel-button>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Deprecated aliases
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<!-- Legacy Style spellings — still rendered identically, prefer the canonical names -->
|
|
73
|
+
<rel-button variant="outline">Outline</rel-button> <!-- → variant="secondary" -->
|
|
74
|
+
<rel-button variant="text">Text</rel-button> <!-- → variant="ghost" -->
|
|
75
|
+
<rel-button variant="icon" aria-label="Settings"> <!-- → icon-only + a variant -->
|
|
76
|
+
<rel-icon name="settings"></rel-icon>
|
|
77
|
+
</rel-button>
|
|
78
|
+
|
|
79
|
+
<!-- Legacy Tone spellings — each logs once per page:
|
|
80
|
+
[rel-button] "tone="critical"" is deprecated and will be removed in 3.0 — use "tone="destructive"" instead. -->
|
|
81
|
+
<rel-button variant="primary" tone="critical">Delete</rel-button> <!-- → tone="destructive" -->
|
|
82
|
+
<rel-button variant="primary" tone="danger">Delete</rel-button> <!-- → tone="destructive" -->
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
<!-- readme-gen:start -->
|
|
86
|
+
|
|
87
|
+
<!-- Generated from rel-button.ts — do not edit; run readme-generate.mjs -->
|
|
88
|
+
|
|
89
|
+
## API
|
|
90
|
+
|
|
91
|
+
### Attributes / Properties
|
|
92
|
+
|
|
93
|
+
| Property | Attribute | Type | Default | Description |
|
|
94
|
+
| --- | --- | --- | --- | --- |
|
|
95
|
+
| `variant` | `variant` | `"default" \| "primary" \| "secondary" \| "text" \| "link" \| "icon" \| "static" \| "outline" \| "ghost"` | `"default"` | Style axis (Figma "Style"). Canonical: `default` (legacy neutral fill), `primary`, `secondary` (outlined), `ghost` (text-only), `link` (underlined inline text), `static` (transparent, static-light label for dark/colored surfaces). Deprecated aliases still accepted: `outline` = secondary, `text` = ghost, and `icon` (pre-2.0 40px circular icon button — use `icon-only` with a style instead). |
|
|
96
|
+
| `tone` | `tone` | `"default" \| "primary" \| "secondary" \| "critical" \| "success" \| "neutral" \| "brand" \| "danger" \| "destructive"` | `"default"` | Tone axis (Figma "Tone"). Canonical: `neutral` (= `default`), `brand` (= `primary`), `destructive`. Deprecated aliases `critical` and `danger` map to destructive and log a one-time console notice. `secondary` and `success` are legacy extras with no Figma counterpart (secondary only affects the legacy `icon` variant). |
|
|
97
|
+
| `iconOnly` | `icon-only` | `boolean` | `false` | Figma "Type=Icon Only": renders a square button (32/40/48px per `size`) of the current style and tone with no padding or min-width. Composes with every `variant`; slot a single `rel-icon` and set `aria-label`. Reflected. |
|
|
98
|
+
| `loading` | `loading` | `boolean` | `false` | Figma "State=Loading": replaces the label with a spinner (`indicator` part), sets `aria-busy`, and blocks pointer and programmatic clicks. The button keeps its width. Reflected. |
|
|
99
|
+
| `size` | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Figma "Size": `small` = 32px, `medium` = 40px, `large` = 48px height, with matching padding, typography and minimum width. |
|
|
100
|
+
| `border` | `border` | `"corner-radius" \| "small-corner-radius" \| "no-corner-radius"` | `"corner-radius"` | Corner treatment: `corner-radius` = fully rounded pill, `small-corner-radius` = small radius token, `no-corner-radius` = square corners. |
|
|
101
|
+
| `disabled` | `disabled` | `boolean` | `false` | Figma "State=Disabled": dims the button to 50% opacity, flattens filled styles to the disabled fill, shows a `not-allowed` cursor and swallows every click (including programmatic `.click()`). Reflected. |
|
|
102
|
+
| `ariaLabel` | `aria-label` | `string \| null` | `null` | Accessible name forwarded to the inner native `<button>`. Required for `icon-only` buttons, whose slotted icon has no visible text. |
|
|
103
|
+
| `badge` | `badge` | `string` | `""` | Text for a small `rel-badge` anchored to the top-right corner (e.g. "3", "999+"). Empty string renders no badge. Ignored when `badge-dot` is set. |
|
|
104
|
+
| `badgeDot` | `badge-dot` | `boolean` | `false` | Renders a small dot badge in the top-right corner instead of a numbered badge; takes precedence over `badge`. The dot is inset 2px from the corner so it lands on a circular icon button's edge. |
|
|
105
|
+
|
|
106
|
+
## Events
|
|
107
|
+
|
|
108
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
109
|
+
| --- | --- | --- | --- |
|
|
110
|
+
| — | — | — | This element emits no custom events. |
|
|
111
|
+
|
|
112
|
+
## Slots
|
|
113
|
+
|
|
114
|
+
| Slot | Description |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| (default) | Button content: label text, a `rel-icon`, or icon + text (kept on one line with the size's gap). |
|
|
117
|
+
|
|
118
|
+
## CSS Parts
|
|
119
|
+
|
|
120
|
+
| Part | Description |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `base` | The inner native `<button>` element (padding, min-width, fill, border, focus ring). |
|
|
123
|
+
| `indicator` | The loading spinner, rendered only while `loading` is set. |
|
|
124
|
+
|
|
125
|
+
## Tokens / CSS Variables
|
|
126
|
+
|
|
127
|
+
### Component hooks
|
|
128
|
+
|
|
129
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
130
|
+
|
|
131
|
+
| Custom property | Default | Description |
|
|
132
|
+
| --- | --- | --- |
|
|
133
|
+
| `--rel-button-min-width` | `80px` | Overrides the per-size minimum width (Figma small/medium/large = 80/100/120px, ghost small = 56px). Ignored by `icon-only` and `link`. |
|
|
134
|
+
|
|
135
|
+
<!-- readme-gen:end -->
|
|
136
|
+
|
|
137
|
+
## Accessibility
|
|
138
|
+
|
|
139
|
+
- Renders a native `<button>` (the `base` part), so it is focusable, announced as a button and activated with the keyboard without extra work.
|
|
140
|
+
- `aria-disabled` mirrors `disabled`; `aria-busy` mirrors `loading`. The spinner is `aria-hidden`, and the label stays in the DOM (visually hidden) while loading, so the accessible name does not change.
|
|
141
|
+
- `aria-label` is forwarded to the inner button. Always set it on `icon-only` buttons and on the legacy `icon` variant — a slotted icon has no text.
|
|
142
|
+
- Disabled and loading buttons swallow clicks in the capture phase on the host, so `el.click()` and delegated listeners never fire.
|
|
143
|
+
|
|
144
|
+
| Key | Action |
|
|
145
|
+
| --- | --- |
|
|
146
|
+
| `Tab` / `Shift+Tab` | Move focus to / from the button |
|
|
147
|
+
| `Enter` / `Space` | Activate (native button behaviour) |
|
|
148
|
+
|
|
149
|
+
Focus: `:focus-visible` shows the shared 2px focus outline plus inner/outer halo on every style except `link`, which shows a 2px focus-coloured underline bar and the hover label colour instead (still a visible indicator per WCAG 2.4.7). Pressing scales the button to 97%; the spinner slows to 2s under `prefers-reduced-motion: reduce`.
|
|
150
|
+
|
|
151
|
+
## Notes / Edge Cases
|
|
152
|
+
|
|
153
|
+
- **Events.** The element dispatches no custom events. The native `click` is `composed`, so a listener on `<rel-button>` (or an ancestor) receives exactly one event per activation — do not re-dispatch it.
|
|
154
|
+
- **Minimum widths** come from the Figma master: small/medium/large = 80/100/120px, ghost small = 56px. `link` has no minimum, `icon-only` is a fixed square (32/40/48px) and the legacy `icon` variant is always a 40px circle regardless of `size`. Override per instance with `--rel-button-min-width`.
|
|
155
|
+
- **Legacy `icon` variant vs `icon-only`.** `variant="icon"` keeps its pre-2.0 look (40px circle, tone-driven fill, `tone="secondary"` gives it an outline) and ignores `size` and `border`. `icon-only` is an axis that composes with any style and size — prefer it.
|
|
156
|
+
- **`tone` on `secondary` / `ghost` / `link`** changes the label, border or text colour only; the fill stays on the surface. The destructive outline border is deliberately subtle at rest and only goes solid on hover/pressed, matching Figma.
|
|
157
|
+
- **`static`** is a neutral-only style meant for coloured or dark backgrounds; other tones have no static treatment.
|
|
158
|
+
- **`success`** is a legacy tone without a Figma counterpart; it renders a green fill/outline/ghost tint but is not part of the current spec.
|
|
159
|
+
- **Badges** render a small `rel-badge` positioned outside the button's box (numbered) or 2px inside the corner (dot); give the button room in tight layouts. `badge-dot` wins when both are set.
|
|
160
|
+
- **Disabled styling**: only filled styles (`default`, `primary`, `icon`) flatten to the neutral disabled fill; `secondary`, `ghost`, `link` and `static` keep their shape at 50% opacity so they still read as their own style.
|