An open source design system that's fully customizable and agent ready
TypeScript
docs(cli): make more showcases interactive (frozen previews) (#3200)
Durvesh Pilankar23a43ab5de16
diff --git a/.changeset/interactive-showcases-2.md b/.changeset/interactive-showcases-2.mdnew file mode 100644index 0000000000..def8ebbf90--- /dev/null+++ b/.changeset/interactive-showcases-2.md@@ -0,0 +1,6 @@+---+'@astryxdesign/cli': patch+---++[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+@durvesh1992diff --git a/packages/cli/templates/blocks/components/NumberInput/NumberInputShowcase.tsx b/packages/cli/templates/blocks/components/NumberInput/NumberInputShowcase.tsxindex fc2fe3a249..ad04c7a9da 100644--- a/packages/cli/templates/blocks/components/NumberInput/NumberInputShowcase.tsx+++ b/packages/cli/templates/blocks/components/NumberInput/NumberInputShowcase.tsx@@ -1,15 +1,19 @@// Copyright (c) Meta Platforms, Inc. and affiliates.+'use client';++import {useState} from 'react';import {NumberInput} from '@astryxdesign/core/NumberInput';export default function NumberInputShowcase() {+ const [value, setValue] = useState<number | null>(0);return (<div style={{width: 300}}><NumberInputlabel="Quantity"placeholder="Enter quantity"- value={0}- onChange={() => {}}+ value={value}+ onChange={setValue}/></div>);diff --git a/packages/cli/templates/blocks/components/RadioList/RadioListShowcase.tsx b/packages/cli/templates/blocks/components/RadioList/RadioListShowcase.tsxindex b438b6a8a3..90eb68a3c1 100644--- a/packages/cli/templates/blocks/components/RadioList/RadioListShowcase.tsx+++ b/packages/cli/templates/blocks/components/RadioList/RadioListShowcase.tsx@@ -1,10 +1,17 @@// Copyright (c) Meta Platforms, Inc. and affiliates.+'use client';++import {useState} from 'react';import {RadioList, RadioListItem} from '@astryxdesign/core/RadioList';export default function RadioListShowcase() {+ const [value, setValue] = useState('');return (- <RadioList label="Notification preference" value="" onChange={() => {}}>+ <RadioList+ label="Notification preference"+ value={value}+ onChange={setValue}><RadioListItem label="Email" value="email" /><RadioListItem label="SMS" value="sms" /><RadioListItem label="Push notification" value="push" />diff --git a/packages/cli/templates/blocks/components/SegmentedControl/SegmentedControlShowcase.tsx b/packages/cli/templates/blocks/components/SegmentedControl/SegmentedControlShowcase.tsxindex 81a8dda925..dc375a30a0 100644--- a/packages/cli/templates/blocks/components/SegmentedControl/SegmentedControlShowcase.tsx+++ b/packages/cli/templates/blocks/components/SegmentedControl/SegmentedControlShowcase.tsx@@ -2,14 +2,16 @@'use client';+import {useState} from 'react';import {SegmentedControl,SegmentedControlItem,} from '@astryxdesign/core/SegmentedControl';export default function SegmentedControlShowcase() {+ const [value, setValue] = useState('grid');return (- <SegmentedControl value="grid" onChange={() => {}} label="View mode">+ <SegmentedControl value={value} onChange={setValue} label="View mode"><SegmentedControlItem value="grid" label="Grid" /><SegmentedControlItem value="list" label="List" /><SegmentedControlItem value="table" label="Table" />diff --git a/packages/cli/templates/blocks/components/Tab/TabShowcase.tsx b/packages/cli/templates/blocks/components/Tab/TabShowcase.tsxindex 88375d1e31..9e64cf5723 100644--- a/packages/cli/templates/blocks/components/Tab/TabShowcase.tsx+++ b/packages/cli/templates/blocks/components/Tab/TabShowcase.tsx@@ -2,12 +2,14 @@'use client';+import {useState} from 'react';import {TabList, Tab} from '@astryxdesign/core/TabList';import {Badge} from '@astryxdesign/core/Badge';export default function TabShowcase() {+ const [value, setValue] = useState('inbox');return (- <TabList value="inbox" onChange={() => {}}>+ <TabList value={value} onChange={setValue}><Tabvalue="inbox"label="Inbox"diff --git a/packages/cli/templates/blocks/components/TabList/TabListShowcase.tsx b/packages/cli/templates/blocks/components/TabList/TabListShowcase.tsxindex 4e96ff0ebf..0d0e6160b9 100644--- a/packages/cli/templates/blocks/components/TabList/TabListShowcase.tsx+++ b/packages/cli/templates/blocks/components/TabList/TabListShowcase.tsx@@ -2,11 +2,13 @@'use client';+import {useState} from 'react';import {TabList, Tab} from '@astryxdesign/core/TabList';export default function TabListShowcase() {+ const [value, setValue] = useState('home');return (- <TabList value="home" onChange={() => {}}>+ <TabList value={value} onChange={setValue}><Tab value="home" label="Home" /><Tab value="projects" label="Projects" /><Tab value="settings" label="Settings" />diff --git a/packages/cli/templates/blocks/components/TabMenu/TabMenuShowcase.tsx b/packages/cli/templates/blocks/components/TabMenu/TabMenuShowcase.tsxindex dce6e2c75a..c8824c30fa 100644--- a/packages/cli/templates/blocks/components/TabMenu/TabMenuShowcase.tsx+++ b/packages/cli/templates/blocks/components/TabMenu/TabMenuShowcase.tsx@@ -2,11 +2,13 @@'use client';+import {useState} from 'react';import {TabList, Tab, TabMenu} from '@astryxdesign/core/TabList';export default function TabMenuShowcase() {+ const [value, setValue] = useState('settings');return (- <TabList value="settings" onChange={() => {}}>+ <TabList value={value} onChange={setValue}><Tab value="overview" label="Overview" /><Tab value="activity" label="Activity" /><TabMenudiff --git a/packages/cli/templates/blocks/components/TextArea/TextAreaShowcase.tsx b/packages/cli/templates/blocks/components/TextArea/TextAreaShowcase.tsxindex 98885359f5..e6ed6eb2fe 100644--- a/packages/cli/templates/blocks/components/TextArea/TextAreaShowcase.tsx+++ b/packages/cli/templates/blocks/components/TextArea/TextAreaShowcase.tsx@@ -2,15 +2,17 @@'use client';+import {useState} from 'react';import {TextArea} from '@astryxdesign/core/TextArea';export default function TextAreaShowcase() {+ const [value, setValue] = useState('');return (<div style={{width: 400}}><TextArealabel="Description"- value=""- onChange={() => {}}+ value={value}+ onChange={setValue}placeholder="Enter a description..."/></div>diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsxindex 9d55eab596..b0a5debb1c 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx+++ b/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx@@ -2,15 +2,17 @@'use client';+import {useState} from 'react';import {TextInput} from '@astryxdesign/core/TextInput';export default function TextInputShowcase() {+ const [value, setValue] = useState('');return (<div style={{width: 300}}><TextInputlabel="Name"- value=""- onChange={() => {}}+ value={value}+ onChange={setValue}placeholder="Enter your name"/></div>