An open source design system that's fully customizable and agent ready
TypeScript
fix(templates): improve CommandPalette blocks (#1627)
Cindy Zhangb29d85c91285
diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAsyncSearch.doc.mjs b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAsyncSearch.doc.mjsindex f53ba57e2f..dda291c807 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAsyncSearch.doc.mjs+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAsyncSearch.doc.mjs@@ -6,5 +6,5 @@ export const doc = {'Server-side search with loading spinner and custom empty states.',isReady: true,aspectRatio: 4 / 3,- componentsUsed: ['CommandPalette', 'Button'],+ componentsUsed: ['CommandPalette', 'CommandPaletteInput', 'Button'],};diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAutoGrouped.doc.mjs b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAutoGrouped.doc.mjsindex 08b532598f..965263a1d0 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAutoGrouped.doc.mjs+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteAutoGrouped.doc.mjs@@ -1,9 +1,9 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'CommandPalette — Auto Grouped',+ name: 'CommandPalette — Grouped',description:- 'Command palette with items automatically grouped via auxiliaryData.group.',+ 'Command palette with items grouped via auxiliaryData.group.',isReady: true,aspectRatio: 4 / 3,componentsUsed: ['CommandPalette', 'Button'],diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.doc.mjs b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.doc.mjsindex 974c2a5341..efa9e84a26 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.doc.mjs+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.doc.mjs@@ -5,5 +5,5 @@ export const doc = {description: 'Command palette with a custom footer tip message.',isReady: true,aspectRatio: 4 / 3,- componentsUsed: ['CommandPalette', 'Button'],+ componentsUsed: ['CommandPalette', 'CommandPaletteFooter', 'Button', 'Text'],};diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.tsx b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.tsxindex bfc5cf989c..ca7588b8e8 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.tsx+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteCustomFooter.tsx@@ -6,6 +6,7 @@ import {XDSCommandPaletteFooter,} from '@xds/core/CommandPalette';import {XDSButton} from '@xds/core/Button';+import {XDSText} from '@xds/core/Text';import {createStaticSource} from '@xds/core/Typeahead';export default function CommandPaletteCustomFooter() {@@ -28,7 +29,7 @@ export default function CommandPaletteCustomFooter() {searchSource={source}footer={<XDSCommandPaletteFooter>- <span>Pro tip: use ⌘K to open anywhere</span>+ <XDSText type="supporting">Pro tip: use ⌘K to open anywhere</XDSText></XDSCommandPaletteFooter>}/>diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.doc.mjs b/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.doc.mjsindex 00a7bf8d33..2cf5a05cb8 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.doc.mjs+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.doc.mjs@@ -6,5 +6,5 @@ export const doc = {'Single-value picker with persistent selection and check indicator.',isReady: true,aspectRatio: 4 / 3,- componentsUsed: ['CommandPalette', 'Button', 'Icon'],+ componentsUsed: ['CommandPalette', 'Button', 'Text', 'Icon'],};diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.tsx b/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.tsxindex 878860d545..e8d610e3a6 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.tsx+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPalettePickerMode.tsx@@ -3,6 +3,7 @@import {useState, useMemo} from 'react';import {XDSCommandPalette} from '@xds/core/CommandPalette';import {XDSButton} from '@xds/core/Button';+import {XDSText} from '@xds/core/Text';import {XDSIcon} from '@xds/core/Icon';import {createStaticSource} from '@xds/core/Typeahead';@@ -32,11 +33,12 @@ export default function CommandPalettePickerMode() {setIsOpen(false);}}renderItem={(item, isSelected) => (- <span- style={{display: 'flex', alignItems: 'center', gap: 8, flex: 1}}>- <span style={{flex: 1}}>{item.label}</span>+ <>+ <XDSText type="body" style={{flex: 1}}>+ {item.label}+ </XDSText>{isSelected && <XDSIcon icon="check" size="sm" />}- </span>+ </>)}/></>diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.doc.mjs b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.doc.mjsindex db82189546..4943a8c28e 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.doc.mjs+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.doc.mjs@@ -6,5 +6,5 @@ export const doc = {'Custom item rendering with icons, keyboard shortcuts, and keyword search.',isReady: true,aspectRatio: 4 / 3,- componentsUsed: ['CommandPalette', 'Button', 'Icon'],+ componentsUsed: ['CommandPalette', 'Button', 'Text', 'Kbd'],};diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.tsx b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.tsxindex a715af18b5..ce86bf2ddf 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.tsx+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteRichItems.tsx@@ -3,6 +3,8 @@import {useState, useMemo} from 'react';import {XDSCommandPalette} from '@xds/core/CommandPalette';import {XDSButton} from '@xds/core/Button';+import {XDSText} from '@xds/core/Text';+import {XDSKbd} from '@xds/core/Kbd';import {createStaticSource} from '@xds/core/Typeahead';import type {XDSSearchableItem} from '@xds/core/Typeahead';@@ -20,7 +22,7 @@ const commands: RichCommand[] = [{id: 'settings',label: 'Open Settings',- auxiliaryData: {group: 'Navigation', shortcut: '⌘,'},+ auxiliaryData: {group: 'Navigation', shortcut: 'mod+,'},},{id: 'profile',@@ -35,12 +37,12 @@ const commands: RichCommand[] = [{id: 'new-file',label: 'Create New File',- auxiliaryData: {group: 'Actions', shortcut: '⌘N'},+ auxiliaryData: {group: 'Actions', shortcut: 'mod+n'},},{id: 'search',label: 'Search Files',- auxiliaryData: {group: 'Actions', shortcut: '⌘P'},+ auxiliaryData: {group: 'Actions', shortcut: 'mod+p'},},];@@ -56,15 +58,14 @@ export default function CommandPaletteRichItems() {onOpenChange={setIsOpen}searchSource={source}renderItem={(item: RichCommand) => (- <span- style={{display: 'flex', alignItems: 'center', gap: 8, flex: 1}}>- <span style={{flex: 1}}>{item.label}</span>+ <>+ <XDSText type="body" style={{flex: 1}}>+ {item.label}+ </XDSText>{item.auxiliaryData?.shortcut && (- <span style={{fontSize: 12, opacity: 0.5}}>- {item.auxiliaryData.shortcut}- </span>+ <XDSKbd keys={item.auxiliaryData.shortcut} />)}- </span>+ </>)}/></>diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.doc.mjs b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.doc.mjsindex 864ad825fd..b1c7f923b5 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.doc.mjs+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.doc.mjs@@ -2,7 +2,9 @@export const doc = {type: 'block',name: 'CommandPalette',+ description: 'Basic command palette with static items and keyboard navigation.',isReady: true,aspectRatio: 1,isShowcase: true,+ componentsUsed: ['CommandPalette', 'Button'],};diff --git a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.tsx b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.tsxindex 13a2944cfa..a3e13c6ecd 100644--- a/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.tsx+++ b/packages/cli/templates/blocks/components/CommandPalette/CommandPaletteShowcase.tsx@@ -1,24 +1,30 @@'use client';+import {useState, useMemo} from 'react';import {XDSCommandPalette} from '@xds/core/CommandPalette';import {XDSButton} from '@xds/core/Button';import {createStaticSource} from '@xds/core/Typeahead';-const source = createStaticSource([- {id: 'home', label: 'Home'},- {id: 'settings', label: 'Settings'},- {id: 'profile', label: 'Profile'},- {id: 'dashboard', label: 'Dashboard'},- {id: 'help', label: 'Help'},-]);-export default function CommandPaletteShowcase() {+ const [isOpen, setIsOpen] = useState(false);+ const source = useMemo(+ () =>+ createStaticSource([+ {id: 'home', label: 'Home'},+ {id: 'settings', label: 'Settings'},+ {id: 'profile', label: 'Profile'},+ {id: 'dashboard', label: 'Dashboard'},+ {id: 'help', label: 'Help'},+ ]),+ [],+ );+return (<>- <XDSButton label="Open Command Palette" onClick={() => {}} />+ <XDSButton label="Open Command Palette" onClick={() => setIsOpen(true)} /><XDSCommandPalette- isOpen={false}- onOpenChange={() => {}}+ isOpen={isOpen}+ onOpenChange={setIsOpen}searchSource={source}/></>