Skip to content

Commit 7e2042a

Browse files
durvesh1992cixzhang
authored andcommitted
docs(cli): make more showcases interactive (frozen previews)
Same class of bug as #3187/#3188/#3189: these showcase blocks rendered controlled components with a static value and a no-op onChange, so the docsite previews were frozen. Wire local useState + onChange in: TextInput, TextArea, NumberInput, SegmentedControl, RadioList, Tab, TabList, TabMenu. (NumberInput/RadioList also gain 'use client'.) Found by scanning template blocks for onChange={() => {}}.
1 parent bdc7bd7 commit 7e2042a

9 files changed

Lines changed: 40 additions & 11 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@astryxdesign/cli': patch
3+
---
4+
5+
[docs] Wire local state into more showcase examples that were frozen (static value + no-op onChange): TextInput, TextArea, NumberInput, SegmentedControl, RadioList, Tab, TabList, and TabMenu. Follows the same fix as the Slider/Selector/MultiSelector showcases so the docsite previews are actually interactive
6+
@durvesh1992

packages/cli/templates/blocks/components/NumberInput/NumberInputShowcase.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// Copyright (c) Meta Platforms, Inc. and affiliates.
22

3+
'use client';
4+
5+
import {useState} from 'react';
36
import {NumberInput} from '@astryxdesign/core/NumberInput';
47

58
export default function NumberInputShowcase() {
9+
const [value, setValue] = useState<number | null>(0);
610
return (
711
<div style={{width: 300}}>
812
<NumberInput
913
label="Quantity"
1014
placeholder="Enter quantity"
11-
value={0}
12-
onChange={() => {}}
15+
value={value}
16+
onChange={setValue}
1317
/>
1418
</div>
1519
);

packages/cli/templates/blocks/components/RadioList/RadioListShowcase.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
// Copyright (c) Meta Platforms, Inc. and affiliates.
22

3+
'use client';
4+
5+
import {useState} from 'react';
36
import {RadioList, RadioListItem} from '@astryxdesign/core/RadioList';
47

58
export default function RadioListShowcase() {
9+
const [value, setValue] = useState('');
610
return (
7-
<RadioList label="Notification preference" value="" onChange={() => {}}>
11+
<RadioList
12+
label="Notification preference"
13+
value={value}
14+
onChange={setValue}>
815
<RadioListItem label="Email" value="email" />
916
<RadioListItem label="SMS" value="sms" />
1017
<RadioListItem label="Push notification" value="push" />

packages/cli/templates/blocks/components/SegmentedControl/SegmentedControlShowcase.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {
67
SegmentedControl,
78
SegmentedControlItem,
89
} from '@astryxdesign/core/SegmentedControl';
910

1011
export default function SegmentedControlShowcase() {
12+
const [value, setValue] = useState('grid');
1113
return (
12-
<SegmentedControl value="grid" onChange={() => {}} label="View mode">
14+
<SegmentedControl value={value} onChange={setValue} label="View mode">
1315
<SegmentedControlItem value="grid" label="Grid" />
1416
<SegmentedControlItem value="list" label="List" />
1517
<SegmentedControlItem value="table" label="Table" />

packages/cli/templates/blocks/components/Tab/TabShowcase.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {TabList, Tab} from '@astryxdesign/core/TabList';
67
import {Badge} from '@astryxdesign/core/Badge';
78

89
export default function TabShowcase() {
10+
const [value, setValue] = useState('inbox');
911
return (
10-
<TabList value="inbox" onChange={() => {}}>
12+
<TabList value={value} onChange={setValue}>
1113
<Tab
1214
value="inbox"
1315
label="Inbox"

packages/cli/templates/blocks/components/TabList/TabListShowcase.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {TabList, Tab} from '@astryxdesign/core/TabList';
67

78
export default function TabListShowcase() {
9+
const [value, setValue] = useState('home');
810
return (
9-
<TabList value="home" onChange={() => {}}>
11+
<TabList value={value} onChange={setValue}>
1012
<Tab value="home" label="Home" />
1113
<Tab value="projects" label="Projects" />
1214
<Tab value="settings" label="Settings" />

packages/cli/templates/blocks/components/TabMenu/TabMenuShowcase.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {TabList, Tab, TabMenu} from '@astryxdesign/core/TabList';
67

78
export default function TabMenuShowcase() {
9+
const [value, setValue] = useState('settings');
810
return (
9-
<TabList value="settings" onChange={() => {}}>
11+
<TabList value={value} onChange={setValue}>
1012
<Tab value="overview" label="Overview" />
1113
<Tab value="activity" label="Activity" />
1214
<TabMenu

packages/cli/templates/blocks/components/TextArea/TextAreaShowcase.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {TextArea} from '@astryxdesign/core/TextArea';
67

78
export default function TextAreaShowcase() {
9+
const [value, setValue] = useState('');
810
return (
911
<div style={{width: 400}}>
1012
<TextArea
1113
label="Description"
12-
value=""
13-
onChange={() => {}}
14+
value={value}
15+
onChange={setValue}
1416
placeholder="Enter a description..."
1517
/>
1618
</div>

packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
'use client';
44

5+
import {useState} from 'react';
56
import {TextInput} from '@astryxdesign/core/TextInput';
67

78
export default function TextInputShowcase() {
9+
const [value, setValue] = useState('');
810
return (
911
<div style={{width: 300}}>
1012
<TextInput
1113
label="Name"
12-
value=""
13-
onChange={() => {}}
14+
value={value}
15+
onChange={setValue}
1416
placeholder="Enter your name"
1517
/>
1618
</div>

0 commit comments

Comments
 (0)