@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.
Files changed (148) hide show
  1. package/CHANGELOG.md +246 -49
  2. package/dist/components/rel-accordion/README.md +133 -132
  3. package/dist/components/rel-alert/README.md +145 -141
  4. package/dist/components/rel-autocomplete/README.md +172 -61
  5. package/dist/components/rel-avatar/README.md +118 -130
  6. package/dist/components/rel-badge/README.md +97 -93
  7. package/dist/components/rel-breadcrumb/README.md +96 -102
  8. package/dist/components/rel-button/README.md +190 -130
  9. package/dist/components/rel-calendar/README.md +109 -109
  10. package/dist/components/rel-card/README.md +75 -94
  11. package/dist/components/rel-cardmedia/README.md +100 -127
  12. package/dist/components/rel-carousel/README.md +186 -166
  13. package/dist/components/rel-checkbox/README.md +96 -75
  14. package/dist/components/rel-chip/README.md +138 -121
  15. package/dist/components/rel-container/README.md +107 -99
  16. package/dist/components/rel-date-picker/README.md +200 -289
  17. package/dist/components/rel-divider/README.md +88 -100
  18. package/dist/components/rel-drawer/README.md +187 -200
  19. package/dist/components/rel-kbd/README.md +141 -151
  20. package/dist/components/rel-layout/README.md +34 -0
  21. package/dist/components/rel-menu/README.md +180 -151
  22. package/dist/components/rel-menubar/README.md +218 -329
  23. package/dist/components/rel-otp/README.md +171 -440
  24. package/dist/components/rel-pagination/README.md +100 -424
  25. package/dist/components/rel-popover/README.md +203 -568
  26. package/dist/components/rel-progress/README.md +88 -110
  27. package/dist/components/rel-radio/README.md +131 -138
  28. package/dist/components/rel-range-picker/README.md +165 -0
  29. package/dist/components/rel-resizable/README.md +199 -140
  30. package/dist/components/rel-segmented-button/README.md +156 -141
  31. package/dist/components/rel-select/README.md +156 -93
  32. package/dist/components/rel-sheet/README.md +168 -224
  33. package/dist/components/rel-skeleton/README.md +104 -0
  34. package/dist/components/rel-slider/README.md +131 -135
  35. package/dist/components/rel-snackbar/README.md +168 -134
  36. package/dist/components/rel-stepper/README.md +162 -160
  37. package/dist/components/rel-switch/README.md +117 -102
  38. package/dist/components/rel-tab/README.md +173 -163
  39. package/dist/components/rel-textfield/README.md +176 -69
  40. package/dist/components/rel-time-picker/README.md +122 -157
  41. package/dist/components/rel-toast/README.md +165 -148
  42. package/dist/components/rel-tooltip/README.md +119 -111
  43. package/dist/components/rel-upload/README.md +220 -0
  44. package/dist/index.d.mts +1726 -447
  45. package/dist/index.d.ts +1726 -447
  46. package/dist/index.js +13715 -10870
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +14018 -11163
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/styles/focus-ring.ts +84 -0
  51. package/dist/styles/vars.css +892 -866
  52. package/dist/{vars-XNMTSRVN.css → vars-DXX6QOAG.css} +892 -866
  53. package/package.json +3 -2
  54. package/dist/components/rel-accordion/rel-accordion.ts +0 -336
  55. package/dist/components/rel-alert/rel-alert.ts +0 -305
  56. package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -720
  57. package/dist/components/rel-avatar/rel-avatar.ts +0 -142
  58. package/dist/components/rel-badge/rel-badge.ts +0 -175
  59. package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
  60. package/dist/components/rel-button/rel-button.ts +0 -560
  61. package/dist/components/rel-calendar/index.ts +0 -1
  62. package/dist/components/rel-calendar/rel-calendar.ts +0 -565
  63. package/dist/components/rel-card/rel-card.ts +0 -88
  64. package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
  65. package/dist/components/rel-carousel/index.ts +0 -1
  66. package/dist/components/rel-carousel/rel-carousel.ts +0 -723
  67. package/dist/components/rel-chart/README.md +0 -286
  68. package/dist/components/rel-chart/index.ts +0 -1
  69. package/dist/components/rel-chart/rel-chart.ts +0 -754
  70. package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
  71. package/dist/components/rel-chip/rel-chip.ts +0 -483
  72. package/dist/components/rel-container/rel-container.ts +0 -95
  73. package/dist/components/rel-date-picker/date-format.test.ts +0 -43
  74. package/dist/components/rel-date-picker/date-format.ts +0 -47
  75. package/dist/components/rel-date-picker/date-parse.test.ts +0 -116
  76. package/dist/components/rel-date-picker/date-parse.ts +0 -178
  77. package/dist/components/rel-date-picker/index.ts +0 -1
  78. package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1676
  79. package/dist/components/rel-divider/rel-divider.ts +0 -54
  80. package/dist/components/rel-drawer/index.ts +0 -1
  81. package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
  82. package/dist/components/rel-drawer/rel-drawer.ts +0 -607
  83. package/dist/components/rel-kbd/rel-kbd.ts +0 -188
  84. package/dist/components/rel-layout/rel-layout.ts +0 -49
  85. package/dist/components/rel-menu/rel-menu.ts +0 -541
  86. package/dist/components/rel-menubar/index.ts +0 -2
  87. package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
  88. package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
  89. package/dist/components/rel-menubar/rel-menubar.ts +0 -777
  90. package/dist/components/rel-nav-menu/README.md +0 -289
  91. package/dist/components/rel-nav-menu/index.ts +0 -3
  92. package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
  93. package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
  94. package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
  95. package/dist/components/rel-navbar/README.md +0 -126
  96. package/dist/components/rel-navbar/rel-navbar.ts +0 -105
  97. package/dist/components/rel-otp/index.ts +0 -1
  98. package/dist/components/rel-otp/rel-otp.ts +0 -527
  99. package/dist/components/rel-pagination/index.ts +0 -1
  100. package/dist/components/rel-pagination/rel-pagination.ts +0 -522
  101. package/dist/components/rel-popover/index.ts +0 -2
  102. package/dist/components/rel-popover/rel-popover-content.ts +0 -81
  103. package/dist/components/rel-popover/rel-popover.ts +0 -475
  104. package/dist/components/rel-progress/rel-progress.ts +0 -234
  105. package/dist/components/rel-radio/rel-radio.ts +0 -481
  106. package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1688
  107. package/dist/components/rel-resizable/index.ts +0 -3
  108. package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
  109. package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
  110. package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
  111. package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -217
  112. package/dist/components/rel-select/rel-select.ts +0 -1416
  113. package/dist/components/rel-sheet/rel-sheet.ts +0 -610
  114. package/dist/components/rel-sidebar/README.md +0 -209
  115. package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1191
  116. package/dist/components/rel-skeleton/rel-skeleton.ts +0 -143
  117. package/dist/components/rel-slider/rel-slider.ts +0 -673
  118. package/dist/components/rel-snackbar/rel-snackbar.ts +0 -329
  119. package/dist/components/rel-stepper/rel-stepper.ts +0 -567
  120. package/dist/components/rel-switch/rel-switch.ts +0 -199
  121. package/dist/components/rel-tab/rel-tab.ts +0 -264
  122. package/dist/components/rel-table/README.md +0 -178
  123. package/dist/components/rel-table/rel-table-body.ts +0 -22
  124. package/dist/components/rel-table/rel-table-caption.ts +0 -30
  125. package/dist/components/rel-table/rel-table-cell.ts +0 -43
  126. package/dist/components/rel-table/rel-table-footer.ts +0 -24
  127. package/dist/components/rel-table/rel-table-head.ts +0 -47
  128. package/dist/components/rel-table/rel-table-header.ts +0 -22
  129. package/dist/components/rel-table/rel-table-row.ts +0 -37
  130. package/dist/components/rel-table/rel-table.ts +0 -62
  131. package/dist/components/rel-textfield/rel-textfield.ts +0 -1054
  132. package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1482
  133. package/dist/components/rel-time-picker/time-parse.test.ts +0 -67
  134. package/dist/components/rel-time-picker/time-parse.ts +0 -85
  135. package/dist/components/rel-toast/rel-toast.ts +0 -206
  136. package/dist/components/rel-tooltip/rel-tooltip.ts +0 -193
  137. package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
  138. package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
  139. package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
  140. package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
  141. package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
  142. package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
  143. package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
  144. package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
  145. package/dist/components/rel-topbar/rel-topbar.ts +0 -446
  146. package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
  147. package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
  148. package/dist/components/rel-upload/rel-upload.ts +0 -968
@@ -1,132 +1,133 @@
1
- # rel-accordion
2
-
3
- ## Overview
4
- An animated accordion component with a collapsible body section. Features a clickable header with chevron icon rotation, smooth expand/collapse transitions, and keyboard support. Respects reduced motion preferences.
5
-
6
- ## Usage
7
- ```html
8
- <!-- Basic accordion -->
9
- <rel-accordion title="Section 1">
10
- <p>This is the content of section 1.</p>
11
- </rel-accordion>
12
-
13
- <!-- Initially open -->
14
- <rel-accordion title="FAQ: How does it work?" open>
15
- <p>This accordion starts in the open state.</p>
16
- <ul>
17
- <li>Bullet 1</li>
18
- <li>Bullet 2</li>
19
- </ul>
20
- </rel-accordion>
21
-
22
- <!-- Multiple accordions -->
23
- <rel-accordion title="Introduction">
24
- <p>Introduction content...</p>
25
- </rel-accordion>
26
- <rel-accordion title="Features">
27
- <p>Features content...</p>
28
- </rel-accordion>
29
- <rel-accordion title="Pricing">
30
- <p>Pricing content...</p>
31
- </rel-accordion>
32
-
33
- <!-- Listen for open state changes -->
34
- <rel-accordion id="myAccordion" title="Details"></rel-accordion>
35
- <script>
36
- const accordion = document.getElementById('myAccordion');
37
- accordion.addEventListener('open-change', (e) => {
38
- console.log('Accordion open:', e.detail); // true or false
39
- });
40
- </script>
41
- ```
42
-
43
- ## API
44
-
45
- ### Attributes/Properties
46
- | Name | Type | Default | Description |
47
- |------|------|---------|-------------|
48
- | `title` | `string` | `"Accordion"` | Header title text |
49
- | `open` (reflected) | `boolean` | `false` | Whether the accordion is expanded |
50
-
51
- ## Events
52
- | Event | Detail | Description |
53
- |-------|--------|-------------|
54
- | `open-change` | `boolean` | Fired when the accordion is toggled (detail is the new `open` state) |
55
-
56
- ## Slots
57
- | Slot | Description |
58
- |------|-------------|
59
- | (default) | Accordion body content |
60
-
61
- ## CSS Parts
62
- None exposed.
63
-
64
- ## Tokens / CSS Variables
65
-
66
- ### Semantic Tokens
67
- - `--rel-fonts-font-family` - Font family
68
-
69
- ### Font Tokens
70
- - `--rel-body-xl-regular-font-size` - Title font size (20px)
71
- - `--rel-body-md-regular-font-size` - Body font size (14px)
72
- - `--rel-fonts-weight-body-medium` - Title font weight (500)
73
-
74
- ### Color Tokens
75
- - `--rel-bg-surface` - Background color
76
- - `--rel-text-label` - Title text color
77
- - `--rel-text-default` - Body text color, icon stroke color
78
- - `--rel-border-default` - Border color
79
- - `--rel-border-info` - Focus outline color
80
-
81
- ### Shadow Tokens
82
- - `--rel-shadows-shadow-100` - Shadow
83
-
84
- ### Border Tokens
85
- - `--rel-border-radius-sm` - Border radius (8px)
86
-
87
- ### Spacing Tokens
88
- - `--rel-spacing-md` - Header horizontal padding, body horizontal padding in closed state (16px)
89
- - `--rel-spacing-xl` - Body top padding when open (24px)
90
- - `--rel-spacing-lg` - Body bottom padding when open (20px)
91
-
92
- ## Accessibility
93
- - Header uses `role="button"` and `aria-expanded` attribute
94
- - Header is keyboard accessible with `tabindex="0"`
95
- - Supports Enter and Space key activation
96
- - Focus visible outline on keyboard focus
97
-
98
- ### Keyboard Interactions
99
- | Key | Action |
100
- |-----|--------|
101
- | `Enter` | Toggle accordion open/closed |
102
- | `Space` | Toggle accordion open/closed |
103
- | `Tab` | Navigate to/from the header |
104
-
105
- ### Focus Behavior
106
- - Header receives focus outline (`outline: 2px solid --rel-border-info`)
107
- - Focus offset is `-2px` inset
108
-
109
- ## Notes / Edge Cases
110
- - **Animation details**:
111
- - Chevron rotates 180° when open (`transform: rotate(180deg)`)
112
- - Body expands from `max-height: 0` to `max-height: 1000px`
113
- - Body padding animates from `0` to full padding when opening
114
- - Transitions: `transform 0.25s ease`, `max-height 0.25s ease`, `padding 0.2s ease`
115
-
116
- - **Reduced motion**: When `prefers-reduced-motion: reduce`, icon rotation and body transitions are disabled
117
-
118
- - **Body rendering**: The slotted content is always in the DOM (not conditionally rendered), but hidden via `max-height: 0` and `overflow: hidden` when closed
119
-
120
- - The header has hover styling (`background: --rel-bg-neutral-elevated-1`)
121
-
122
- - The component is `display: block` and `width: 100%`
123
-
124
- - The accordion border is `1px solid` with rounded corners
125
-
126
- - The chevron icon is an inline SVG (9-point downward-pointing chevron)
127
-
128
- - When closed, the body has `padding: 0 var(--rel-spacing-md)` to maintain horizontal padding
129
-
130
- - The `open` attribute is reflected in HTML when set
131
-
132
- - Multiple accordions can be open simultaneously (no automatic closing of others)
1
+ # rel-accordion
2
+
3
+ `<rel-accordion>` is a single collapsible section of the Reliability Design System (Figma "Accordion", 6021:1085): a clickable header with a title and a chevron that expands or collapses the slotted body. Each element is independent — stack several to build an FAQ or a settings list, and nothing closes automatically when another opens. Use it for progressive disclosure of secondary content; do not use it to switch between peer views (use tabs) or to hide primary actions.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Basic: closed by default, opens on click / Enter / Space -->
9
+ <rel-accordion title="Shipping">
10
+ <p>Orders ship within two business days.</p>
11
+ </rel-accordion>
12
+
13
+ <!-- Initially open -->
14
+ <rel-accordion title="Returns" open>
15
+ <p>Free returns within 30 days.</p>
16
+ </rel-accordion>
17
+
18
+ <!-- Header scale: 56 / 48 / 44 px -->
19
+ <rel-accordion size="large" title="Large"></rel-accordion>
20
+ <rel-accordion size="medium" title="Medium"></rel-accordion>
21
+ <rel-accordion size="small" title="Small"></rel-accordion>
22
+
23
+ <!-- Plain style: square corners and a 1px border instead of the shadow card -->
24
+ <rel-accordion appearance="plain" title="Plain"></rel-accordion>
25
+
26
+ <!-- Action type: leading rotating chevron + static trailing arrow-expansion, body indented -->
27
+ <rel-accordion type="action" title="Filters">
28
+ <p>Filter options…</p>
29
+ </rel-accordion>
30
+
31
+ <!-- Action type with a custom leading icon (slotted icons never rotate) -->
32
+ <rel-accordion type="action" title="Preferences">
33
+ <rel-icon slot="icon" name="settings"></rel-icon>
34
+ <p>Preference options…</p>
35
+ </rel-accordion>
36
+
37
+ <!-- Custom trailing icon on the default type -->
38
+ <rel-accordion title="More">
39
+ <rel-icon slot="trailing-icon" name="plus"></rel-icon>
40
+ <p>Extra content…</p>
41
+ </rel-accordion>
42
+ ```
43
+
44
+ ```js
45
+ const accordion = document.querySelector("rel-accordion");
46
+
47
+ accordion.addEventListener("open-change", (e) => {
48
+ e.detail; // true when the body was just expanded, false when collapsed
49
+ });
50
+
51
+ // Programmatic toggle (does not fire open-change)
52
+ accordion.open = true;
53
+ ```
54
+
55
+ ### Deprecated aliases
56
+
57
+ ```html
58
+ <!-- size="md" → size="large", size="sm" → size="medium". Both still work; no console notice is logged. -->
59
+ <rel-accordion size="md" title="Legacy large"></rel-accordion>
60
+ <rel-accordion size="sm" title="Legacy medium"></rel-accordion>
61
+ <!-- canonical -->
62
+ <rel-accordion size="large" title="Large"></rel-accordion>
63
+ <rel-accordion size="medium" title="Medium"></rel-accordion>
64
+ ```
65
+
66
+ <!-- readme-gen:start -->
67
+
68
+ <!-- Generated from rel-accordion.ts — do not edit; run readme-generate.mjs -->
69
+
70
+ ## API
71
+
72
+ ### Attributes / Properties
73
+
74
+ | Property | Attribute | Type | Default | Description |
75
+ | --- | --- | --- | --- | --- |
76
+ | `title` | `title` | `string` | `"Accordion"` | Header text. Note it is also the native HTML `title` attribute, so browsers show it as a tooltip on hover. |
77
+ | `open` | `open` | `boolean` | `false` | Whether the body is expanded; toggled by the header and reported via `open-change`. Setting it from code does not fire the event. Reflected. |
78
+ | `size` | `size` | `"md" \| "sm" \| "large" \| "medium" \| "small"` | `"md"` | Header scale (Figma "Size"): `large` = 56px header / heading-md title, `medium` = 48px / heading-sm, `small` = 44px / heading-xs (new in 1.4.7). The historical spellings stay supported as aliases: `md` = large (the default), `sm` = medium. Reflected. |
79
+ | `type` | `type` | `"default" \| "action"` | `"default"` | Header layout (Figma "Type"): `default` = title + trailing rotating chevron; `action` = leading icon slot (rotating chevron by default) + static trailing arrow-expansion icon, with the body indented under the title. DELIBERATE DIVERGENCE — do not "fix" this to a button. For `Type=Action` Figma draws the trailing affordance as a full ghost icon Button instance (Size=Medium 40x40, Size=Small 32x32, Style=Ghost, Type=Icon Only); the code keeps a bare icon. Ruled by the user: our behaviour stands and the DESIGN FILE follows our docs here, not the other way round. The whole header is the click target, so a nested button would add a second focusable control inside it and two competing hit areas. Reflected. |
80
+ | `appearance` | `appearance` | `"shadow" \| "plain"` | `"shadow"` | Figma "Style" axis — named appearance because `style` collides with the HTML style attribute. `shadow` = 4px-radius card with the shadow-sm effect and no border; `plain` = square corners with a 1px border-subtle stroke and no elevation. Reflected. |
81
+ | `disabled` | `disabled` | `boolean` | `false` | Figma "State=Disabled": dims the whole component to 40% and blocks toggling by pointer and keyboard. The header keeps its fill and stroke — the dulling is opacity alone, as Figma specifies. Reflected. |
82
+
83
+ ## Events
84
+
85
+ | Event | Detail | Bubbles / composed | Description |
86
+ | --- | --- | --- | --- |
87
+ | `open-change` | `open` | bubbles / composed | Fired when the header toggles the accordion (click, Enter or Space). Detail: the new `open` state (boolean). Not fired when `open` is set programmatically. |
88
+
89
+ ## Slots
90
+
91
+ | Slot | Description |
92
+ | --- | --- |
93
+ | (default) | Body content, revealed when `open` |
94
+ | `icon` | Leading icon in the header (`type="action"` only); replaces the default rotating chevron-down |
95
+ | `trailing-icon` | Trailing icon in the header; replaces the default chevron-down (default type) or arrow-expansion (action type) |
96
+
97
+ ## CSS Parts
98
+
99
+ | Part | Description |
100
+ | --- | --- |
101
+ | `base` | The outer card (`.accordion`) carrying the appearance border / shadow |
102
+ | `trigger` | The `role="button"` header row |
103
+ | `label` | The title row (leading icon + title text) |
104
+ | `icon` | The trailing icon wrapper |
105
+ | `content` | The `role="region"` body that holds the default slot |
106
+
107
+ <!-- readme-gen:end -->
108
+
109
+ ## Accessibility
110
+
111
+ - The header (part `trigger`) is a `role="button"` with `tabindex="0"`, `aria-expanded` mirroring `open`, and `aria-controls` pointing at the body.
112
+ - The body (part `content`) is a `role="region"` labelled by the header (`aria-labelledby`). While closed it carries the `inert` attribute, so collapsed content is removed from the Tab order and from the accessibility tree — not merely hidden visually.
113
+ - The slotted `icon` / `trailing-icon` content and the built-in `rel-icon` chevrons are decorative; the accessible name of the header is the `title` text.
114
+ - Keyboard focus is shown as a 2px `--rel-border-focus` outline inset 2px inside the header (it follows the card radius so it is not clipped).
115
+ - No live-region announcements are made; the `aria-expanded` change is what screen readers report.
116
+
117
+ | Key (header focused) | Action |
118
+ | --- | --- |
119
+ | Enter | Toggle open / closed (fires `open-change`) |
120
+ | Space | Toggle open / closed (fires `open-change`) |
121
+ | Tab / Shift + Tab | Move to the next / previous focusable element; the body's content is only reachable while open |
122
+
123
+ ## Notes / Edge Cases
124
+
125
+ - `size` defaults to the legacy spelling `"md"`, which renders the Figma Large (56px) header; `"sm"` renders Medium (48px). The full-word values are the canonical ones — see Deprecated aliases.
126
+ - `title` is also the element's native `title` attribute, so browsers show it as a hover tooltip on the whole component.
127
+ - `open-change` fires only from user toggles (click, Enter, Space). Setting `open` from code updates the UI silently.
128
+ - The body stays in the DOM when closed; it is collapsed with `max-height: 0` / `overflow: hidden` and `inert`. When open the cap is `max-height: 1000px`, so content taller than 1000px is clipped.
129
+ - Rotation on open applies only to the built-in fallback icons (`chevron-down` in the trailing slot for `type="default"`, in the leading slot for `type="action"`). Anything you slot into `icon` or `trailing-icon` stays static, and the Action type's trailing `arrow-expansion` never rotates (Figma audit 1b).
130
+ - `type="action"` indents the open body under the title: 56px at `large`, 48px at `medium` / `small`. The leading icon wrapper is 40px / 18px icon at `large` and 32px / 16px at the other sizes; the trailing icon wrapper follows the same tiers.
131
+ - Header hover / pressed use the `--rel-action-overlay-hover` / `--rel-action-overlay-pressed` tokens. `appearance="shadow"` uses `--rel-shadows-sm` with a transparent border; `appearance="plain"` uses `--rel-border-subtle` with no shadow and zero radius.
132
+ - Transitions (chevron rotation, body max-height and padding) are disabled under `prefers-reduced-motion: reduce`.
133
+ - The host is `display: block; width: 100%`; wrap it to constrain the width.
@@ -1,141 +1,145 @@
1
- # rel-alert
2
-
3
- ## Overview
4
- A versatile alert component for displaying informational, success, warning, error, or neutral messages. Features built-in icons, optional dismissibility, secondary message text, and inline links. Automatically hides when dismissed via the `dismissed` reflected attribute.
5
-
6
- ## Usage
7
- ```html
8
- <!-- Basic neutral alert -->
9
- <rel-alert
10
- message1="This is a neutral alert"
11
- type="neutral">
12
- </rel-alert>
13
-
14
- <!-- Info alert with secondary message -->
15
- <rel-alert
16
- type="info"
17
- message1="System Notification"
18
- message2="Your settings have been updated successfully.">
19
- </rel-alert>
20
-
21
- <!-- Success alert -->
22
- <rel-alert
23
- type="success"
24
- message1="Operation Completed"
25
- message2="Your data has been saved.">
26
- </rel-alert>
27
-
28
- <!-- Warning alert -->
29
- <rel-alert
30
- type="warning"
31
- message1="Warning"
32
- message2="Please verify your input before continuing.">
33
- </rel-alert>
34
-
35
- <!-- Error alert -->
36
- <rel-alert
37
- type="error"
38
- message1="Error Occurred"
39
- message2="Unable to process your request.">
40
- </rel-alert>
41
-
42
- <!-- With action link -->
43
- <rel-alert
44
- type="info"
45
- message1="Update Available"
46
- message2="A new version is ready."
47
- urlText="Learn More"
48
- urlHref="https://example.com/release-notes">
49
- </rel-alert>
50
-
51
- <!-- Non-dismissible -->
52
- <rel-alert
53
- type="warning"
54
- message1="Required Action"
55
- dismissible="false">
56
- </rel-alert>
57
-
58
- <!-- Listen for dismiss -->
59
- <rel-alert id="myAlert" type="success" message1="Success!"></rel-alert>
60
- <script>
61
- const alert = document.getElementById('myAlert');
62
- alert.addEventListener('dismiss', () => {
63
- console.log('Alert was dismissed');
64
- });
65
- </script>
66
- ```
67
-
68
- ## API
69
-
70
- ### Attributes/Properties
71
- | Name | Type | Default | Description |
72
- |------|------|---------|-------------|
73
- | `type` | `"info" \| "success" \| "warning" \| "error" \| "neutral"` | `"neutral"` | Alert type determining icon and color scheme |
74
- | `message1` | `string` | `""` | Primary message text (bold) |
75
- | `message2` | `string` | - | Optional secondary message text (smaller, slightly transparent) |
76
- | `urlText` | `string` | - | Link text (shown below messages) |
77
- | `urlHref` | `string` | - | Link URL (both `urlText` and `urlHref` required for link to show) |
78
- | `dismissible` | `boolean` | `true` | Whether to show the close (✕) button |
79
- | `dismissed` | `boolean` (reflected) | `false` | When true, hides the component via `:host([dismissed])` |
80
-
81
- ## Events
82
- | Event | Detail | Description |
83
- |-------|--------|-------------|
84
- | `dismiss` | None | Fired when the close button is clicked (sets `dismissed` to true) |
85
-
86
- ## Slots
87
- Default slot not used.
88
-
89
- ## CSS Parts
90
- None exposed.
91
-
92
- ## Tokens / CSS Variables
93
-
94
- ### Semantic Tokens
95
- - `--rel-fonts-font-family` - Font family
96
- - `--rel-body-md-regular-font-size` - Primary message font size
97
- - `--rel-body-sm-regular-font-size` - Secondary message and link font size
98
- - `--rel-fonts-weight-body-medium` - Primary message and link font weight
99
- - `--rel-fonts-weight-body-semibold` - Used implicitly in link styling
100
-
101
- ### Spacing Tokens
102
- - `--rel-spacing-xs` - Gap between icon and content
103
- - `--rel-spacing-sm` - Vertical padding
104
- - `--rel-spacing-md` - Horizontal padding
105
- - `--rel-spacing-2xs` - Close button padding
106
-
107
- ### Color Tokens (by type)
108
- - **info**: `--rel-bg-info-light` (background), `--rel-text-info` (text), `--rel-text-info` (icon)
109
- - **success**: `--rel-bg-success-light`, `--rel-text-success`, `--rel-text-success`
110
- - **warning**: `--rel-bg-warning-light`, `--rel-text-warning`, `--rel-text-warning`
111
- - **error**: `--rel-bg-danger-light`, `--rel-text-error`, `--rel-text-danger`
112
- - **neutral**: `--rel-bg-surface` (background), `--rel-text-default` (text), `--rel-text-default` (icon), `--rel-border-default` (border)
113
-
114
- ### Border Tokens
115
- - `--rel-border-radius-sm` - Border radius
116
-
117
- ## Accessibility
118
- - Uses `role="alert"` for screen reader announcements
119
- - Close button has `aria-label="Dismiss"`
120
- - Focus visible states on close button with 2px outline
121
- - Secondary message has reduced opacity for visual hierarchy
122
-
123
- ### Keyboard Interactions
124
- - `Tab` - Focus the close button (if dismissible)
125
- - `Space/Enter` - Dismiss the alert (when close button focused)
126
-
127
- ### Focus Behavior
128
- - Close button shows 2px outline matching the alert's text color with 2px offset
129
- - Border radius applied to maintain visual consistency
130
-
131
- ## Notes / Edge Cases
132
- - Icons are built-in SVG graphics that change based on `type` (info: ℹ️, success: ✓, warning: ⚠️, error: ❗, neutral: ℹ️)
133
- - Icon colors are controlled by type-specific `--rel-icon-*` tokens
134
- - The alert has a minimum width of `360px`
135
- - Both `urlText` and `urlHref` must be set for the link to appear
136
- - Links inherit the alert's text color and are underlined
137
- - `message2` has `opacity: 0.9` for subtle contrast with `message1`
138
- - When `dismissed` is set to `true`, the component applies `display: none` via `:host([dismissed])`
139
- - `dismissed` is a reflected attribute, meaning it appears in the HTML when true
140
- - The close button is always positioned at the right edge via `margin-left: auto`
141
- - Neutral type includes a 1px border while colored types do not
1
+ # rel-alert
2
+
3
+ `<rel-alert>` is the inline status banner of the Reliability Design System (Figma "Alert"). It renders a tone-coloured box with a leading status icon, a bold title (`message1`), optional supporting text (`message2`), an optional inline link and an optional dismiss button, in the Figma Tone (neutral / info / success / warning / destructive) and Style (subtle / solid / outline) variants. Use it for persistent, in-flow messages about a page or section — form-level validation, degraded-service notices, onboarding hints. For transient feedback that disappears on its own use `<rel-toast>` or `<rel-snackbar>`; for blocking decisions use `<rel-modal>`.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Neutral (default tone, subtle appearance) -->
9
+ <rel-alert message1="Scheduled maintenance on Sunday 02:00–04:00 UTC"></rel-alert>
10
+
11
+ <!-- Tones -->
12
+ <rel-alert tone="info" message1="Update available" message2="Version 2.3 adds offline mode."></rel-alert>
13
+ <rel-alert tone="success" message1="Changes saved" message2="Your profile is up to date."></rel-alert>
14
+ <rel-alert tone="warning" message1="Storage almost full" message2="You have used 95% of your quota."></rel-alert>
15
+ <rel-alert tone="destructive" message1="Upload failed" message2="The file exceeds the 25 MB limit."></rel-alert>
16
+
17
+ <!-- Appearance: subtle (default) | solid | outline -->
18
+ <rel-alert tone="info" appearance="solid" message1="Solid alert"></rel-alert>
19
+ <rel-alert tone="info" appearance="outline" message1="Outline alert"></rel-alert>
20
+
21
+ <!-- Inline link: both url-text and url-href are required for it to render -->
22
+ <rel-alert
23
+ tone="info"
24
+ message1="Release notes"
25
+ message2="See what changed in this version."
26
+ url-text="Read more"
27
+ url-href="https://example.com/release-notes"
28
+ ></rel-alert>
29
+
30
+ <!-- Non-dismissible: the boolean must be cleared from script (see the js block) -->
31
+ <rel-alert id="locked" tone="warning" message1="Action required"></rel-alert>
32
+
33
+ <!-- Listen for dismissal -->
34
+ <rel-alert id="saved" tone="success" message1="Saved"></rel-alert>
35
+ ```
36
+
37
+ ```js
38
+ // A Lit boolean attribute is true whenever present, so dismissible="false" does NOT work.
39
+ document.getElementById("locked").dismissible = false;
40
+
41
+ const saved = document.getElementById("saved");
42
+ saved.addEventListener("dismiss", () => {
43
+ saved.dismissed; // true — the host is now display: none
44
+ });
45
+ // Show it again later:
46
+ saved.dismissed = false;
47
+ ```
48
+
49
+ ### Deprecated aliases
50
+
51
+ ```html
52
+ <!-- type= is the deprecated alias of tone= (tone wins when both are set). Logs once per page:
53
+ [rel-alert] "type" is deprecated and will be removed in 3.0 — use "tone" instead. Note: tone="destructive" replaces type="error". -->
54
+ <rel-alert type="error" message1="Upload failed"></rel-alert>
55
+
56
+ <!-- tone="error" | "danger" | "critical" are deprecated spellings of tone="destructive". Logs once per spelling:
57
+ [rel-alert] "tone="error"" is deprecated and will be removed in 3.0 — use "tone="destructive"" instead. -->
58
+ <rel-alert tone="error" message1="Upload failed"></rel-alert>
59
+ <rel-alert tone="critical" message1="Upload failed"></rel-alert>
60
+
61
+ <!-- appearance="filled" is the deprecated alias of appearance="solid" (no console notice). -->
62
+ <rel-alert tone="info" appearance="filled" message1="Solid alert"></rel-alert>
63
+ ```
64
+
65
+ <!-- readme-gen:start -->
66
+
67
+ <!-- Generated from rel-alert.ts — do not edit; run readme-generate.mjs -->
68
+
69
+ ## API
70
+
71
+ ### Attributes / Properties
72
+
73
+ | Property | Attribute | Type | Default | Description |
74
+ | --- | --- | --- | --- | --- |
75
+ | `tone` | `tone` | `"neutral" \| "info" \| "success" \| "warning" \| "destructive" \| "error" \| "danger" \| "critical"` | `undefined` | Semantic tone (Figma "Tone"): `"neutral"` (default) \| `"info"` \| `"success"` \| `"warning"` \| `"destructive"`. Drives the fill/border colour, the title colour and the leading icon (info, check-circle, alert-circle, error). `"error"`, `"danger"` and `"critical"` are deprecated aliases of `"destructive"` and log a one-time console notice. Takes precedence over the deprecated `type` prop. |
76
+ | `appearance` | `appearance` | `"solid" \| "subtle" \| "outline" \| "filled"` | `"subtle"` | Visual treatment (Figma "Style"): `"subtle"` (default: tone-light fill, no border) \| `"solid"` (tone fill, inverse text, `--rel-shadows-md` elevation) \| `"outline"` (transparent fill, tone border). `"filled"` is a deprecated alias of `"solid"` (no console notice). Reflected. |
77
+ | `message1` | `message1` | `string` | `""` | Primary message (title), rendered in body-lg medium weight in the tone colour. |
78
+ | `message2` | `message2` | `string` | `undefined` | Optional secondary message rendered under the title in body-md at 90% opacity; omitted when unset. |
79
+ | `urlText` | `url-text` | `string` | `undefined` | Text of the inline link rendered under the messages. The link appears only when both `urlText` and `urlHref` are set. |
80
+ | `urlHref` | `url-href` | `string` | `undefined` | `href` of the inline link. The link appears only when both `urlText` and `urlHref` are set. |
81
+ | `dismissible` | `dismissible` | `boolean` | `true` | Shows the dismiss (✕) button. Defaults to true; because it is a Lit boolean, `dismissible="false"` is still true — set the property to `false` from script to hide the button. |
82
+ | `dismissed` | `dismissed` | `boolean` | `false` | True once the alert has been dismissed; hides the host via `:host([dismissed]) { display: none }`. Set it back to `false` to show the alert again. Reflected. |
83
+
84
+ #### Deprecated (still supported — removal targeted for 3.0)
85
+
86
+ | Property | Attribute | Type | Use instead |
87
+ | --- | --- | --- | --- |
88
+ | `type` | `type` | `"neutral" \| "info" \| "success" \| "warning" \| "destructive" \| "error" \| "danger" \| "critical"` | Deprecated since 1.4.7 — alias of `tone`; use `tone`. Same values as `tone`; `type="error"` maps to `tone="destructive"`. Ignored when `tone` is set. Logs a one-time console notice. |
89
+
90
+ ### Public fields / accessors
91
+
92
+ | Name | Type | Description |
93
+ | --- | --- | --- |
94
+ | `resolvedTone` | `AlertTone` | Read-only canonical tone actually rendered: explicit `tone` wins, else `type`, else `"neutral"`; deprecated aliases are resolved to `"destructive"`. |
95
+
96
+ ## Events
97
+
98
+ | Event | Detail | Bubbles / composed | Description |
99
+ | --- | --- | --- | --- |
100
+ | `dismiss` | — | bubbles / composed | Fired when the user clicks the dismiss button, after `dismissed` has been set to true. No detail. |
101
+
102
+ ## Slots
103
+
104
+ | Slot | Description |
105
+ | --- | --- |
106
+ | — | This element has no slots. |
107
+
108
+ ## CSS Parts
109
+
110
+ | Part | Description |
111
+ | --- | --- |
112
+ | `base` | The `role="alert"` container that carries the tone and appearance styling |
113
+ | `icon` | Wrapper around the leading status `<rel-icon>` |
114
+ | `content` | Column that stacks the title, helper text and link |
115
+ | `label` | The primary message (`message1`) paragraph |
116
+ | `helper` | The secondary message (`message2`) paragraph; rendered only when `message2` is set |
117
+ | `action` | The inline link; rendered only when both `url-text` and `url-href` are set |
118
+ | `close-button` | The dismiss (✕) button; rendered only while `dismissible` is true |
119
+
120
+ <!-- readme-gen:end -->
121
+
122
+ ## Accessibility
123
+
124
+ - The container (part `base`) has `role="alert"` and `aria-atomic="true"`, so screen readers announce the whole message assertively when the element enters the DOM or its text changes. Because of that, reserve it for messages that warrant an interruption; render a `<rel-alert>` only when there is something to say rather than keeping an empty one mounted.
125
+ - The leading status `<rel-icon>` renders `aria-hidden="true"`; the tone is not conveyed to assistive technology except through the text, so put the meaning in `message1` / `message2`.
126
+ - The dismiss control is a native `<button>` with `aria-label="Dismiss"`. The inline link is a plain `<a href>`. Both are in the Tab order; the component adds no key handlers of its own:
127
+
128
+ | Key | Action |
129
+ | --- | --- |
130
+ | Tab / Shift + Tab | Move between the inline link (if any) and the dismiss button (if any) |
131
+ | Enter / Space | Activate the focused dismiss button (fires `dismiss`, sets `dismissed`) |
132
+ | Enter | Follow the focused link |
133
+
134
+ - Keyboard focus on the dismiss button is a 2px `currentColor` outline with 2px offset (`:focus-visible` only).
135
+ - Dismissing hides the host with `display: none`; focus is not moved, so if the dismiss button had focus the browser drops focus to `<body>`. Move focus yourself in the `dismiss` handler when the alert sits in the middle of a form.
136
+
137
+ ## Notes / Edge Cases
138
+
139
+ - `tone` and `appearance` are independent axes; every tone renders in every appearance. Solid uses inverse text and carries the `--rel-shadows-md` elevation; subtle and outline have no shadow.
140
+ - The status icon is fixed per tone (`info` for neutral and info, `check-circle`, `alert-circle`, `error`) and cannot be replaced or removed — there are no slots.
141
+ - The alert has `min-width: 360px`; it stretches to its container (`display: block`) but never shrinks below that.
142
+ - The link renders only when both `url-text` and `url-href` are set; it opens in the same tab (no `target`).
143
+ - `dismissible` and `dismissed` are Lit booleans: any attribute value (including `"false"`) counts as true. Toggle them as properties from script.
144
+ - `dismissed` only hides the host; the element stays in the DOM and keeps its state. Resetting `dismissed = false` shows it again without re-firing `dismiss`.
145
+ - `resolvedTone` is the tone actually rendered after alias resolution; use it (not `tone` / `type`) if you branch on tone in script.