opui-css 4.1.0 → 5.0.1

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 (114) hide show
  1. package/CHANGELOG.md +282 -247
  2. package/LICENSE +21 -21
  3. package/MIGRATING.md +127 -105
  4. package/README.md +87 -87
  5. package/astro/index.ts +46 -46
  6. package/components/AGENTS.md +248 -247
  7. package/components/Accordion/Accordion.astro +42 -42
  8. package/components/Anchor/Anchor.astro +51 -51
  9. package/components/Avatar/Avatar.astro +38 -44
  10. package/components/Badge/Badge.astro +59 -54
  11. package/components/Button/Button.astro +45 -45
  12. package/components/ButtonGroup/ButtonGroup.astro +29 -29
  13. package/components/Callout/Callout.astro +75 -75
  14. package/components/Card/Card.astro +36 -36
  15. package/components/Checkbox/Checkbox.astro +76 -76
  16. package/components/Checkbox/CheckboxInput.astro +32 -32
  17. package/components/Chip/Chip.astro +37 -37
  18. package/components/ClassicSelect/ClassicSelect.astro +83 -83
  19. package/components/DescriptionList/Description.astro +12 -12
  20. package/components/DescriptionList/DescriptionList.astro +22 -22
  21. package/components/DescriptionList/Item.astro +12 -12
  22. package/components/DescriptionList/Term.astro +12 -12
  23. package/components/DescriptionList/index.ts +12 -12
  24. package/components/Dialog/Dialog.astro +41 -41
  25. package/components/Divider/Divider.astro +17 -14
  26. package/components/Drawer/Drawer.astro +49 -49
  27. package/components/Drawer/DrawerFooter.astro +14 -14
  28. package/components/Drawer/DrawerHeader.astro +31 -31
  29. package/components/FieldDescription/FieldDescription.astro +13 -13
  30. package/components/FieldGroup/FieldGroup.astro +31 -31
  31. package/components/FieldLegend/FieldLegend.astro +15 -15
  32. package/components/FieldSet/FieldSet.astro +15 -15
  33. package/components/Form/Form.astro +15 -15
  34. package/components/IconButton/IconButton.astro +26 -26
  35. package/components/List/List.astro +36 -36
  36. package/components/ListItem/ListItem.astro +118 -118
  37. package/components/Progress/Progress.astro +41 -40
  38. package/components/Radio/Radio.astro +70 -70
  39. package/components/Radio/RadioInput.astro +24 -24
  40. package/components/Range/Range.astro +136 -136
  41. package/components/Select/Select.astro +106 -106
  42. package/components/Switch/Switch.astro +101 -101
  43. package/components/Switch/SwitchInput.astro +25 -25
  44. package/components/Table/Body.astro +13 -13
  45. package/components/Table/Cell.astro +13 -13
  46. package/components/Table/Column.astro +15 -15
  47. package/components/Table/ColumnGroup.astro +13 -13
  48. package/components/Table/Head.astro +13 -13
  49. package/components/Table/HeaderCell.astro +13 -13
  50. package/components/Table/Row.astro +13 -13
  51. package/components/Table/Table.astro +18 -15
  52. package/components/Table/index.ts +20 -20
  53. package/components/Tabs/Tabs.astro +28 -28
  54. package/components/Tabs/TabsItem.astro +47 -47
  55. package/components/Tabs/TabsPanel.astro +21 -21
  56. package/components/Tabs/TabsTab.astro +19 -19
  57. package/components/Tabs/index.ts +14 -14
  58. package/components/TextField/TextField.astro +128 -128
  59. package/components/Textarea/Textarea.astro +106 -106
  60. package/components/Toast/Toast.astro +42 -42
  61. package/components/ToggleButton/ToggleButton.astro +53 -53
  62. package/components/ToggleGroup/ToggleGroup.astro +49 -49
  63. package/components/Tooltip/Tooltip.astro +30 -30
  64. package/core/normalize.css +194 -194
  65. package/core/palette.css +59 -59
  66. package/core/utils.css +71 -71
  67. package/css/components/accordion.css +174 -174
  68. package/css/components/anchor.css +27 -27
  69. package/css/components/avatar.css +65 -65
  70. package/css/components/badge.css +107 -107
  71. package/css/components/button-group.css +179 -179
  72. package/css/components/button.css +215 -215
  73. package/css/components/callout.css +109 -109
  74. package/css/components/card.css +117 -117
  75. package/css/components/checkbox.css +205 -205
  76. package/css/components/chip.css +87 -87
  77. package/css/components/description-list.css +80 -77
  78. package/css/components/dialog.css +68 -68
  79. package/css/components/divider.css +20 -20
  80. package/css/components/drawer.css +171 -171
  81. package/css/components/form.css +146 -146
  82. package/css/components/icon-button.css +139 -139
  83. package/css/components/link.css +21 -21
  84. package/css/components/list.css +345 -345
  85. package/css/components/progress.css +102 -97
  86. package/css/components/radio.css +172 -172
  87. package/css/components/range.css +337 -337
  88. package/css/components/select.css +169 -169
  89. package/css/components/spinner.css +37 -37
  90. package/css/components/switch.css +268 -268
  91. package/css/components/table.css +179 -179
  92. package/css/components/tabs.css +83 -77
  93. package/css/components/text-field.css +450 -450
  94. package/css/components/text-input.css +64 -64
  95. package/css/components/textarea.css +24 -24
  96. package/css/components/toast.css +161 -161
  97. package/css/components/toggle-button.css +87 -87
  98. package/css/components/toggle-group.css +56 -56
  99. package/css/components/tooltip.css +67 -67
  100. package/css/components/typography.css +585 -585
  101. package/css/components.css +41 -41
  102. package/css/imports.css +16 -16
  103. package/css/js/checkbox.js +21 -21
  104. package/css/js/toast.js +94 -94
  105. package/css/theme.css +132 -132
  106. package/dist/op.css +65 -65
  107. package/dist/op.css.map +1 -1
  108. package/dist/opui.components.css +5159 -5145
  109. package/dist/opui.components.css.map +1 -1
  110. package/dist/opui.css +5668 -5654
  111. package/dist/opui.css.map +1 -1
  112. package/env.d.ts +14 -14
  113. package/open-props.css +9 -9
  114. package/package.json +81 -81
@@ -1,247 +1,248 @@
1
- # UI Component Implementation Guide
2
-
3
- This guide defines the standards for implementing reusable Astro UI components in this package (`packages/opui/components/<Name>/<Name>.astro`) based on the documentation specs at `src/docs/components/`. Use it as a reference for maintaining consistency and accessibility across the library.
4
-
5
- **CRITICAL INSTRUCTION**: Always use components from this package (imported via the `@opui/astro` alias) and their corresponding CSS from `packages/opui/css/components/` whenever possible. Avoid writing custom CSS if an existing component or utility can achieve the desired result.
6
-
7
- ## 0. Implementation Checklist
8
-
9
- When implementing or updating a component, ensure:
10
- - [ ] **Title Export**: `export const title = "Component Name"` is present.
11
- - [ ] **Props Type**: Used `type Props = { ... }` (avoid interfaces).
12
- - [ ] **Sorting**: Props, Destructuring, and Classes are sorted alphabetically.
13
- - [ ] **Rest Props**: `...rest` is captured and spread onto the root element.
14
- - [ ] **Class Management**: Used `class:list` for all class manipulations.
15
- - [ ] **ID Stability**: Used `Astro.locals.$id` for any internal element linking.
16
- - [ ] **Accessibility**: ARIA labels, roles, and relationships are correctly handled.
17
- - [ ] **Slot Strategy**: Named slots are used for structural content (icons, actions).
18
-
19
- ---
20
-
21
- ## 1. Frontmatter Structure
22
-
23
- Every component must follow this exact frontmatter layout:
24
-
25
- ```astro
26
- ---
27
- type Props = {
28
- [key: string]: any // Required for ...rest support
29
- class?: string
30
- disabled?: boolean
31
- label?: string
32
- size?: "small" | "large"
33
- variant?: "outlined" | "tonal" | "filled"
34
- }
35
-
36
- export const title = "My Component"
37
-
38
- const {
39
- class: className,
40
- disabled,
41
- label,
42
- size,
43
- variant = "outlined", // Default values in destructuring
44
- ...rest
45
- } = Astro.props
46
- ---
47
- ```
48
-
49
- ### Key Rules:
50
- - **Alphabetical Sorting**: Sort property definitions in `type Props` and variables in the destructuring statement.
51
- - **REST Support**: Always include `[key: string]: any` in props and `...rest` in destructuring.
52
- - **Title Export**: This is mandatory for documentation generation.
53
-
54
- ---
55
-
56
- ## 2. Component Composition & Tags
57
-
58
- ### Dynamic Elements (Polymorphism)
59
- For components that can be different HTML elements (e.g., `Button` as `<a>` or `<button>`), use a dynamic `Tag` variable.
60
-
61
- ```astro
62
- ---
63
- const { as: Tag = Astro.props.href ? "a" : "button", ...rest } = Astro.props
64
- ---
65
- <Tag {...rest}><slot /></Tag>
66
- ```
67
- - **Inference**: Default to `"a"` if `href` is present.
68
- - **Override**: Allow manual override via the `as` prop.
69
-
70
- ### Styling Inheritance
71
- Components should often inherit styles from others (e.g., `Dialog` looking like a `Card`). Use conditional classes to apply the inherited base class.
72
-
73
- ```astro
74
- <dialog class:list={["dialog", { card: variant }, variant, className]} {...rest}>
75
- ```
76
-
77
- ---
78
-
79
- ## 3. Class Management
80
-
81
- Use `class:list` exclusively. Follow this order for readability:
82
- 1. **Component Base Class**: The primary CSS class (e.g., `"button"`).
83
- 2. **State Objects**: Boolean flags (e.g., `{ active, disabled, error }`).
84
- 3. **Variant Props**: Direct string values from props (e.g., `size`, `variant`).
85
- 4. **External Class**: Always include `className` at the end to allow for overrides.
86
-
87
- ```astro
88
- <div
89
- class:list={[
90
- "chip",
91
- {
92
- multiline: isMultiline,
93
- selected,
94
- },
95
- size,
96
- variant,
97
- className,
98
- ]}
99
- >
100
- ```
101
-
102
- ---
103
-
104
- ## 4. Slot Patterns
105
-
106
- ### Default Slots vs Label Props
107
- For simple text-based components, provide both a `label` prop and a default slot.
108
-
109
- ```astro
110
- <div class="component">
111
- { (label || Astro.slots.has("default")) && (
112
- <span class="text">
113
- {label}
114
- <slot />
115
- </span>
116
- )}
117
- </div>
118
- ```
119
-
120
- ### Named Slots (Icons & Actions)
121
- Use named slots for specific functional areas. Check for existence before rendering wrapper tags.
122
-
123
- ```astro
124
- <div class="card">
125
- {Astro.slots.has("header") && <header><slot name="header" /></header>}
126
- <slot />
127
- {Astro.slots.has("actions") && <footer class="actions"><slot name="actions" /></footer>}
128
- </div>
129
- ```
130
-
131
- ---
132
-
133
- ## 5. Form & Input Patterns
134
-
135
- ### Label Wrapping
136
- Most inputs should be wrapped in a `<label>` to provide a larger hit area and built-in accessibility.
137
-
138
- ```astro
139
- <label class:list={["field", { disabled, error }]}>
140
- <span class="label">{label}</span>
141
- <input type="text" {...rest} />
142
- {endText && <span class="end-text">{endText}</span>}
143
- </label>
144
- ```
145
-
146
- ### End Text & ARIA
147
- When providing `endText`, use `Astro.locals.$id` to link it to the input via `aria-describedby`.
148
-
149
- ```astro
150
- ---
151
- const { $id } = Astro.locals
152
- const helpId = $id("help")
153
- ---
154
- <input aria-describedby={endText ? helpId : undefined} />
155
- {endText && <span id={helpId}>{endText}</span>}
156
- ```
157
-
158
- ### Input Attribute Mapping
159
- Explicitly define and pass through native input attributes in the `Props` type for better IDE support.
160
-
161
- ```astro
162
- <input
163
- disabled={disabled}
164
- name={name}
165
- required={required}
166
- type={type}
167
- value={value}
168
- {...rest}
169
- />
170
- ```
171
-
172
- ### Sub-component Decomposition
173
- For complex inputs (like `Checkbox` with custom visuals), split the component into a public wrapper (`Checkbox.astro`) and a private raw input (`CheckboxInput.astro`) to keep the root element clean.
174
-
175
- ### Form Structure: FieldSet, FieldLegend, FieldDescription, FieldGroup
176
- When building forms, follow this nesting order inside a `FieldSet`:
177
- 1. `FieldLegend` - The heading/label for the fieldset
178
- 2. `FieldDescription` - Optional helper text
179
- 3. `FieldGroup` - Wrapper for the actual form controls
180
-
181
- **Always wrap form elements in a `FieldGroup`**, never place them directly after `FieldLegend` or `FieldDescription`.
182
-
183
- ```astro
184
- <!-- ✅ Correct -->
185
- <FieldSet>
186
- <FieldLegend>Username</FieldLegend>
187
- <FieldDescription>Enter your preferred username.</FieldDescription>
188
- <FieldGroup>
189
- <TextField placeholder="e.g. jdoe" />
190
- </FieldGroup>
191
- </FieldSet>
192
-
193
- <!-- ❌ Incorrect - TextField directly after FieldDescription -->
194
- <FieldSet>
195
- <FieldLegend>Username</FieldLegend>
196
- <FieldDescription>Enter your preferred username.</FieldDescription>
197
- <TextField placeholder="e.g. jdoe" />
198
- </FieldSet>
199
- ```
200
-
201
- ---
202
-
203
- ## 6. Identification & Accessibility
204
-
205
- ### Unique IDs
206
- Always use `Astro.locals.$id` for IDs. This ensures stability across server and client rendering and prevents ID collisions when multiple instances of the same component are on a page.
207
-
208
- ```astro
209
- const { $id } = Astro.locals
210
- const fieldId = id || $id("input") // Prefer passed ID if available
211
- ```
212
-
213
- ### Default Icons
214
- Components like `Callout` or `Toast` should provide default SVG icons within their named slots, while allowing users to override them.
215
-
216
- ```astro
217
- <slot name="icon">
218
- {severity === "error" && <svg>...</svg>}
219
- </slot>
220
- ```
221
-
222
- ---
223
-
224
- ## 7. Data-Driven Components
225
-
226
- For repetitive structures (DescriptionLists, Menus, Selects), prefer an `items` prop alongside standard slots.
227
-
228
- ```astro
229
- type Item = { label: string; value: any }
230
- type Props = { items?: Item[] }
231
-
232
- <ul>
233
- {items.map(item => <li>{item.label}</li>)}
234
- <slot /> <!-- Still allow manual entries -->
235
- </ul>
236
- ```
237
-
238
- ---
239
-
240
- ## 8. Development Workflow
241
-
242
- 1. **Read the Spec**: Open `src/docs/components/[name].astro` to see required HTML and CSS classes. (Component docs live under `src/docs/components/` now; `src/pages/components/` only contains route shells.)
243
- 2. **Analyze the API**: Check `src/component-api/[name]/` (`Astro.astro` and `HTML.astro`) or `src/component-api/[name]-api.astro` for the documented props.
244
- 3. **Implement**: Follow the checklist in Section 0.
245
- 4. **Verify**: Check that your implementation matches the "HTML" preview in the rendered `Example` for the spec page (`/components/[name]`). For framework-specific behaviour, also verify the Astro variant at `/astro/components/[name]`.
246
-
247
-
1
+ # UI Component Implementation Guide
2
+
3
+ This guide defines the standards for implementing reusable Astro UI components in this package (`packages/opui/components/<Name>/<Name>.astro`) based on the documentation specs at `src/docs/components/`. Use it as a reference for maintaining consistency and accessibility across the library.
4
+
5
+ **CRITICAL INSTRUCTION**: Always use components from this package (imported via the `@opui/astro` alias) and their corresponding CSS from `packages/opui/css/components/` whenever possible. Avoid writing custom CSS if an existing component or utility can achieve the desired result.
6
+
7
+ ## 0. Implementation Checklist
8
+
9
+ When implementing or updating a component, ensure:
10
+ - [ ] **Title Export**: `export const title = "Component Name"` is present.
11
+ - [ ] **Props Type**: Used `type Props = { ... }` (avoid interfaces).
12
+ - [ ] **Sorting**: Props, Destructuring, and Classes are sorted alphabetically.
13
+ - [ ] **Rest Props**: `...rest` is captured and spread onto the root element.
14
+ - [ ] **Class Management**: Used `class:list` for all class manipulations.
15
+ - [ ] **ID Stability**: Used `Astro.locals.$id` for any internal element linking.
16
+ - [ ] **Accessibility**: ARIA labels, roles, and relationships are correctly handled.
17
+ - [ ] **Slot Strategy**: Named slots are used for structural content (icons, actions).
18
+
19
+ ---
20
+
21
+ ## 1. Frontmatter Structure
22
+
23
+ Every component must follow this exact frontmatter layout:
24
+
25
+ ```astro
26
+ ---
27
+ type Props = {
28
+ [key: string]: any // Required for ...rest support
29
+ class?: string
30
+ disabled?: boolean
31
+ label?: string
32
+ size?: "small" | "large"
33
+ variant?: "outlined" | "tonal" | "filled"
34
+ }
35
+
36
+ export const title = "My Component"
37
+
38
+ const {
39
+ class: className,
40
+ disabled,
41
+ label,
42
+ size,
43
+ variant = "outlined", // Default values in destructuring
44
+ ...rest
45
+ } = Astro.props
46
+ ---
47
+ ```
48
+
49
+ ### Key Rules:
50
+ - **Alphabetical Sorting**: Sort property definitions in `type Props` and variables in the destructuring statement.
51
+ - **REST Support**: Always include `[key: string]: any` in props and `...rest` in destructuring.
52
+ - **Title Export**: This is mandatory for documentation generation.
53
+
54
+ ---
55
+
56
+ ## 2. Component Composition & Tags
57
+
58
+ ### Dynamic Elements (Polymorphism)
59
+ For components that can be different HTML elements (e.g., `Button` as `<a>` or `<button>`), use a dynamic `Tag` variable.
60
+
61
+ ```astro
62
+ ---
63
+ const { as: Tag = Astro.props.href ? "a" : "button", ...rest } = Astro.props
64
+ ---
65
+ <Tag {...rest}><slot /></Tag>
66
+ ```
67
+ - **Inference**: Default to `"a"` if `href` is present.
68
+ - **Override**: Allow manual override via the `as` prop.
69
+
70
+ ### Styling Inheritance
71
+ Components should often inherit styles from others (e.g., `Dialog` looking like a `Card`). Use conditional classes to apply the inherited base class. All library classes are prefixed with `ui-`.
72
+
73
+ ```astro
74
+ <dialog class:list={["ui-dialog", { "ui-card": variant }, variant && `ui-${variant}`, className]} {...rest}>
75
+ ```
76
+
77
+ ---
78
+
79
+ ## 3. Class Management
80
+
81
+ Use `class:list` exclusively. Every library-owned class is prefixed with `ui-`; the public prop API stays unprefixed (`<Button size="small" variant="outlined">`) and the component interpolates the prefix when rendering.
82
+
83
+ Follow this order for readability:
84
+ 1. **Component Base Class**: The primary CSS class, prefixed (e.g., `"ui-button"`).
85
+ 2. **State Objects**: Boolean flags as quoted prefixed keys (e.g., `{ "ui-disabled": disabled }`).
86
+ 3. **Variant Props**: Interpolate the prefix from the prop value (e.g., `size && \`ui-${size}\``).
87
+ 4. **External Class**: Always include `className` at the end to allow for overrides. Do not prefix `className`.
88
+
89
+ ```astro
90
+ <div
91
+ class:list={[
92
+ "ui-chip",
93
+ {
94
+ "ui-multiline": isMultiline,
95
+ },
96
+ size && `ui-${size}`,
97
+ variant && `ui-${variant}`,
98
+ className,
99
+ ]}
100
+ >
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 4. Slot Patterns
106
+
107
+ ### Default Slots vs Label Props
108
+ For simple text-based components, provide both a `label` prop and a default slot.
109
+
110
+ ```astro
111
+ <div class="ui-component">
112
+ { (label || Astro.slots.has("default")) && (
113
+ <span class="ui-text">
114
+ {label}
115
+ <slot />
116
+ </span>
117
+ )}
118
+ </div>
119
+ ```
120
+
121
+ ### Named Slots (Icons & Actions)
122
+ Use named slots for specific functional areas. Check for existence before rendering wrapper tags.
123
+
124
+ ```astro
125
+ <div class="ui-card">
126
+ {Astro.slots.has("header") && <header><slot name="header" /></header>}
127
+ <slot />
128
+ {Astro.slots.has("actions") && <footer class="ui-actions"><slot name="actions" /></footer>}
129
+ </div>
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 5. Form & Input Patterns
135
+
136
+ ### Label Wrapping
137
+ Most inputs should be wrapped in a `<label>` to provide a larger hit area and built-in accessibility.
138
+
139
+ ```astro
140
+ <label class:list={["ui-field", { "ui-disabled": disabled, "ui-critical": error }]}>
141
+ <span class="ui-label">{label}</span>
142
+ <input type="text" {...rest} />
143
+ {endText && <span class="ui-end-text">{endText}</span>}
144
+ </label>
145
+ ```
146
+
147
+ ### End Text & ARIA
148
+ When providing `endText`, use `Astro.locals.$id` to link it to the input via `aria-describedby`.
149
+
150
+ ```astro
151
+ ---
152
+ const { $id } = Astro.locals
153
+ const helpId = $id("help")
154
+ ---
155
+ <input aria-describedby={endText ? helpId : undefined} />
156
+ {endText && <span id={helpId}>{endText}</span>}
157
+ ```
158
+
159
+ ### Input Attribute Mapping
160
+ Explicitly define and pass through native input attributes in the `Props` type for better IDE support.
161
+
162
+ ```astro
163
+ <input
164
+ disabled={disabled}
165
+ name={name}
166
+ required={required}
167
+ type={type}
168
+ value={value}
169
+ {...rest}
170
+ />
171
+ ```
172
+
173
+ ### Sub-component Decomposition
174
+ For complex inputs (like `Checkbox` with custom visuals), split the component into a public wrapper (`Checkbox.astro`) and a private raw input (`CheckboxInput.astro`) to keep the root element clean.
175
+
176
+ ### Form Structure: FieldSet, FieldLegend, FieldDescription, FieldGroup
177
+ When building forms, follow this nesting order inside a `FieldSet`:
178
+ 1. `FieldLegend` - The heading/label for the fieldset
179
+ 2. `FieldDescription` - Optional helper text
180
+ 3. `FieldGroup` - Wrapper for the actual form controls
181
+
182
+ **Always wrap form elements in a `FieldGroup`**, never place them directly after `FieldLegend` or `FieldDescription`.
183
+
184
+ ```astro
185
+ <!-- ✅ Correct -->
186
+ <FieldSet>
187
+ <FieldLegend>Username</FieldLegend>
188
+ <FieldDescription>Enter your preferred username.</FieldDescription>
189
+ <FieldGroup>
190
+ <TextField placeholder="e.g. jdoe" />
191
+ </FieldGroup>
192
+ </FieldSet>
193
+
194
+ <!-- ❌ Incorrect - TextField directly after FieldDescription -->
195
+ <FieldSet>
196
+ <FieldLegend>Username</FieldLegend>
197
+ <FieldDescription>Enter your preferred username.</FieldDescription>
198
+ <TextField placeholder="e.g. jdoe" />
199
+ </FieldSet>
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 6. Identification & Accessibility
205
+
206
+ ### Unique IDs
207
+ Always use `Astro.locals.$id` for IDs. This ensures stability across server and client rendering and prevents ID collisions when multiple instances of the same component are on a page.
208
+
209
+ ```astro
210
+ const { $id } = Astro.locals
211
+ const fieldId = id || $id("input") // Prefer passed ID if available
212
+ ```
213
+
214
+ ### Default Icons
215
+ Components like `Callout` or `Toast` should provide default SVG icons within their named slots, while allowing users to override them.
216
+
217
+ ```astro
218
+ <slot name="icon">
219
+ {severity === "error" && <svg>...</svg>}
220
+ </slot>
221
+ ```
222
+
223
+ ---
224
+
225
+ ## 7. Data-Driven Components
226
+
227
+ For repetitive structures (DescriptionLists, Menus, Selects), prefer an `items` prop alongside standard slots.
228
+
229
+ ```astro
230
+ type Item = { label: string; value: any }
231
+ type Props = { items?: Item[] }
232
+
233
+ <ul>
234
+ {items.map(item => <li>{item.label}</li>)}
235
+ <slot /> <!-- Still allow manual entries -->
236
+ </ul>
237
+ ```
238
+
239
+ ---
240
+
241
+ ## 8. Development Workflow
242
+
243
+ 1. **Read the Spec**: Open `src/docs/components/[name].astro` to see required HTML and CSS classes. (Component docs live under `src/docs/components/` now; `src/pages/components/` only contains route shells.)
244
+ 2. **Analyze the API**: Check `src/component-api/[name]/` (`Astro.astro` and `HTML.astro`) or `src/component-api/[name]-api.astro` for the documented props.
245
+ 3. **Implement**: Follow the checklist in Section 0.
246
+ 4. **Verify**: Check that your implementation matches the "HTML" preview in the rendered `Example` for the spec page (`/components/[name]`). For framework-specific behaviour, also verify the Astro variant at `/astro/components/[name]`.
247
+
248
+
@@ -1,42 +1,42 @@
1
- ---
2
- type Props = {
3
- class?: string
4
- name?: string
5
- open?: boolean
6
- variant?: "default" | "outlined" | "elevated" | "tonal"
7
- [key: string]: any
8
- }
9
-
10
- export const title = "Accordion"
11
-
12
- const { $id } = Astro.locals
13
- const { class: className, name, open, variant, ...rest } = Astro.props
14
-
15
- const summaryId = $id("summary")
16
- const contentId = $id("content")
17
- ---
18
-
19
- <details
20
- name={name}
21
- class:list={["accordion", "card", variant, className]}
22
- open={open}
23
- {...rest}
24
- >
25
- <!-- Summary -->
26
- <!-- prettier-ignore -->
27
- <summary id={summaryId} aria-controls={contentId}><slot name="summary" /><slot name="marker" /></summary>
28
-
29
- <!-- Content -->
30
- <div id={contentId} class="content" role="region" aria-labelledby={summaryId}>
31
- <slot />
32
- </div>
33
-
34
- <!-- Actions -->
35
- {
36
- Astro.slots.has("actions") && (
37
- <div class="actions">
38
- <slot name="actions" />
39
- </div>
40
- )
41
- }
42
- </details>
1
+ ---
2
+ type Props = {
3
+ class?: string
4
+ name?: string
5
+ open?: boolean
6
+ variant?: "default" | "outlined" | "elevated" | "tonal"
7
+ [key: string]: any
8
+ }
9
+
10
+ export const title = "Accordion"
11
+
12
+ const { $id } = Astro.locals
13
+ const { class: className, name, open, variant, ...rest } = Astro.props
14
+
15
+ const summaryId = $id("summary")
16
+ const contentId = $id("content")
17
+ ---
18
+
19
+ <details
20
+ name={name}
21
+ class:list={["ui-accordion", "ui-card", variant && `ui-${variant}`, className]}
22
+ open={open}
23
+ {...rest}
24
+ >
25
+ <!-- Summary -->
26
+ <!-- prettier-ignore -->
27
+ <summary id={summaryId} aria-controls={contentId}><slot name="summary" /><slot name="marker" /></summary>
28
+
29
+ <!-- Content -->
30
+ <div id={contentId} class="ui-content" role="region" aria-labelledby={summaryId}>
31
+ <slot />
32
+ </div>
33
+
34
+ <!-- Actions -->
35
+ {
36
+ Astro.slots.has("actions") && (
37
+ <div class="ui-actions">
38
+ <slot name="actions" />
39
+ </div>
40
+ )
41
+ }
42
+ </details>