Skip to content

Commit 9fbf3a8

Browse files
Fix Radio Card docs order and headings (#267)
1 parent 14303ad commit 9fbf3a8

File tree

5 files changed

+188
-87
lines changed

5 files changed

+188
-87
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/kumo": patch
3+
---
4+
5+
Fix Radio compound component to use Object.assign pattern, enabling sub-component detection (Radio.Group, Radio.Item) in the component registry.

packages/kumo-docs-astro/src/pages/components/radio.mdx

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -127,46 +127,6 @@ defaultValue="standard"
127127
<RadioDescriptionDemo client:visible />
128128
</ComponentExample>
129129

130-
<Heading level={3}>With Error</Heading>
131-
<p>
132-
Show validation errors at the group level using the <code
133-
class="rounded bg-kumo-control px-1 py-0.5 text-sm">error</code> prop.
134-
</p>
135-
<ComponentExample
136-
code={`<Radio.Group
137-
138-
legend="Payment method"
139-
error="Please select a payment method to continue"
140-
141-
>
142-
143-
<Radio.Item label="Credit Card" value="card" variant="error" />
144-
<Radio.Item label="PayPal" value="paypal" variant="error" />
145-
<Radio.Item label="Bank Transfer" value="bank" variant="error" />
146-
</Radio.Group>`}
147-
>
148-
<RadioErrorDemo client:visible />
149-
</ComponentExample>
150-
151-
<Heading level={3}>Disabled</Heading>
152-
<p>
153-
Disable the entire group or individual items.
154-
</p>
155-
<ComponentExample
156-
code={`<Radio.Group legend="Disabled group" disabled defaultValue="a">
157-
158-
<Radio.Item label="Option A" value="a" />
159-
<Radio.Item label="Option B" value="b" />
160-
</Radio.Group>
161-
162-
<Radio.Group legend="Individual disabled" defaultValue="available">
163-
<Radio.Item label="Available" value="available" />
164-
<Radio.Item label="Unavailable" value="unavailable" disabled />
165-
</Radio.Group>`}
166-
>
167-
<RadioDisabledDemo client:visible />
168-
</ComponentExample>
169-
170130
<Heading level={3}>Control Position</Heading>
171131
<p>
172132
Use `controlPosition="end"` to place labels before radio buttons.
@@ -181,9 +141,9 @@ error="Please select a payment method to continue"
181141
<RadioControlPositionDemo client:visible />
182142
</ComponentExample>
183143

184-
<Heading level={3}>Card Appearance</Heading>
144+
<Heading level={3}>Radio Card</Heading>
185145
<p>
186-
Use `appearance="card"` for a more prominent card-style layout with descriptions.
146+
Use <code class="rounded bg-kumo-control px-1 py-0.5 text-sm">appearance="card"</code> on the group to display each option as a selectable card. Combine with the <code class="rounded bg-kumo-control px-1 py-0.5 text-sm">description</code> prop on each item for richer content.
187147
</p>
188148
<ComponentExample
189149
code={`<Radio.Group legend="Choose a plan" appearance="card" defaultValue="free">
@@ -213,9 +173,9 @@ error="Please select a payment method to continue"
213173
<RadioCardDemo client:visible />
214174
</ComponentExample>
215175

216-
<Heading level={3}>Card Appearance (Horizontal)</Heading>
176+
<Heading level={3}>Radio Card (Horizontal)</Heading>
217177
<p>
218-
Combine `appearance="card"` with `orientation="horizontal"` for a horizontal card layout.
178+
Combine <code class="rounded bg-kumo-control px-1 py-0.5 text-sm">appearance="card"</code> with <code class="rounded bg-kumo-control px-1 py-0.5 text-sm">orientation="horizontal"</code> for a side-by-side card layout.
219179
</p>
220180
<ComponentExample
221181
code={`<Radio.Group
@@ -251,6 +211,46 @@ defaultValue="free"
251211
>
252212
<RadioCardHorizontalDemo client:visible />
253213
</ComponentExample>
214+
215+
<Heading level={3}>With Error</Heading>
216+
<p>
217+
Show validation errors at the group level using the <code
218+
class="rounded bg-kumo-control px-1 py-0.5 text-sm">error</code> prop.
219+
</p>
220+
<ComponentExample
221+
code={`<Radio.Group
222+
223+
legend="Payment method"
224+
error="Please select a payment method to continue"
225+
226+
>
227+
228+
<Radio.Item label="Credit Card" value="card" variant="error" />
229+
<Radio.Item label="PayPal" value="paypal" variant="error" />
230+
<Radio.Item label="Bank Transfer" value="bank" variant="error" />
231+
</Radio.Group>`}
232+
>
233+
<RadioErrorDemo client:visible />
234+
</ComponentExample>
235+
236+
<Heading level={3}>Disabled</Heading>
237+
<p>
238+
Disable the entire group or individual items.
239+
</p>
240+
<ComponentExample
241+
code={`<Radio.Group legend="Disabled group" disabled defaultValue="a">
242+
243+
<Radio.Item label="Option A" value="a" />
244+
<Radio.Item label="Option B" value="b" />
245+
</Radio.Group>
246+
247+
<Radio.Group legend="Individual disabled" defaultValue="available">
248+
<Radio.Item label="Available" value="available" />
249+
<Radio.Item label="Unavailable" value="unavailable" disabled />
250+
</Radio.Group>`}
251+
>
252+
<RadioDisabledDemo client:visible />
253+
</ComponentExample>
254254
</ComponentSection>
255255

256256
{/* API Reference */}

packages/kumo/ai/component-registry.json

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,13 +1938,7 @@
19381938
"description": "Additional CSS classes merged via `cn()`."
19391939
}
19401940
},
1941-
"examples": [
1942-
"<CodeBlock\n lang=\"tsx\"\n code={`const greeting = \"Hello, World!\";\nconsole.log(greeting);`}\n />",
1943-
"<CodeBlock\n lang=\"tsx\"\n code={`interface User {\n id: string;\n name: string;\n email: string;\n}\n\nconst user: User = {\n id: \"1\",\n name: \"John Doe\",\n email: \"john@example.com\"\n};`}\n />",
1944-
"<CodeBlock\n lang=\"bash\"\n code={`npm install @cloudflare/kumo\npnpm add @cloudflare/kumo`}\n />",
1945-
"<CodeBlock\n lang=\"jsonc\"\n code={`{\n \"name\": \"kumo\",\n \"version\": \"1.0.0\",\n \"dependencies\": {\n \"react\": \"^19.0.0\"\n }\n}`}\n />",
1946-
"<Code\n lang=\"bash\"\n code=\"export API_KEY={{apiKey}}\"\n values={{\n apiKey: { value: \"sk_live_123\", highlight: true },\n }}\n />"
1947-
],
1941+
"examples": [],
19481942
"colors": [
19491943
"bg-kumo-base",
19501944
"border-kumo-fill",
@@ -3354,7 +3348,8 @@
33543348
"examples": [
33553349
"<Loader />",
33563350
"<div className=\"flex items-center gap-4\">\n <Loader size=\"sm\" />\n <Loader size=\"base\" />\n <Loader size=\"lg\" />\n </div>",
3357-
"<Loader size={24} />"
3351+
"<Loader size={24} />",
3352+
"<Loader className=\"text-kumo-subtle\" />"
33583353
],
33593354
"colors": []
33603355
},
@@ -3387,9 +3382,9 @@
33873382
}
33883383
},
33893384
"examples": [
3390-
"<MenuBar\n isActive=\"bold\"\n optionIds\n options={[\n {\n icon: <TextBolderIcon />,\n id: \"bold\",\n tooltip: \"Bold\",\n onClick: () => {},\n },\n {\n icon: <TextItalicIcon />,\n id: \"italic\",\n tooltip: \"Italic\",\n onClick: () => {},\n },\n ]}\n />",
3391-
"<MenuBar\n isActive=\"bold\"\n optionIds\n options={[\n {\n icon: <TextBolderIcon />,\n id: \"bold\",\n tooltip: \"Bold\",\n onClick: () => {},\n },\n {\n icon: <TextItalicIcon />,\n id: \"italic\",\n tooltip: \"Italic\",\n onClick: () => {},\n },\n ]}\n />",
3392-
"<MenuBar\n isActive=\"\"\n optionIds\n options={[\n {\n icon: <TextBolderIcon />,\n id: \"bold\",\n tooltip: \"Bold\",\n onClick: () => {},\n },\n {\n icon: <TextItalicIcon />,\n id: \"italic\",\n tooltip: \"Italic\",\n onClick: () => {},\n },\n ]}\n />"
3385+
"<MenuBar\n isActive={active}\n optionIds\n options={[\n {\n icon: <TextBolderIcon />,\n id: \"bold\",\n tooltip: \"Bold\",\n onClick: () => setActive(active === \"bold\" ? undefined : \"bold\"),\n },\n {\n icon: <TextItalicIcon />,\n id: \"italic\",\n tooltip: \"Italic\",\n onClick: () => setActive(active === \"italic\" ? undefined : \"italic\"),\n },\n ]}\n />",
3386+
"<MenuBar\n isActive={active}\n optionIds\n options={[\n {\n icon: <TextBolderIcon />,\n id: \"bold\",\n tooltip: \"Bold\",\n onClick: () => setActive(active === \"bold\" ? undefined : \"bold\"),\n },\n {\n icon: <TextItalicIcon />,\n id: \"italic\",\n tooltip: \"Italic\",\n onClick: () => setActive(active === \"italic\" ? undefined : \"italic\"),\n },\n ]}\n />",
3387+
"<MenuBar\n isActive={active}\n optionIds\n options={[\n {\n icon: <TextBolderIcon />,\n id: \"bold\",\n tooltip: \"Bold\",\n onClick: () => setActive(active === \"bold\" ? undefined : \"bold\"),\n },\n {\n icon: <TextItalicIcon />,\n id: \"italic\",\n tooltip: \"Italic\",\n onClick: () => setActive(active === \"italic\" ? undefined : \"italic\"),\n },\n ]}\n />"
33933388
],
33943389
"colors": [
33953390
"bg-kumo-base",
@@ -3461,7 +3456,7 @@
34613456
"<Meter label=\"Progress\" value={40} showValue={false} />",
34623457
"<Meter label=\"Quota reached\" value={100} />",
34633458
"<Meter label=\"Memory usage\" value={15} />",
3464-
"<Meter\n label=\"Upload progress\"\n value={80}\n indicatorClassName=\"from-green-500 via-green-500 to-green-500\"\n />"
3459+
"<Meter\n label=\"Upload progress\"\n value={80}\n indicatorClassName=\"from-kumo-success via-kumo-success to-kumo-success\"\n />"
34653460
],
34663461
"colors": [
34673462
"bg-kumo-fill",
@@ -3805,7 +3800,72 @@
38053800
"text-kumo-danger",
38063801
"text-kumo-default",
38073802
"text-kumo-subtle"
3808-
]
3803+
],
3804+
"subComponents": {
3805+
"Item": {
3806+
"name": "Item",
3807+
"description": "Item sub-component",
3808+
"props": {}
3809+
},
3810+
"Group": {
3811+
"name": "Group",
3812+
"description": "Group sub-component",
3813+
"props": {
3814+
"legend": {
3815+
"type": "string",
3816+
"required": true
3817+
},
3818+
"children": {
3819+
"type": "ReactNode",
3820+
"required": true
3821+
},
3822+
"orientation": {
3823+
"type": "\"vertical\" | \"horizontal\"",
3824+
"optional": true
3825+
},
3826+
"appearance": {
3827+
"type": "KumoRadioAppearance",
3828+
"optional": true
3829+
},
3830+
"error": {
3831+
"type": "string",
3832+
"optional": true
3833+
},
3834+
"description": {
3835+
"type": "ReactNode",
3836+
"optional": true
3837+
},
3838+
"value": {
3839+
"type": "string",
3840+
"optional": true
3841+
},
3842+
"disabled": {
3843+
"type": "boolean",
3844+
"optional": true
3845+
},
3846+
"label": {
3847+
"type": "\"start\" (default) puts radio before label",
3848+
"required": true
3849+
},
3850+
"Note": {
3851+
"type": "In card appearance",
3852+
"required": true
3853+
},
3854+
"controlPosition": {
3855+
"type": "RadioControlPosition",
3856+
"optional": true
3857+
},
3858+
"name": {
3859+
"type": "string",
3860+
"optional": true
3861+
},
3862+
"className": {
3863+
"type": "string",
3864+
"optional": true
3865+
}
3866+
}
3867+
}
3868+
}
38093869
},
38103870
"Select": {
38113871
"name": "Select",
@@ -4084,6 +4144,7 @@
40844144
"bg-kumo-brand",
40854145
"bg-kumo-control",
40864146
"outline-kumo-ring",
4147+
"ring-kumo-ring",
40874148
"text-kumo-default",
40884149
"text-kumo-subtle"
40894150
]
@@ -4240,7 +4301,8 @@
42404301
"<Switch label=\"Disabled\" checked={false} disabled />",
42414302
"<Switch\n label=\"Neutral switch\"\n variant=\"neutral\"\n checked={checked}\n onCheckedChange={setChecked}\n />",
42424303
"<div className=\"flex flex-col gap-4\">\n <Switch\n label=\"Neutral off\"\n variant=\"neutral\"\n checked={false}\n onCheckedChange={() => {}}\n />\n <Switch\n label=\"Neutral on\"\n variant=\"neutral\"\n checked={true}\n onCheckedChange={() => {}}\n />\n <Switch\n label=\"Neutral disabled\"\n variant=\"neutral\"\n checked={false}\n disabled\n />\n </div>",
4243-
"<div className=\"flex flex-col gap-4\">\n <Switch\n label=\"Default variant\"\n checked={true}\n onCheckedChange={() => {}}\n />\n <Switch\n label=\"Neutral variant\"\n variant=\"neutral\"\n checked={true}\n onCheckedChange={() => {}}\n />\n </div>"
4304+
"<div className=\"flex flex-col gap-4\">\n <Switch\n label=\"Default variant\"\n checked={true}\n onCheckedChange={() => {}}\n />\n <Switch\n label=\"Neutral variant\"\n variant=\"neutral\"\n checked={true}\n onCheckedChange={() => {}}\n />\n </div>",
4305+
"<div className=\"flex flex-col gap-4\">\n <Switch\n label=\"Small\"\n size=\"sm\"\n checked={true}\n onCheckedChange={() => {}}\n />\n <Switch\n label=\"Base (default)\"\n size=\"base\"\n checked={true}\n onCheckedChange={() => {}}\n />\n <Switch\n label=\"Large\"\n size=\"lg\"\n checked={true}\n onCheckedChange={() => {}}\n />\n </div>"
42444306
],
42454307
"colors": [
42464308
"bg-kumo-base",
@@ -5138,4 +5200,4 @@
51385200
]
51395201
}
51405202
}
5141-
}
5203+
}

0 commit comments

Comments
 (0)