@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.
Files changed (146) hide show
  1. package/CHANGELOG.md +211 -49
  2. package/dist/components/rel-accordion/README.md +132 -132
  3. package/dist/components/rel-alert/README.md +145 -141
  4. package/dist/components/rel-autocomplete/README.md +156 -61
  5. package/dist/components/rel-avatar/README.md +116 -130
  6. package/dist/components/rel-badge/README.md +98 -93
  7. package/dist/components/rel-breadcrumb/README.md +96 -102
  8. package/dist/components/rel-button/README.md +160 -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 +184 -166
  13. package/dist/components/rel-checkbox/README.md +93 -75
  14. package/dist/components/rel-chip/README.md +132 -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 +78 -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-menu/README.md +178 -151
  21. package/dist/components/rel-menubar/README.md +218 -329
  22. package/dist/components/rel-otp/README.md +170 -440
  23. package/dist/components/rel-pagination/README.md +100 -424
  24. package/dist/components/rel-popover/README.md +203 -568
  25. package/dist/components/rel-progress/README.md +88 -110
  26. package/dist/components/rel-radio/README.md +131 -138
  27. package/dist/components/rel-range-picker/README.md +162 -0
  28. package/dist/components/rel-resizable/README.md +199 -140
  29. package/dist/components/rel-segmented-button/README.md +155 -141
  30. package/dist/components/rel-select/README.md +154 -93
  31. package/dist/components/rel-sheet/README.md +168 -224
  32. package/dist/components/rel-skeleton/README.md +103 -0
  33. package/dist/components/rel-slider/README.md +130 -135
  34. package/dist/components/rel-snackbar/README.md +162 -134
  35. package/dist/components/rel-stepper/README.md +158 -160
  36. package/dist/components/rel-switch/README.md +108 -102
  37. package/dist/components/rel-tab/README.md +171 -163
  38. package/dist/components/rel-textfield/README.md +159 -69
  39. package/dist/components/rel-time-picker/README.md +122 -157
  40. package/dist/components/rel-toast/README.md +157 -148
  41. package/dist/components/rel-tooltip/README.md +108 -111
  42. package/dist/components/rel-upload/README.md +220 -0
  43. package/dist/index.d.mts +1147 -340
  44. package/dist/index.d.ts +1147 -340
  45. package/dist/index.js +3451 -3163
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +3416 -3118
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/styles/vars.css +877 -866
  50. package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -866
  51. package/package.json +3 -2
  52. package/dist/components/rel-accordion/rel-accordion.ts +0 -336
  53. package/dist/components/rel-alert/rel-alert.ts +0 -305
  54. package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -720
  55. package/dist/components/rel-avatar/rel-avatar.ts +0 -142
  56. package/dist/components/rel-badge/rel-badge.ts +0 -175
  57. package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
  58. package/dist/components/rel-button/rel-button.ts +0 -560
  59. package/dist/components/rel-calendar/index.ts +0 -1
  60. package/dist/components/rel-calendar/rel-calendar.ts +0 -565
  61. package/dist/components/rel-card/rel-card.ts +0 -88
  62. package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
  63. package/dist/components/rel-carousel/index.ts +0 -1
  64. package/dist/components/rel-carousel/rel-carousel.ts +0 -723
  65. package/dist/components/rel-chart/README.md +0 -286
  66. package/dist/components/rel-chart/index.ts +0 -1
  67. package/dist/components/rel-chart/rel-chart.ts +0 -754
  68. package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
  69. package/dist/components/rel-chip/rel-chip.ts +0 -483
  70. package/dist/components/rel-container/rel-container.ts +0 -95
  71. package/dist/components/rel-date-picker/date-format.test.ts +0 -43
  72. package/dist/components/rel-date-picker/date-format.ts +0 -47
  73. package/dist/components/rel-date-picker/date-parse.test.ts +0 -116
  74. package/dist/components/rel-date-picker/date-parse.ts +0 -178
  75. package/dist/components/rel-date-picker/index.ts +0 -1
  76. package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1676
  77. package/dist/components/rel-divider/rel-divider.ts +0 -54
  78. package/dist/components/rel-drawer/index.ts +0 -1
  79. package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
  80. package/dist/components/rel-drawer/rel-drawer.ts +0 -607
  81. package/dist/components/rel-kbd/rel-kbd.ts +0 -188
  82. package/dist/components/rel-layout/rel-layout.ts +0 -49
  83. package/dist/components/rel-menu/rel-menu.ts +0 -541
  84. package/dist/components/rel-menubar/index.ts +0 -2
  85. package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
  86. package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
  87. package/dist/components/rel-menubar/rel-menubar.ts +0 -777
  88. package/dist/components/rel-nav-menu/README.md +0 -289
  89. package/dist/components/rel-nav-menu/index.ts +0 -3
  90. package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
  91. package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
  92. package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
  93. package/dist/components/rel-navbar/README.md +0 -126
  94. package/dist/components/rel-navbar/rel-navbar.ts +0 -105
  95. package/dist/components/rel-otp/index.ts +0 -1
  96. package/dist/components/rel-otp/rel-otp.ts +0 -527
  97. package/dist/components/rel-pagination/index.ts +0 -1
  98. package/dist/components/rel-pagination/rel-pagination.ts +0 -522
  99. package/dist/components/rel-popover/index.ts +0 -2
  100. package/dist/components/rel-popover/rel-popover-content.ts +0 -81
  101. package/dist/components/rel-popover/rel-popover.ts +0 -475
  102. package/dist/components/rel-progress/rel-progress.ts +0 -234
  103. package/dist/components/rel-radio/rel-radio.ts +0 -481
  104. package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1688
  105. package/dist/components/rel-resizable/index.ts +0 -3
  106. package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
  107. package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
  108. package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
  109. package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -217
  110. package/dist/components/rel-select/rel-select.ts +0 -1416
  111. package/dist/components/rel-sheet/rel-sheet.ts +0 -610
  112. package/dist/components/rel-sidebar/README.md +0 -209
  113. package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1191
  114. package/dist/components/rel-skeleton/rel-skeleton.ts +0 -143
  115. package/dist/components/rel-slider/rel-slider.ts +0 -673
  116. package/dist/components/rel-snackbar/rel-snackbar.ts +0 -329
  117. package/dist/components/rel-stepper/rel-stepper.ts +0 -567
  118. package/dist/components/rel-switch/rel-switch.ts +0 -199
  119. package/dist/components/rel-tab/rel-tab.ts +0 -264
  120. package/dist/components/rel-table/README.md +0 -178
  121. package/dist/components/rel-table/rel-table-body.ts +0 -22
  122. package/dist/components/rel-table/rel-table-caption.ts +0 -30
  123. package/dist/components/rel-table/rel-table-cell.ts +0 -43
  124. package/dist/components/rel-table/rel-table-footer.ts +0 -24
  125. package/dist/components/rel-table/rel-table-head.ts +0 -47
  126. package/dist/components/rel-table/rel-table-header.ts +0 -22
  127. package/dist/components/rel-table/rel-table-row.ts +0 -37
  128. package/dist/components/rel-table/rel-table.ts +0 -62
  129. package/dist/components/rel-textfield/rel-textfield.ts +0 -1054
  130. package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1482
  131. package/dist/components/rel-time-picker/time-parse.test.ts +0 -67
  132. package/dist/components/rel-time-picker/time-parse.ts +0 -85
  133. package/dist/components/rel-toast/rel-toast.ts +0 -206
  134. package/dist/components/rel-tooltip/rel-tooltip.ts +0 -193
  135. package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
  136. package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
  137. package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
  138. package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
  139. package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
  140. package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
  141. package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
  142. package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
  143. package/dist/components/rel-topbar/rel-topbar.ts +0 -446
  144. package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
  145. package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
  146. package/dist/components/rel-upload/rel-upload.ts +0 -968
@@ -1,130 +1,116 @@
1
- # rel-avatar
2
-
3
- ## Overview
4
- A circular avatar component supporting three display types: image, text initials, or custom icon content. Provides four size variants and three style variants (fill, subtle, outline), with automatic text transformation and SVG sizing for icons.
5
-
6
- ## Usage
7
- ```html
8
- <!-- Image avatar -->
9
- <rel-avatar
10
- type="image"
11
- src="./user-photo.jpg"
12
- alt="John Doe">
13
- </rel-avatar>
14
-
15
- <!-- Text initials avatar -->
16
- <rel-avatar
17
- type="text"
18
- text="JD">
19
- </rel-avatar>
20
-
21
- <!-- Icon avatar with slotted SVG -->
22
- <rel-avatar type="icon">
23
- <svg viewBox="0 0 24 24" fill="currentColor">
24
- <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
25
- </svg>
26
- </rel-avatar>
27
-
28
- <!-- Different sizes -->
29
- <rel-avatar type="text" text="XS" size="xs"></rel-avatar>
30
- <rel-avatar type="text" text="SM" size="sm"></rel-avatar>
31
- <rel-avatar type="text" text="MD" size="md"></rel-avatar>
32
- <rel-avatar type="text" text="LG" size="lg"></rel-avatar>
33
-
34
- <!-- Style variants -->
35
- <rel-avatar type="text" text="AA" variant="fill"></rel-avatar>
36
- <rel-avatar type="text" text="AA" variant="subtle"></rel-avatar>
37
- <rel-avatar type="text" text="AA" variant="outline"></rel-avatar>
38
-
39
- <!-- User list with avatars -->
40
- <div style="display: flex; gap: 8px; align-items: center;">
41
- <rel-avatar type="image" src="user1.jpg" size="sm"></rel-avatar>
42
- <span>John Doe</span>
43
- </div>
44
-
45
- <!-- Avatar group -->
46
- <div style="display: flex; margin-left: -8px;">
47
- <rel-avatar type="text" text="A" size="md" style="margin-left: -8px;"></rel-avatar>
48
- <rel-avatar type="text" text="B" size="md" style="margin-left: -8px;"></rel-avatar>
49
- <rel-avatar type="text" text="C" size="md" style="margin-left: -8px;"></rel-avatar>
50
- </div>
51
- ```
52
-
53
- ## API
54
-
55
- ### Attributes/Properties
56
- | Name | Type | Default | Description |
57
- |------|------|---------|-------------|
58
- | `size` (reflected) | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | Avatar size variant |
59
- | `type` (reflected) | `"image" \| "text" \| "icon"` | `"image"` | Display type |
60
- | `variant` (reflected) | `"fill" \| "subtle" \| "outline"` | `"fill"` | Style variant |
61
- | `src` | `string` | `""` | Image URL (for `type="image"`) |
62
- | `text` | `string` | `""` | Text content (for `type="text"`, usually initials) |
63
- | `alt` | `string` | `"Avatar"` | Alt text for the image |
64
- | `bg` | `string` | `""` | Direct CSS background-color override (any valid CSS color), takes precedence over `variant` |
65
-
66
- ## Events
67
- None.
68
-
69
- ## Slots
70
- | Slot | Description |
71
- |------|-------------|
72
- | (default) | Custom icon content (for `type="icon"`, typically an SVG) |
73
-
74
- ## CSS Parts
75
- None exposed.
76
-
77
- ## Tokens / CSS Variables
78
-
79
- ### Semantic Tokens
80
- - `--rel-fonts-font-family` - Font family
81
-
82
- ### Font Tokens
83
- - `--rel-headings-lg-font-size` - Large avatar text size
84
- - `--rel-body-xl-regular-font-size` - Medium avatar text size
85
- - `--rel-body-md-regular-font-size` - Small avatar text size
86
- - `--rel-body-xs-regular-font-size` - Extra small avatar text size
87
- - `--rel-fonts-weight-body-semibold` - Text font weight
88
-
89
- ### Color Tokens (by variant)
90
- - **fill** (default): `--rel-avatar-bg-fill` (default `--rel-text-disabled`), `--rel-avatar-color-fill` (default `#ffffff`)
91
- - **subtle**: `--rel-avatar-bg-subtle` (default `--rel-bg-neutral-elevated-1`), `--rel-avatar-color-subtle` (default `--rel-text-label`)
92
- - **outline**: `--rel-avatar-bg-outline` (default `--rel-bg-surface`), `--rel-avatar-border-outline` (default `--rel-border-default`), `--rel-avatar-color-outline` (default `--rel-text-label`)
93
- - `--rel-stroke-sm` - Border width (all variants; `fill`/`subtle` use a transparent border to keep sizing consistent)
94
-
95
- All of the above semantic tokens (`--rel-bg-*`, `--rel-text-label`, `--rel-border-*`, `--rel-text-disabled`) have dark-mode overrides defined in `vars.css` under `:root[data-theme="dark"]`, so all three variants automatically adapt to dark mode with no extra configuration.
96
-
97
- ## Accessibility
98
- - Image avatars include `alt` attribute for screen readers
99
- - Text is automatically uppercased for consistency
100
- - Ensure meaningful `alt` text is provided for image avatars
101
-
102
- ### Keyboard Interactions
103
- - None (purely presentational)
104
-
105
- ### Focus Behavior
106
- - Does not receive focus
107
-
108
- ## Notes / Edge Cases
109
- - **Size variants**:
110
- - **lg**: 40px × 40px, font-size: `--rel-headings-lg-font-size`
111
- - **md**: 32px × 32px, font-size: `--rel-body-xl-regular-font-size`
112
- - **sm**: 24px × 24px, font-size: `--rel-body-md-regular-font-size`
113
- - **xs**: 18px × 18px, font-size: `--rel-body-xs-regular-font-size`
114
-
115
- - **Display types**:
116
- - **image**: Displays an `<img>` with `src` and `alt`
117
- - Uses `object-fit: cover` for proper image scaling
118
- - Image is `width: 100%`, `height: 100%`
119
- - **text**: Displays the `text` property in a `<span>`
120
- - Text is automatically uppercased via `text-transform: uppercase`
121
- - **icon**: Displays slotted content (typically SVG)
122
- - Slotted SVGs are automatically sized to 50% of the avatar size
123
-
124
- - The avatar is always circular via `border-radius: 50%`
125
- - The avatar uses `overflow: hidden` to clip images to circle shape
126
- - Text and icons are centered using flexbox
127
- - The avatar is `inline-flex` for easy inline usage with text
128
- - The `size` and `type` attributes are reflected in HTML
129
- - The component uses `user-select: none` to prevent text selection
130
- - If `type` is `image` but `src` is empty, nothing is displayed (no fallback)
1
+ # rel-avatar
2
+
3
+ `<rel-avatar>` is the circular identity mark of the Figma "Avatar" component: a 20–40px disc that shows a photo (`type="image"`), uppercase initials (`type="text"`) or a slotted icon (`type="icon"`), in a solid `fill`, a neutral `subtle` or a bordered `outline` variant. Use it wherever a person, team or account needs a compact visual identity — user menus, comment threads, assignee columns, stacked avatar groups. It is purely presentational: it takes no focus and emits no events, so wrap it in a button or link when it should be clickable, and overlay a `rel-badge` when it needs a status or count.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Image avatar (always pass a meaningful alt) -->
9
+ <rel-avatar type="image" src="./user-photo.jpg" alt="Priya Natarajan"></rel-avatar>
10
+
11
+ <!-- Initials -->
12
+ <rel-avatar type="text" text="PN"></rel-avatar>
13
+
14
+ <!-- Slotted icon -->
15
+ <rel-avatar type="icon">
16
+ <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
17
+ <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
18
+ </svg>
19
+ </rel-avatar>
20
+
21
+ <!-- Sizes: xs 20px, sm 24px, md 32px (default), lg 40px -->
22
+ <rel-avatar type="text" text="XS" size="xs"></rel-avatar>
23
+ <rel-avatar type="text" text="SM" size="sm"></rel-avatar>
24
+ <rel-avatar type="text" text="MD" size="md"></rel-avatar>
25
+ <rel-avatar type="text" text="LG" size="lg"></rel-avatar>
26
+
27
+ <!-- Variants -->
28
+ <rel-avatar type="text" text="AA" variant="fill"></rel-avatar>
29
+ <rel-avatar type="text" text="AA" variant="subtle"></rel-avatar>
30
+ <rel-avatar type="text" text="AA" variant="outline"></rel-avatar>
31
+
32
+ <!-- Inline colour overrides (any CSS colour) -->
33
+ <rel-avatar type="text" text="JD" bg="#1d4ed8" color="#ffffff"></rel-avatar>
34
+
35
+ <!-- Stacked group -->
36
+ <div style="display: flex; padding-left: 8px;">
37
+ <rel-avatar type="text" text="A" style="margin-left: -8px;"></rel-avatar>
38
+ <rel-avatar type="text" text="B" style="margin-left: -8px;"></rel-avatar>
39
+ <rel-avatar type="text" text="C" style="margin-left: -8px;"></rel-avatar>
40
+ </div>
41
+ ```
42
+
43
+ <!-- readme-gen:start -->
44
+
45
+ <!-- Generated from rel-avatar.ts — do not edit; run readme-generate.mjs -->
46
+
47
+ ## API
48
+
49
+ ### Attributes / Properties
50
+
51
+ | Property | Attribute | Type | Default | Description |
52
+ | --- | --- | --- | --- | --- |
53
+ | `size` | `size` | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | Diameter step: `lg` 40px, `md` 32px, `sm` 24px, `xs` 20px; each binds the matching body-*-semibold text role for initials. Reflected. |
54
+ | `type` | `type` | `"image" \| "text" \| "icon"` | `"image"` | What is rendered inside the circle: `image` shows `src`, `text` shows the `text` initials, `icon` shows the default slot. Reflected. |
55
+ | `variant` | `variant` | `"fill" \| "subtle" \| "outline"` | `"fill"` | Fill style: `fill` = solid inverse background with light text, `subtle` = elevated neutral background, `outline` = transparent with a 1px border. Reflected. |
56
+ | `src` | `src` | `string` | `""` | Image URL for `type="image"`; when empty nothing is rendered inside the circle (there is no fallback to initials). |
57
+ | `text` | `text` | `string` | `""` | Initials shown for `type="text"`; rendered uppercase via `text-transform`. |
58
+ | `alt` | `alt` | `string` | `"Avatar"` | Alt text of the `<img>` for `type="image"`; the default is the generic word "Avatar", so pass the person's name. |
59
+ | `bg` | `bg` | `string` | `""` | Any CSS colour applied inline as `background-color` on the circle, overriding the variant background. |
60
+ | `color` | `color` | `string` | `""` | Any CSS colour applied inline as `color` on the circle (initials / icon), overriding the variant text colour. |
61
+
62
+ ## Events
63
+
64
+ | Event | Detail | Bubbles / composed | Description |
65
+ | --- | --- | --- | --- |
66
+ | — | — | — | This element emits no custom events. |
67
+
68
+ ## Slots
69
+
70
+ | Slot | Description |
71
+ | --- | --- |
72
+ | (default) | Icon content rendered when `type="icon"` (typically an inline SVG, sized to 50% of the circle) |
73
+
74
+ ## CSS Parts
75
+
76
+ | Part | Description |
77
+ | --- | --- |
78
+ | `base` | The circular wrapper that carries the size, variant and inline `bg` / `color` overrides |
79
+ | `icon` | The `<img>` (`type="image"`) or the icon wrapper span around the slot (`type="icon"`) |
80
+ | `label` | The `<span>` holding the initials when `type="text"` |
81
+
82
+ ## Tokens / CSS Variables
83
+
84
+ ### Component hooks
85
+
86
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
87
+
88
+ | Custom property | Default | Description |
89
+ | --- | --- | --- |
90
+ | `--rel-avatar-bg-fill` | `var(--rel-bg-neutral-inverse-2)` | Background colour of the `fill` variant |
91
+ | `--rel-avatar-bg-subtle` | `var(--rel-bg-neutral-elevated-1)` | Background colour of the `subtle` variant |
92
+ | `--rel-avatar-border-outline` | `var(--rel-border-default)` | 1px border colour of the `outline` variant |
93
+ | `--rel-avatar-color-fill` | `var(--rel-text-inverse)` | Text / icon colour of the `fill` variant |
94
+ | `--rel-avatar-color-outline` | `var(--rel-text-default)` | Text / icon colour of the `outline` variant |
95
+ | `--rel-avatar-color-subtle` | `var(--rel-text-default)` | Text / icon colour of the `subtle` variant |
96
+ | `--rel-avatar-font-size` | `var(--_rel-avatar-font-size)` | Overrides the initials' font-size, for use alongside `--rel-avatar-size`; defaults to the preset's text role |
97
+ | `--rel-avatar-size` | `var(--_rel-avatar-size)` | Overrides the circle's width/height for sizes between (or below) the `size` presets; defaults to the preset's diameter |
98
+
99
+ <!-- readme-gen:end -->
100
+
101
+ ## Accessibility
102
+
103
+ - The host has no ARIA role and no keyboard handling, and it is never focusable. Put it inside a `<button>` or `<a>` when it should be interactive and give that element the accessible name.
104
+ - `type="image"` renders a real `<img>` whose alt text comes from the `alt` prop. The default is the generic word "Avatar" — pass the person's name, or an empty string when the avatar sits next to visible text with the same name.
105
+ - `type="text"` renders the initials as plain text in the `label` part, so screen readers read the letters ("P N"). If the initials alone are meaningless, add `aria-hidden="true"` and keep the full name in nearby text.
106
+ - `type="icon"` slots your SVG unchanged; add `aria-hidden="true"` to decorative icons or a `<title>` to meaningful ones.
107
+ - The three variants differ only by colour; every colour used has a dark-mode value in `vars.css`, so no extra theming is needed.
108
+
109
+ ## Notes / Edge Cases
110
+
111
+ - The disc is `border-radius: 50%` with `overflow: hidden`; images use `object-fit: cover`, so non-square sources are centre-cropped rather than stretched.
112
+ - `type="image"` with an empty `src` renders an empty circle — there is no automatic fallback to initials. Switch `type` yourself when the photo is missing.
113
+ - Every variant keeps a 1px border (`--rel-stroke-sm`); `fill` and `subtle` make it transparent so the outer size is identical across variants.
114
+ - `bg` and `color` are written as inline styles on the `base` part, so they win over both the `--rel-avatar-*` hooks and the variant tokens.
115
+ - Initials are forced uppercase and `user-select: none`. `size`, `type` and `variant` are reflected, so `rel-avatar[size="lg"]` works as a selector.
116
+ - The `icon` part name is shared by the `<img>` (`type="image"`) and the slot wrapper (`type="icon"`); `::part(icon)` matches whichever one is rendered.
@@ -1,93 +1,98 @@
1
- # rel-badge
2
-
3
- ## Overview
4
- A simple notification badge component displaying numeric counts or dot indicators. Supports three sizes (sm, md, lg) and two variants (number, dot). Ideal for indicating counts, status, or notifications in UI elements.
5
-
6
- ## Usage
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
- <!-- Dot badges (no number shown) -->
14
- <rel-badge variant="dot" size="sm"></rel-badge>
15
- <rel-badge variant="dot" size="md"></rel-badge>
16
- <rel-badge variant="dot" size="lg"></rel-badge>
17
-
18
- <!-- Common use case: Badge on icon/button -->
19
- <div style="position: relative; display: inline-block;">
20
- <button>🔔 Notifications</button>
21
- <rel-badge number="3" size="sm" style="position: absolute; top: -8px; right: -8px;"></rel-badge>
22
- </div>
23
-
24
- <!-- Sizes comparison -->
25
- <rel-badge number="1" size="sm"></rel-badge>
26
- <rel-badge number="2" size="md"></rel-badge>
27
- <rel-badge number="3" size="lg"></rel-badge>
28
-
29
- <!-- Custom colors -->
30
- <rel-badge number="3" color="#7d7d7d"></rel-badge>
31
- <rel-badge number="3" color="teal" text-color="#1a1a1a"></rel-badge>
32
- <rel-badge variant="dot" color="lavender"></rel-badge>
33
- ```
34
-
35
- ## API
36
-
37
- ### Attributes/Properties
38
- | Name | Type | Default | Description |
39
- |------|------|---------|-------------|
40
- | `number` | `string` | `""` | Text to display in number variant (can be numeric or text like "99+") |
41
- | `size` | `"sm" \| "md" \| "lg"` (reflected) | `"md"` | Size variant |
42
- | `variant` | `"dot" \| "number"` (reflected) | `"number"` | Display mode (number shows text, dot shows indicator only) |
43
- | `color` | `string` (reflected) | `""` | Direct CSS color override for the badge background. Accepts any valid CSS color (hex, rgb, hsl, named, `var(...)`). Falls back to the default token when empty |
44
- | `text-color` | `string` (reflected) | `""` | Direct CSS color override for the badge text/icon color. Accepts any valid CSS color. Falls back to white when empty |
45
-
46
- ## Events
47
- None.
48
-
49
- ## Slots
50
- Default slot not used.
51
-
52
- ## CSS Parts
53
- None exposed.
54
-
55
- ## Tokens / CSS Variables
56
-
57
- ### Semantic Tokens
58
- - `--rel-fonts-font-family` - Font family
59
- - `--rel-fonts-weight-body-semibold` - Font weight (number variant)
60
- - `--rel-body-xs-regular-font-size`, `--rel-body-sm-regular-font-size`, `--rel-body-xl-regular-font-size` - Font sizes for number variant sizes
61
-
62
- ### Color Tokens
63
- - `--rel-bg-danger` - Background color
64
- - `--rel-bg-surface` - Text color
65
-
66
- ## Accessibility
67
- - Purely visual indicator (no ARIA roles)
68
- - For critical information, ensure accompanying text or ARIA labels on parent elements
69
- - Screen readers will not announce badge content unless used with proper labeling
70
-
71
- ### Keyboard Interactions
72
- - None (not focusable)
73
-
74
- ### Focus Behavior
75
- - Not focusable
76
-
77
- ## Notes / Edge Cases
78
- - **Number variant sizes**:
79
- - **sm**: 20px × 20px, 12px font
80
- - **md**: 28px × 28px, 14px font
81
- - **lg**: 40px × 40px, 20px font
82
- - **Dot variant sizes**:
83
- - **sm**: 8px × 8px
84
- - **md**: 10px × 10px
85
- - **lg**: 12px × 12px
86
- - All badges are circular (`border-radius: 50%`)
87
- - The `number` property accepts any string (e.g., "99+", "NEW", or numeric values)
88
- - In dot variant, the `number` property is ignored and nothing is rendered inside
89
- - The component is `display: inline-flex` for easy positioning
90
- - Badges use `justify-content: center` and `align-items: center` for centering content
91
- - `size` and `variant` are reflected attributes (appear in HTML when set)
92
- - Common pattern: position badges absolutely over parent elements (e.g., icons, avatar images)
93
- - For very large numbers, consider truncating or using "99+" format to avoid overflow
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" size="sm"></rel-badge>
16
+ <rel-badge variant="dot" size="md"></rel-badge>
17
+ <rel-badge variant="dot" size="lg"></rel-badge>
18
+
19
+ <!-- Positioned over an icon button -->
20
+ <div style="position: relative; display: inline-block;">
21
+ <button aria-label="Notifications">🔔</button>
22
+ <rel-badge number="3" size="sm" style="position: absolute; top: -8px; right: -8px;"></rel-badge>
23
+ </div>
24
+
25
+ <!-- Accessible-name control -->
26
+ <rel-badge number="3" suffix="unread messages"></rel-badge>
27
+ <rel-badge variant="dot" arialabel="New activity"></rel-badge>
28
+
29
+ <!-- Colour overrides: any CSS colour, including a token via var() -->
30
+ <rel-badge number="3" color="#7d7d7d"></rel-badge>
31
+ <rel-badge number="3" color="teal" text-color="#1a1a1a"></rel-badge>
32
+ <rel-badge variant="dot" color="seagreen"></rel-badge>
33
+ ```
34
+
35
+ <!-- readme-gen:start -->
36
+
37
+ <!-- Generated from rel-badge.ts — do not edit; run readme-generate.mjs -->
38
+
39
+ ## API
40
+
41
+ ### Attributes / Properties
42
+
43
+ | Property | Attribute | Type | Default | Description |
44
+ | --- | --- | --- | --- | --- |
45
+ | `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. |
46
+ | `ariaLabel` | `arialabel` | `string` | `""` | Explicit accessible name; when empty it is composed as "<number> <suffix>" or, with no number, "New <suffix>". Attribute is `arialabel`. |
47
+ | `suffix` | `suffix` | `string` | `"notifications"` | Noun appended to the count in the generated accessible name, e.g. "3 notifications". |
48
+ | `size` | `size` | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Badge scale (Figma Badge S/M/L/XL): number badges are 20 / 24 / 28 / 40px tall, dot badges 8 / 10 / 12 / 12px. Reflected. |
49
+ | `variant` | `variant` | `"dot" \| "number"` | `"number"` | `number` renders the `number` text in a pill that widens with its content; `dot` renders a small disc with no text. Reflected. |
50
+ | `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. |
51
+ | `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. |
52
+
53
+ ## Events
54
+
55
+ | Event | Detail | Bubbles / composed | Description |
56
+ | --- | --- | --- | --- |
57
+ | — | — | — | This element emits no custom events. |
58
+
59
+ ## Slots
60
+
61
+ | Slot | Description |
62
+ | --- | --- |
63
+ | — | This element has no slots. |
64
+
65
+ ## CSS Parts
66
+
67
+ | Part | Description |
68
+ | --- | --- |
69
+ | `base` | The `role="status"` pill / dot that carries the size, variant and colour overrides |
70
+
71
+ ## Tokens / CSS Variables
72
+
73
+ ### Component hooks
74
+
75
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
76
+
77
+ | Custom property | Default | Description |
78
+ | --- | --- | --- |
79
+ | `--rel-badge-bg` | `var(--rel-bg-danger)` | Background colour of the badge; the `color` prop writes this on the host |
80
+ | `--rel-badge-color` | `var(--rel-text-static-light)` | Text colour of the count; the `text-color` prop writes this on the host |
81
+
82
+ <!-- readme-gen:end -->
83
+
84
+ ## Accessibility
85
+
86
+ - 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.
87
+ - `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.
88
+ - 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.
89
+ - 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.
90
+
91
+ ## Notes / Edge Cases
92
+
93
+ - 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.
94
+ - The corner radius is a fixed `999px`, not `50%`, which is what lets wide content become a pill instead of clipping.
95
+ - In `variant="dot"` the `number` text is not rendered but still feeds the accessible name ("3 notifications" for a dot with `number="3"`).
96
+ - `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).
97
+ - 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`.
98
+ - The host is `display: inline-flex`; the usual pattern is an absolutely positioned badge inside a `position: relative` wrapper around the decorated element.