@reliability-design/web 1.4.5 → 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 (142) 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 -135
  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 -103
  42. package/dist/components/rel-upload/README.md +220 -0
  43. package/dist/index.d.mts +1387 -350
  44. package/dist/index.d.ts +1387 -350
  45. package/dist/index.js +5863 -3600
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +5864 -3592
  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 +4 -3
  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 -689
  55. package/dist/components/rel-avatar/rel-avatar.ts +0 -142
  56. package/dist/components/rel-badge/rel-badge.ts +0 -170
  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 -519
  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 -700
  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 -472
  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/index.ts +0 -1
  74. package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1237
  75. package/dist/components/rel-divider/rel-divider.ts +0 -54
  76. package/dist/components/rel-drawer/index.ts +0 -1
  77. package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
  78. package/dist/components/rel-drawer/rel-drawer.ts +0 -604
  79. package/dist/components/rel-kbd/rel-kbd.ts +0 -188
  80. package/dist/components/rel-layout/rel-layout.ts +0 -49
  81. package/dist/components/rel-menu/rel-menu.ts +0 -535
  82. package/dist/components/rel-menubar/index.ts +0 -2
  83. package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
  84. package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
  85. package/dist/components/rel-menubar/rel-menubar.ts +0 -777
  86. package/dist/components/rel-nav-menu/README.md +0 -289
  87. package/dist/components/rel-nav-menu/index.ts +0 -3
  88. package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
  89. package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
  90. package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
  91. package/dist/components/rel-navbar/README.md +0 -126
  92. package/dist/components/rel-navbar/rel-navbar.ts +0 -105
  93. package/dist/components/rel-otp/index.ts +0 -1
  94. package/dist/components/rel-otp/rel-otp.ts +0 -517
  95. package/dist/components/rel-pagination/index.ts +0 -1
  96. package/dist/components/rel-pagination/rel-pagination.ts +0 -509
  97. package/dist/components/rel-popover/index.ts +0 -2
  98. package/dist/components/rel-popover/rel-popover-content.ts +0 -81
  99. package/dist/components/rel-popover/rel-popover.ts +0 -444
  100. package/dist/components/rel-progress/rel-progress.ts +0 -225
  101. package/dist/components/rel-radio/rel-radio.ts +0 -305
  102. package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1331
  103. package/dist/components/rel-resizable/index.ts +0 -3
  104. package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
  105. package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
  106. package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
  107. package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -213
  108. package/dist/components/rel-select/rel-select.ts +0 -1385
  109. package/dist/components/rel-sheet/rel-sheet.ts +0 -465
  110. package/dist/components/rel-sidebar/README.md +0 -209
  111. package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1185
  112. package/dist/components/rel-skeleton/rel-skeleton.ts +0 -134
  113. package/dist/components/rel-slider/rel-slider.ts +0 -670
  114. package/dist/components/rel-snackbar/rel-snackbar.ts +0 -325
  115. package/dist/components/rel-stepper/rel-stepper.ts +0 -565
  116. package/dist/components/rel-switch/rel-switch.ts +0 -197
  117. package/dist/components/rel-tab/rel-tab.ts +0 -264
  118. package/dist/components/rel-table/README.md +0 -178
  119. package/dist/components/rel-table/rel-table-body.ts +0 -22
  120. package/dist/components/rel-table/rel-table-caption.ts +0 -30
  121. package/dist/components/rel-table/rel-table-cell.ts +0 -43
  122. package/dist/components/rel-table/rel-table-footer.ts +0 -24
  123. package/dist/components/rel-table/rel-table-head.ts +0 -47
  124. package/dist/components/rel-table/rel-table-header.ts +0 -22
  125. package/dist/components/rel-table/rel-table-row.ts +0 -37
  126. package/dist/components/rel-table/rel-table.ts +0 -62
  127. package/dist/components/rel-textfield/rel-textfield.ts +0 -866
  128. package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1126
  129. package/dist/components/rel-toast/rel-toast.ts +0 -204
  130. package/dist/components/rel-tooltip/rel-tooltip.ts +0 -190
  131. package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
  132. package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
  133. package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
  134. package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
  135. package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
  136. package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
  137. package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
  138. package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
  139. package/dist/components/rel-topbar/rel-topbar.ts +0 -446
  140. package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
  141. package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
  142. package/dist/components/rel-upload/rel-upload.ts +0 -943
@@ -1,109 +1,109 @@
1
- # rel-calendar
2
-
3
- A fully accessible calendar component built with Lit for the Reliability Design System.
4
-
5
- ## Features
6
-
7
- - Single date selection
8
- - Month navigation
9
- - Keyboard navigation support (arrow keys, Home/End, PageUp/PageDown)
10
- - Min/max date constraints
11
- - Custom disabled date predicate
12
- - Configurable week start (Sunday or Monday)
13
- - Locale-aware month names
14
- - Today indicator
15
- - Full ARIA support
16
-
17
- ## Usage
18
-
19
- ```html
20
- <rel-calendar></rel-calendar>
21
- ```
22
-
23
- ### With value
24
-
25
- ```html
26
- <rel-calendar value="2026-01-16"></rel-calendar>
27
- ```
28
-
29
- ### With min/max
30
-
31
- ```html
32
- <rel-calendar
33
- min="2026-01-01"
34
- max="2026-12-31"
35
- ></rel-calendar>
36
- ```
37
-
38
- ### Week starting Monday
39
-
40
- ```html
41
- <rel-calendar week-start="mon"></rel-calendar>
42
- ```
43
-
44
- ### Disabled
45
-
46
- ```html
47
- <rel-calendar disabled></rel-calendar>
48
- ```
49
-
50
- ### Custom disabled dates (JavaScript)
51
-
52
- ```javascript
53
- const calendar = document.querySelector('rel-calendar');
54
-
55
- // Disable weekends
56
- calendar.isDateDisabled = (date) => {
57
- const day = date.getDay();
58
- return day === 0 || day === 6; // Sunday or Saturday
59
- };
60
-
61
- // Listen to changes
62
- calendar.addEventListener('rel-change', (e) => {
63
- console.log('Selected date:', e.detail.value); // "2026-01-16"
64
- console.log('Selected date object:', e.detail.date); // Date object
65
- });
66
- ```
67
-
68
- ## Attributes
69
-
70
- | Attribute | Type | Default | Description |
71
- |-----------|------|---------|-------------|
72
- | `value` | `string \| null` | `null` | Selected date in ISO format (YYYY-MM-DD) |
73
- | `min` | `string \| null` | `null` | Minimum selectable date (ISO format) |
74
- | `max` | `string \| null` | `null` | Maximum selectable date (ISO format) |
75
- | `disabled` | `boolean` | `false` | Disables all interaction |
76
- | `week-start` | `"sun" \| "mon"` | `"sun"` | First day of the week |
77
- | `locale` | `string` | `"en-US"` | Locale for month names (uses Intl.DateTimeFormat) |
78
-
79
- ## Properties
80
-
81
- | Property | Type | Description |
82
- |----------|------|-------------|
83
- | `isDateDisabled` | `(date: Date) => boolean` | Custom function to disable specific dates |
84
-
85
- ## Events
86
-
87
- | Event | Detail | Description |
88
- |-------|--------|-------------|
89
- | `rel-change` | `{ value: string \| null, date: Date \| null }` | Fired when selection changes |
90
-
91
- ## Keyboard Navigation
92
-
93
- - **Arrow keys**: Move focus by day (left/right) and week (up/down)
94
- - **Home/End**: Jump to start/end of current week
95
- - **PageUp/PageDown**: Change month
96
- - **Shift + PageUp/PageDown**: Change year
97
- - **Enter/Space**: Select focused day
98
-
99
- ## Styling
100
-
101
- The component uses design tokens from the Reliability Design System. All colors, spacing, and typography are inherited from CSS variables.
102
-
103
- Key tokens used:
104
- - `--rel-bg-*` / `--rel-text-*` / `--rel-border-*` semantic colors
105
- - `--rel-spacing-*` for spacing
106
- - `--rel-body-*` / `--rel-headings-*` composite typography roles
107
- - `--rel-border-radius-*` for border radius
108
- - Focus outline uses `--rel-bg-info`
109
- - Selected state uses `--rel-bg-brand`
1
+ # rel-calendar
2
+
3
+ `<rel-calendar>` is the inline, always-visible month calendar of the Reliability Design System (Figma "Calendar"). It renders one month as a 7-column grid with previous/next navigation, a today ring, dimmed weekends and adjacent-month days, `min`/`max` bounds and a custom disabled-day predicate, and lets the user select a single date. Use it when the calendar itself is the interface — a scheduling sidebar, an inline availability view. For a form field that opens a calendar in a popover use `<rel-date-picker>`; for a from/to range use `<rel-range-picker>`.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Default: today's month, nothing selected -->
9
+ <rel-calendar></rel-calendar>
10
+
11
+ <!-- Preselected date (ISO YYYY-MM-DD); the grid opens on that month -->
12
+ <rel-calendar value="2026-01-16"></rel-calendar>
13
+
14
+ <!-- Bounded: days outside min/max render disabled -->
15
+ <rel-calendar min="2026-01-01" max="2026-12-31"></rel-calendar>
16
+
17
+ <!-- Monday-first week with German month and weekday names -->
18
+ <rel-calendar week-start="mon" locale="de-DE"></rel-calendar>
19
+
20
+ <!-- Disabled: every cell and both navigation buttons are inert -->
21
+ <rel-calendar value="2026-01-16" disabled></rel-calendar>
22
+ ```
23
+
24
+ ```js
25
+ const calendar = document.querySelector("rel-calendar");
26
+
27
+ // Disable individual days on top of min/max (property only — there is no attribute)
28
+ calendar.isDateDisabled = (date) => date.getDay() === 0 || date.getDay() === 6;
29
+
30
+ calendar.addEventListener("rel-change", (e) => {
31
+ e.detail.value; // "2026-01-16"
32
+ e.detail.date; // Date at local midnight
33
+ });
34
+ ```
35
+
36
+ <!-- readme-gen:start -->
37
+
38
+ <!-- Generated from rel-calendar.ts — do not edit; run readme-generate.mjs -->
39
+
40
+ ## API
41
+
42
+ ### Attributes / Properties
43
+
44
+ | Property | Attribute | Type | Default | Description |
45
+ | --- | --- | --- | --- | --- |
46
+ | `value` | `value` | `string \| null` | `null` | Selected date as an ISO `YYYY-MM-DD` string, or `null` for no selection; setting it also moves the visible month. Reflected. |
47
+ | `min` | `min` | `string \| null` | `null` | Earliest selectable date (ISO `YYYY-MM-DD`); earlier days render disabled. |
48
+ | `max` | `max` | `string \| null` | `null` | Latest selectable date (ISO `YYYY-MM-DD`); later days render disabled. |
49
+ | `disabled` | `disabled` | `boolean` | `false` | Disables every day cell and the month navigation; the host dims to 40% opacity (Figma State=Disabled). Reflected. |
50
+ | `weekStart` | `week-start` | `"sun" \| "mon"` | `"sun"` | First column of the week grid: `"sun"` (default) or `"mon"`. |
51
+ | `locale` | `locale` | `string` | `"en-US"` | BCP 47 locale for the month name, weekday headers and day cell labels (via `Intl.DateTimeFormat`). |
52
+
53
+ ### Public fields / accessors
54
+
55
+ | Name | Type | Description |
56
+ | --- | --- | --- |
57
+ | `isDateDisabled` | `(date: Date) => boolean` | Custom predicate that disables individual days (return `true` to disable); applied on top of `min`/`max`. Property only — assign it from JavaScript. |
58
+
59
+ ## Events
60
+
61
+ | Event | Detail | Bubbles / composed | Description |
62
+ | --- | --- | --- | --- |
63
+ | `rel-change` | `{ value: newValue, date: new Date(day.date), }` | bubbles / composed | Fired when the user selects a day. Detail: `{ value: string, date: Date }` — the ISO `YYYY-MM-DD` string and a local-midnight Date. |
64
+
65
+ ## Slots
66
+
67
+ | Slot | Description |
68
+ | --- | --- |
69
+ | — | This element has no slots. |
70
+
71
+ ## CSS Parts
72
+
73
+ | Part | Description |
74
+ | --- | --- |
75
+ | `header` | Month navigation row (previous button, month/year label, next button) |
76
+ | `action` | The previous-month and next-month buttons |
77
+ | `label` | The month/year heading and each weekday column header |
78
+ | `list` | The weekday-header row and the day grid |
79
+ | `item` | Each day cell button |
80
+
81
+ <!-- readme-gen:end -->
82
+
83
+ ## Accessibility
84
+
85
+ - The day area is a `role="grid"` named "<Month> <Year>" (e.g. "January 2026"); the weekday header row and each week are `role="row"`, weekday names are `role="columnheader"`.
86
+ - Every day is a native `<button role="gridcell">` whose `aria-label` is the full long date in `locale` ("Friday, January 16, 2026"), with `aria-selected` for the selected day, `aria-current="date"` on today, and the native `disabled` attribute for days outside `min`/`max`, rejected by `isDateDisabled`, or when the host is `disabled`.
87
+ - The navigation buttons are labelled "Previous month" / "Next month".
88
+ - Roving tabindex: exactly one cell is a Tab stop — the last cell the user arrowed to, else the selected day, else today, else the first enabled day of the month — so Tab can always re-enter the grid.
89
+ - After every month or year change (buttons, PageUp/PageDown, or arrowing past the edge of the month) the new "<Month> <Year>" is read to screen readers through the shared `announce()` live region (`utils/announce.ts`).
90
+
91
+ | Key | Action |
92
+ | --- | --- |
93
+ | ArrowLeft / ArrowRight | Focus the previous / next day (crossing into the adjacent month switches the view) |
94
+ | ArrowUp / ArrowDown | Focus the same weekday one week earlier / later |
95
+ | Home / End | Focus the first / last cell of the current row |
96
+ | PageUp / PageDown | Show the previous / next month |
97
+ | Shift + PageUp / Shift + PageDown | Show the previous / next year |
98
+ | Enter / Space | Select the focused day (fires `rel-change`) |
99
+
100
+ ## Notes / Edge Cases
101
+
102
+ - `value`, `min` and `max` must be `YYYY-MM-DD`; any other string is ignored (no selection, view unchanged). Setting `value` moves the visible month; clearing it to `null` leaves the view where it is.
103
+ - The grid always renders six weeks (42 cells). The leading/trailing cells belong to the adjacent months and, unlike in `rel-date-picker`, they are selectable (subject to `min`/`max`/`isDateDisabled`); picking one fires `rel-change` and the view jumps to that month.
104
+ - Comparisons happen at local midnight: the `Date` passed to `isDateDisabled` and returned in `rel-change` is `new Date(y, m, d)`, so read it with local getters, not `toISOString()`.
105
+ - `disabled` makes every day fail the disabled check and disables both navigation buttons; pointer events stay on the host so the `not-allowed` cursor shows.
106
+ - Each cell follows Figma ".Date Days": a 36 px full-rounded halo around a 28 px disc. The halo carries hover (`action/overlay/hover`), the focus ring and the selected day's `elevated-1` backing; the disc carries today's 1 px brand ring and the selected day's `inverse-2` fill with an inverse semibold label.
107
+ - Figma treats the cell tone as one axis, so exactly one applies per day: today beats weekend beats adjacent-month. Adjacent-month labels render at 40% and weekend labels at 70% — on the label only, so a *selected* weekend or adjacent-month day still reads at full contrast on the dark disc. A disabled day switches to the disabled text colour, and a disabled today swaps its brand ring for a neutral one.
108
+ - The month-navigation buttons are hand-rolled ghost buttons that bind the same action tokens as `<rel-button variant="ghost">` (audit 8b) — they are intentionally not `<rel-button>` instances.
109
+ - The host has a fixed `max-width: 320px`, its own radius, shadow and padding and no border (Figma draws the card with `shadow/xl`, approximated here by `--rel-shadows-shadow-400`, the nearest shipped step); wrap it or override on the host if you need a different footprint.
@@ -1,94 +1,75 @@
1
- # rel-card
2
-
3
- ## Overview
4
- A simple, versatile card container component with built-in elevation shadow and hover lift effect. Provides a clean, elevated surface for grouping related content. Respects user motion preferences by disabling animations when requested.
5
-
6
- ## Usage
7
- ```html
8
- <!-- Basic card with text content -->
9
- <rel-card>
10
- <h3>Card Title</h3>
11
- <p>This is some content inside the card.</p>
12
- </rel-card>
13
-
14
- <!-- Card with mixed content -->
15
- <rel-card>
16
- <h2>Product Name</h2>
17
- <img src="product.jpg" alt="Product" style="width: 100%; border-radius: 8px;">
18
- <p>Product description goes here.</p>
19
- <button>Add to Cart</button>
20
- </rel-card>
21
-
22
- <!-- Multiple cards in a grid -->
23
- <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;">
24
- <rel-card>
25
- <h4>Feature 1</h4>
26
- <p>Description of feature 1</p>
27
- </rel-card>
28
- <rel-card>
29
- <h4>Feature 2</h4>
30
- <p>Description of feature 2</p>
31
- </rel-card>
32
- <rel-card>
33
- <h4>Feature 3</h4>
34
- <p>Description of feature 3</p>
35
- </rel-card>
36
- </div>
37
- ```
38
-
39
- ## API
40
-
41
- ### Attributes/Properties
42
- None. This component is purely presentational and controlled via slots.
43
-
44
- ## Events
45
- None.
46
-
47
- ## Slots
48
- | Slot | Description |
49
- |------|-------------|
50
- | (default) | Card content (any HTML elements) |
51
-
52
- ## CSS Parts
53
- None exposed.
54
-
55
- ## Tokens / CSS Variables
56
-
57
- ### Semantic Tokens
58
- - `--rel-fonts-font-family` - Font family
59
-
60
- ### Color Tokens
61
- - `--rel-bg-surface` - Card background color
62
- - `--rel-text-default` - Text color
63
-
64
- ### Shadow Tokens
65
- - `--rel-shadows-shadow-200` - Default elevation shadow
66
- - `--rel-shadows-shadow-300` - Hover elevation shadow (larger)
67
-
68
- ### Border Tokens
69
- - `--rel-border-radius-md` - Card border radius
70
-
71
- ### Spacing Tokens
72
- - `--rel-spacing-md` - Internal padding
73
-
74
- ## Accessibility
75
- - The card itself has no specific ARIA role (it's a generic container)
76
- - Ensure slotted content includes proper semantic HTML and ARIA attributes where needed
77
- - Hover effect is purely visual and does not affect accessibility
78
-
79
- ### Keyboard Interactions
80
- - None (purely presentational container)
81
-
82
- ### Focus Behavior
83
- - Does not receive focus (container only)
84
- - Ensure slotted interactive elements are keyboard accessible
85
-
86
- ## Notes / Edge Cases
87
- - The card is `display: block` and takes full width of its container by default
88
- - **Hover effect**: Translates the card upward by 3px (`translateY(-3px)`) and increases shadow depth
89
- - **Animation**: Uses `transition: transform 0.2s ease, box-shadow 0.2s ease`
90
- - **Motion preferences**: When `prefers-reduced-motion: reduce`, both hover transform and transitions are disabled
91
- - The card has consistent padding on all sides via `--rel-spacing-md`
92
- - The internal `.card` wrapper is where all styling is applied
93
- - The component provides no default content styling—you control the layout of slotted elements
94
- - Works well with CSS Grid or Flexbox for creating card layouts
1
+ # rel-card
2
+
3
+ `<rel-card>` is a bordered, padded surface that groups related content — the Figma "Card" component. `type="custom"` (the default) pads whatever you slot in and applies the Figma card typography to slotted headings and paragraphs; `type="media"` adds a flush media region above the body, meant for a `<rel-card-media>` image header. Use it for dashboard tiles, summary blocks and list items that pair a title with body copy. It is a static container with no interaction of its own — for transient content use `rel-modal` or `rel-drawer` instead, and for a surface with its own tone/elevation variants use `rel-container`.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Default type: padded body -->
9
+ <rel-card>
10
+ <h3>Shipment 4821</h3>
11
+ <p>Departed Dallas · ETA Thursday 14:00</p>
12
+ </rel-card>
13
+
14
+ <!-- Media type: flush image header via <rel-card-media> in the "media" slot -->
15
+ <rel-card type="media">
16
+ <rel-card-media slot="media" image-src="/img/warehouse.jpg" image-alt="Warehouse floor"></rel-card-media>
17
+ <h3>Dallas hub</h3>
18
+ <p>12 dock doors · 24/7 operations</p>
19
+ </rel-card>
20
+
21
+ <!-- Cards in a grid -->
22
+ <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;">
23
+ <rel-card><h4>On time</h4><p>98.2%</p></rel-card>
24
+ <rel-card><h4>Damage-free</h4><p>99.7%</p></rel-card>
25
+ <rel-card><h4>Claims</h4><p>3 open</p></rel-card>
26
+ </div>
27
+ ```
28
+
29
+ <!-- readme-gen:start -->
30
+
31
+ <!-- Generated from rel-card.ts — do not edit; run readme-generate.mjs -->
32
+
33
+ ## API
34
+
35
+ ### Attributes / Properties
36
+
37
+ | Property | Attribute | Type | Default | Description |
38
+ | --- | --- | --- | --- | --- |
39
+ | `type` | `type` | `"custom" \| "media"` | `"custom"` | Figma "Type" axis: custom (default) renders slotted content with card padding; media adds a flush media region (slot name="media") above the content — pair it with <rel-card-media>. Reflected. |
40
+
41
+ ## Events
42
+
43
+ | Event | Detail | Bubbles / composed | Description |
44
+ | --- | --- | --- | --- |
45
+ | — | — | — | This element emits no custom events. |
46
+
47
+ ## Slots
48
+
49
+ | Slot | Description |
50
+ | --- | --- |
51
+ | (default) | Card body; slotted headings and paragraphs receive the Figma card typography |
52
+ | `media` | Flush media region above the body; rendered only when `type="media"` |
53
+
54
+ ## CSS Parts
55
+
56
+ | Part | Description |
57
+ | --- | --- |
58
+ | `base` | The outer bordered card surface |
59
+ | `header` | The media region wrapper (present only when `type="media"`) |
60
+ | `content` | The padded body that wraps the default slot |
61
+
62
+ <!-- readme-gen:end -->
63
+
64
+ ## Accessibility
65
+
66
+ - The card sets no ARIA role — it is a generic container (`display: block`), so the accessible structure comes entirely from the slotted content. Use real headings (`<h2>`–`<h4>`) and paragraphs inside it; they also pick up the card typography.
67
+ - The host is not focusable and has no keyboard handling. Interactive children (links, `rel-button`) keep their own focus order and must be keyboard-reachable on their own.
68
+ - A `<rel-card-media>` in the `media` slot carries the image's alt text via its `image-alt` attribute; leave it empty only for purely decorative imagery.
69
+
70
+ ## Notes / Edge Cases
71
+
72
+ - `type="media"` removes the card's own padding and clips overflow so the media sits flush against the rounded border; the body (`content` part) keeps the standard padding. Content placed in the `media` slot without `type="media"` is not rendered, because the slot only exists in that mode.
73
+ - The `header` part exists only while `type="media"`; `::part(header)` matches nothing otherwise.
74
+ - Slotted `h1`–`h4` and `p` elements get the Figma card roles (heading md / body lg) with their default margins reset; wrap other content in your own elements to style it.
75
+ - There is no hover lift, shadow or transition — the card is a flat bordered surface in both light and dark themes.
@@ -1,127 +1,100 @@
1
- # rel-card-media
2
-
3
- ## Overview
4
- A media-rich card component combining an image, title, subtitle, and custom content area. Features automatic image sizing with object-fit, enhanced hover lift effect (4px), and semantic heading structure. Ideal for blog posts, product listings, or media galleries.
5
-
6
- ## Usage
7
- ```html
8
- <!-- Basic media card -->
9
- <rel-card-media
10
- imageSrc="./photo.jpg"
11
- imageAlt="Beautiful landscape"
12
- title="Card Title"
13
- subtitle="Card subtitle or description">
14
- </rel-card-media>
15
-
16
- <!-- With custom slotted content -->
17
- <rel-card-media
18
- imageSrc="./product.jpg"
19
- imageAlt="Product image"
20
- title="Premium Product"
21
- subtitle="$99.99">
22
- <p>Additional product details go here.</p>
23
- <button>Buy Now</button>
24
- </rel-card-media>
25
-
26
- <!-- Without image -->
27
- <rel-card-media
28
- title="Text-Only Card"
29
- subtitle="No image provided">
30
- <p>This card has no image, just title, subtitle, and content.</p>
31
- </rel-card-media>
32
-
33
- <!-- With title only -->
34
- <rel-card-media
35
- imageSrc="./banner.jpg"
36
- imageAlt="Banner"
37
- title="Event Title">
38
- <p>Event description and details.</p>
39
- </rel-card-media>
40
-
41
- <!-- Gallery layout -->
42
- <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;">
43
- <rel-card-media
44
- imageSrc="./img1.jpg"
45
- title="Gallery Item 1">
46
- </rel-card-media>
47
- <rel-card-media
48
- imageSrc="./img2.jpg"
49
- title="Gallery Item 2">
50
- </rel-card-media>
51
- <rel-card-media
52
- imageSrc="./img3.jpg"
53
- title="Gallery Item 3">
54
- </rel-card-media>
55
- </div>
56
- ```
57
-
58
- ## API
59
-
60
- ### Attributes/Properties
61
- | Name | Type | Default | Description |
62
- |------|------|---------|-------------|
63
- | `imageSrc` | `string` | `""` | URL of the card image (optional) |
64
- | `imageAlt` | `string` | `"Card image"` | Alt text for the image (for accessibility) |
65
- | `title` | `string` | `""` | Card title displayed as `<h3>` (optional) |
66
- | `subtitle` | `string` | `""` | Card subtitle displayed as `<p>` (optional) |
67
-
68
- ## Events
69
- None.
70
-
71
- ## Slots
72
- | Slot | Description |
73
- |------|-------------|
74
- | (default) | Additional content rendered below title and subtitle |
75
-
76
- ## CSS Parts
77
- None exposed.
78
-
79
- ## Tokens / CSS Variables
80
-
81
- ### Semantic Tokens
82
- - `--rel-fonts-font-family` - Font family
83
- - `--rel-body-md-regular-font-size` - Title font size
84
- - `--rel-body-sm-regular-font-size` - Subtitle font size
85
- - `--rel-fonts-weight-body-semibold` - Title font weight
86
-
87
- ### Color Tokens
88
- - `--rel-bg-surface` - Card background color
89
- - `--rel-text-default` - General text color
90
- - `--rel-text-label` - Title color
91
-
92
- ### Shadow Tokens
93
- - `--rel-shadows-shadow-200` - Default elevation shadow
94
- - `--rel-shadows-shadow-300` - Hover elevation shadow (larger)
95
-
96
- ### Border Tokens
97
- - `--rel-border-radius-md` - Card border radius
98
-
99
- ### Spacing Tokens
100
- - `--rel-spacing-md` - Content area padding
101
-
102
- ## Accessibility
103
- - Image has `alt` attribute for screen reader support
104
- - Title uses semantic `<h3>` heading
105
- - Subtitle uses `<p>` for proper text hierarchy
106
- - Hover effect is purely visual and does not affect accessibility
107
-
108
- ### Keyboard Interactions
109
- - None (purely presentational container)
110
- - Ensure slotted interactive elements are keyboard accessible
111
-
112
- ### Focus Behavior
113
- - Does not receive focus (container only)
114
-
115
- ## Notes / Edge Cases
116
- - **Image rendering**: If `imageSrc` is not provided or empty, the image section is not rendered
117
- - **Image sizing**: The image uses `width: 100%`, `height: auto`, and `object-fit: cover` for responsive scaling
118
- - The image is `display: block` to remove default inline spacing
119
- - **Title and subtitle**: Both are optional; if not provided, their respective elements are not rendered
120
- - Title has `margin: 0 0 4px 0` for spacing from subtitle
121
- - Subtitle has `margin: 0 0 8px 0` for spacing from slotted content
122
- - **Hover effect**: Translates the card upward by 4px (`translateY(-4px)`) and increases shadow depth (1px more than rel-card)
123
- - **Animation**: Uses `transition: transform 0.2s ease, box-shadow 0.2s ease`
124
- - **Motion preferences**: When `prefers-reduced-motion: reduce`, both hover transform and transitions are disabled
125
- - The card uses `overflow: hidden` to ensure image respects border radius
126
- - The `.card-content` wrapper provides consistent padding for title, subtitle, and slotted content
127
- - The component is `display: block` and takes full width of its container
1
+ # rel-card-media
2
+
3
+ Media card (element `<rel-card-media>`, folder `rel-cardmedia`): a bordered surface with an optional full-width image on top, then a title (`<h3>`), a subtitle and a slotted body inside a padded content area. Use it for previews that lead with an image — articles, products, gallery tiles. Use `rel-card` when you need a free-form layout or no image section.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Image, title, subtitle -->
9
+ <rel-card-media
10
+ image-src="/images/lake.jpg"
11
+ image-alt="A mountain lake at sunrise"
12
+ title="Alpine lakes"
13
+ subtitle="12 photos"
14
+ ></rel-card-media>
15
+
16
+ <!-- With slotted body content -->
17
+ <rel-card-media
18
+ image-src="/images/headphones.jpg"
19
+ image-alt="Over-ear headphones"
20
+ title="Studio headphones"
21
+ subtitle="$99.99"
22
+ >
23
+ <p>Closed-back, 40 mm drivers, detachable cable.</p>
24
+ <rel-button variant="primary" size="small">Add to cart</rel-button>
25
+ </rel-card-media>
26
+
27
+ <!-- No image: just the content area -->
28
+ <rel-card-media title="Text-only card" subtitle="No image provided">
29
+ <p>Body copy goes in the default slot.</p>
30
+ </rel-card-media>
31
+
32
+ <!-- Gallery grid -->
33
+ <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;">
34
+ <rel-card-media image-src="/images/1.jpg" image-alt="" title="Item 1"></rel-card-media>
35
+ <rel-card-media image-src="/images/2.jpg" image-alt="" title="Item 2"></rel-card-media>
36
+ <rel-card-media image-src="/images/3.jpg" image-alt="" title="Item 3"></rel-card-media>
37
+ </div>
38
+
39
+ <!-- Restyle through parts -->
40
+ <style>
41
+ .flat::part(base) {
42
+ border: none;
43
+ }
44
+ .flat::part(content) {
45
+ padding: 24px;
46
+ }
47
+ </style>
48
+ <rel-card-media class="flat" title="Flat card"></rel-card-media>
49
+ ```
50
+
51
+ <!-- readme-gen:start -->
52
+
53
+ <!-- Generated from rel-cardmedia.ts — do not edit; run readme-generate.mjs -->
54
+
55
+ ## API
56
+
57
+ ### Attributes / Properties
58
+
59
+ | Property | Attribute | Type | Default | Description |
60
+ | --- | --- | --- | --- | --- |
61
+ | `imageSrc` | `image-src` | `string` | `""` | URL of the hero image shown full-width at the top of the card. Empty (the default) omits the image section entirely. |
62
+ | `imageAlt` | `image-alt` | `string` | `"Card image"` | Alternative text for the hero image. Replace the generic default with a real description, or an empty string for purely decorative images. |
63
+ | `title` | `title` | `string` | `""` | Heading rendered as an `<h3>` above the subtitle; empty omits it. Note this is also the native `title` attribute, so a value shows as a browser tooltip on hover. |
64
+ | `subtitle` | `subtitle` | `string` | `""` | Secondary line rendered as a paragraph under the title; empty omits it. |
65
+
66
+ ## Events
67
+
68
+ | Event | Detail | Bubbles / composed | Description |
69
+ | --- | --- | --- | --- |
70
+ | — | — | — | This element emits no custom events. |
71
+
72
+ ## Slots
73
+
74
+ | Slot | Description |
75
+ | --- | --- |
76
+ | (default) | Body content rendered inside the padded content area below the title and subtitle. |
77
+
78
+ ## CSS Parts
79
+
80
+ | Part | Description |
81
+ | --- | --- |
82
+ | `base` | The outer bordered card surface (background, border, radius, overflow clip). |
83
+ | `icon` | The image wrapper above the content, rendered only when `image-src` is set. |
84
+ | `content` | The padded area holding the title, subtitle and slotted body. |
85
+
86
+ <!-- readme-gen:end -->
87
+
88
+ ## Accessibility
89
+
90
+ - The image renders as an `<img>` whose `alt` is `image-alt`; the default "Card image" is a placeholder — supply a real description, or an empty `image-alt=""` when the picture is decorative.
91
+ - The title is a real `<h3>`; make sure that fits the page's heading outline (there is no way to change the level).
92
+ - The card itself is a non-focusable container with no keyboard handling. Slotted controls (buttons, links) keep their own focus and keyboard behaviour.
93
+
94
+ ## Notes / Edge Cases
95
+
96
+ - **Attribute spellings are kebab-case**: `image-src` and `image-alt`. Setting `imageSrc="…"` as an HTML attribute does nothing; use the property in code (`el.imageSrc = …`).
97
+ - **`title` is also the native tooltip attribute.** Because the property maps to the global `title` attribute, hovering the card shows the title text as a browser tooltip.
98
+ - The image section (`icon` part) is omitted entirely when `image-src` is empty; the title and subtitle are likewise omitted when empty, so the content area may hold only slotted children.
99
+ - The image is `width: 100%; height: auto; object-fit: cover` and the card clips overflow, so the top corners follow the card radius.
100
+ - The card is static: no hover lift, shadow or transition is applied.