An open source design system that's fully customizable and agent ready
TypeScript
feat(ChatComposerDrawer): rename FollowUpQuestions template to Feedback (#1898)
Kenton Quatmanb2780c53fb26
diff --git a/apps/storybook/stories/ChatComposer.stories.tsx b/apps/storybook/stories/ChatComposer.stories.tsxindex a45bd13a77..ade88d5a4e 100644--- a/apps/storybook/stories/ChatComposer.stories.tsx+++ b/apps/storybook/stories/ChatComposer.stories.tsx@@ -56,33 +56,6 @@ const MicIcon = (</svg>);-const ChevronLeftIcon = (- <svg- width="1em"- height="1em"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round">- <path d="m15 18-6-6 6-6" />- </svg>-);-const ChevronRightIcon = (- <svg- width="1em"- height="1em"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round">- <path d="m9 18 6-6-6-6" />- </svg>-);-const meta: Meta<typeof XDSChatComposer> = {title: 'Core/Chat/Composer',component: XDSChatComposer,@@ -361,98 +334,36 @@ export const SendStopToggle: Story = {},};-/** Drawer with follow-up questions, selectable options, and prev/next navigation */-export const FollowUpQuestion: Story = {+/** Drawer with a feedback prompt, warning badge, and selectable options */+export const Feedback: Story = {render: () => {- const questions = [+ const options = [+ {key: 'A', label: 'Yes'},{- question: 'Which environment should this deploy to?',- options: [- {key: 'A', label: 'Production (requires approval)'},- {key: 'B', label: 'Staging'},- {key: 'C', label: 'Local development only'},- ],- },- {- question:- 'This will modify 12 files. How should I handle breaking changes?',- options: [- {key: 'A', label: 'Add a migration and keep backward compatibility'},- {- key: 'B',- label: 'Breaking change is fine \u2014 bump the major version',- },- ],- },- {- question:- 'I found 3 existing implementations. Which one should I extend?',- options: [- {key: 'A', label: 'UserService in src/services/ (most recent)'},- {- key: 'B',- label: 'UserManager in src/legacy/ (has more test coverage)',- },- {key: 'C', label: 'Neither \u2014 start fresh'},- ],+ key: 'B',+ label: 'Yes, and don\u2019t ask again for `git add` commands',},+ {key: 'C', label: 'No, and tell me what to do differently'},];- const [currentQ, setCurrentQ] = useState(0);- const [answers, setAnswers] = useState<Record<number, string>>({});- const q = questions[currentQ];- const selected = answers[currentQ] ?? null;+ const [selected, setSelected] = useState<string | null>(null);return (<XDSChatComposeronSubmit={value => {- console.log('Submit:', value, '| Answers:', answers);- alert(- `Sent: "${value}"\nAnswers: ${JSON.stringify(answers, null, 2)}`,- );+ console.log('Submit:', value, '| Answer:', selected);+ alert(`Sent: "${value}"\nAnswer: ${selected}`);}}- placeholder="Or describe what you need in your own words\u2026"drawer={- <XDSChatComposerDrawer count={questions.length} label="Questions">+ <XDSChatComposerDrawer count={1} label="User feedback requested"><div style={{width: '100%'}}>- <div- style={{- display: 'flex',- alignItems: 'center',- justifyContent: 'space-between',- marginBlockEnd: 4,- }}>- <XDSButton- label="Previous question"- variant="ghost"- size="sm"- icon={ChevronLeftIcon}- isIconOnly- isDisabled={currentQ === 0}- onClick={() => setCurrentQ(i => i - 1)}- />- <XDSText color="secondary">- {currentQ + 1} of {questions.length}- </XDSText>- <XDSButton- label="Next question"- variant="ghost"- size="sm"- icon={ChevronRightIcon}- isIconOnly- isDisabled={currentQ === questions.length - 1}- onClick={() => setCurrentQ(i => i + 1)}- />- </div><XDSList><XDSListItemlabel={- <XDSText weight="bold">- {currentQ + 1}. {q.question}- </XDSText>+ <XDSText weight="bold">Do you want to proceed?</XDSText>}/>- {q.options.map(opt => (+ {options.map(opt => (<XDSListItemkey={opt.key}label={opt.label}@@ -463,16 +374,13 @@ export const FollowUpQuestion: Story = {/>}isSelected={selected === opt.key}- onClick={() =>- setAnswers(prev => ({...prev, [currentQ]: opt.key}))- }+ onClick={() => setSelected(opt.key)}/>))}</XDSList></div></XDSChatComposerDrawer>}- footerActions={<XDSButton label="Skip all" variant="ghost" size="md" />}/>);},diff --git a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFeedback.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFeedback.doc.mjsnew file mode 100644index 0000000000..b40c262534--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFeedback.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ChatComposerDrawer — Feedback',+ description: 'Chat composer drawer with a feedback prompt and selectable lettered options. Use for user confirmation workflows that require explicit action before proceeding.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['ChatComposer', 'List', 'Badge', 'Text', 'Layout'],+};diff --git a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFeedback.tsx b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFeedback.tsxnew file mode 100644index 0000000000..e93e8a1bc6--- /dev/null+++ b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFeedback.tsx@@ -0,0 +1,55 @@+'use client';++import {useState} from 'react';+import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';+import {XDSList, XDSListItem} from '@xds/core/List';+import {XDSText} from '@xds/core/Text';+import {XDSBadge} from '@xds/core/Badge';+import {XDSStack} from '@xds/core/Layout';++const options = [+ {key: 'A', label: 'Yes'},+ {key: 'B', label: 'Yes, and don\u2019t ask again for `git add` commands'},+ {key: 'C', label: 'No, and tell me what to do differently'},+];++export default function ChatComposerDrawerFeedback() {+ const [selected, setSelected] = useState<string | null>(null);++ return (+ <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>+ <XDSChatComposer+ onSubmit={value => {+ console.log('Submit:', value, '| Answer:', selected);+ }}+ drawer={+ <XDSChatComposerDrawer count={1} label="User feedback requested">+ <XDSStack direction="vertical" gap={1} width="100%">+ <XDSList>+ <XDSListItem+ label={+ <XDSText weight="bold">Do you want to proceed?</XDSText>+ }+ />+ {options.map(opt => (+ <XDSListItem+ key={opt.key}+ label={opt.label}+ startContent={+ <XDSBadge+ variant={selected === opt.key ? 'info' : 'neutral'}+ label={opt.key}+ />+ }+ isSelected={selected === opt.key}+ onClick={() => setSelected(opt.key)}+ />+ ))}+ </XDSList>+ </XDSStack>+ </XDSChatComposerDrawer>+ }+ />+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.doc.mjs b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.doc.mjsdeleted file mode 100644index b9a802fd14..0000000000--- a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.doc.mjs+++ /dev/null@@ -1,9 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ChatComposerDrawer — Follow-Up Questions',- description: 'Chat composer drawer with navigable follow-up questions and selectable lettered options. Use for multi-step clarification workflows.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['ChatComposer', 'Button', 'Icon', 'List', 'Badge', 'Text', 'Layout'],-};diff --git a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.tsx b/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.tsxdeleted file mode 100644index 40022e0314..0000000000--- a/packages/cli/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerFollowUpQuestions.tsx+++ /dev/null@@ -1,114 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSChatComposer, XDSChatComposerDrawer} from '@xds/core/Chat';-import {XDSButton} from '@xds/core/Button';-import {XDSIcon} from '@xds/core/Icon';-import {XDSList, XDSListItem} from '@xds/core/List';-import {XDSText} from '@xds/core/Text';-import {XDSBadge} from '@xds/core/Badge';-import {XDSStack} from '@xds/core/Layout';-import {ChevronLeftIcon, ChevronRightIcon} from '@heroicons/react/24/outline';--const questions = [- {- question: 'Which environment should this deploy to?',- options: [- {key: 'A', label: 'Production (requires approval)'},- {key: 'B', label: 'Staging'},- {key: 'C', label: 'Local development only'},- ],- },- {- question:- 'This will modify 12 files. How should I handle breaking changes?',- options: [- {key: 'A', label: 'Add a migration and keep backward compatibility'},- {- key: 'B',- label: 'Breaking change is fine \u2014 bump the major version',- },- ],- },- {- question: 'I found 3 existing implementations. Which one should I extend?',- options: [- {key: 'A', label: 'UserService in src/services/ (most recent)'},- {key: 'B', label: 'UserManager in src/legacy/ (has more test coverage)'},- {key: 'C', label: 'Neither \u2014 start fresh'},- ],- },-];--export default function ChatComposerDrawerFollowUpQuestions() {- const [currentQ, setCurrentQ] = useState(0);- const [answers, setAnswers] = useState<Record<number, string>>({});- const q = questions[currentQ];- const selected = answers[currentQ] ?? null;-- return (- <XDSStack direction="vertical" style={{width: '100%', maxWidth: 450}}>- <XDSChatComposer- onSubmit={value => {- console.log('Submit:', value, '| Answers:', answers);- }}- placeholder="Or describe what you need in your own words\u2026"- drawer={- <XDSChatComposerDrawer count={questions.length} label="Questions">- <XDSStack direction="vertical" gap={1} width="100%">- <XDSStack direction="horizontal" hAlign="between" vAlign="center">- <XDSButton- label="Previous question"- variant="ghost"- size="sm"- icon={<XDSIcon icon={ChevronLeftIcon} />}- isIconOnly- isDisabled={currentQ === 0}- onClick={() => setCurrentQ(i => i - 1)}- />- <XDSText color="secondary">- {currentQ + 1} of {questions.length}- </XDSText>- <XDSButton- label="Next question"- variant="ghost"- size="sm"- icon={<XDSIcon icon={ChevronRightIcon} />}- isIconOnly- isDisabled={currentQ === questions.length - 1}- onClick={() => setCurrentQ(i => i + 1)}- />- </XDSStack>- <XDSList>- <XDSListItem- label={- <XDSText weight="bold">- {currentQ + 1}. {q.question}- </XDSText>- }- />- {q.options.map(opt => (- <XDSListItem- key={opt.key}- label={opt.label}- startContent={- <XDSBadge- variant={selected === opt.key ? 'info' : 'neutral'}- label={opt.key}- />- }- isSelected={selected === opt.key}- onClick={() =>- setAnswers(prev => ({...prev, [currentQ]: opt.key}))- }- />- ))}- </XDSList>- </XDSStack>- </XDSChatComposerDrawer>- }- footerActions={<XDSButton label="Skip all" variant="ghost" size="md" />}- />- </XDSStack>- );-}