An open source design system that's fully customizable and agent ready
TypeScript
refactor(templates): rename ToggleButton — With Label to ToggleButton — Label (#1698)
Kenton Quatman94ac048bf282
diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonColor.doc.mjs b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonColor.doc.mjsnew file mode 100644index 0000000000..e48b7c9bcb--- /dev/null+++ b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonColor.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'ToggleButton — Color',+ description: 'Toggle buttons with colored icons in the pressed state. Shows accent-colored toolbar formatting and semantic reaction colors (yellow star, red heart, blue bookmark).',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['ToggleButton', 'Layout', 'Text', 'Icon'],+};diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonColor.tsx b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonColor.tsxnew file mode 100644index 0000000000..9d00ca4bb0--- /dev/null+++ b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonColor.tsx@@ -0,0 +1,138 @@+'use client';++import {useState} from 'react';+import {XDSToggleButton} from '@xds/core/ToggleButton';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';+import {XDSIcon} from '@xds/core/Icon';+import {+ BoldIcon,+ ItalicIcon,+ UnderlineIcon,+ StrikethroughIcon,+ LinkIcon,+ StarIcon,+ BookmarkIcon,+ HeartIcon,+ BellIcon,+} from '@heroicons/react/24/outline';+import {+ BoldIcon as BoldSolid,+ ItalicIcon as ItalicSolid,+ UnderlineIcon as UnderlineSolid,+ StarIcon as StarSolid,+ BookmarkIcon as BookmarkSolid,+ HeartIcon as HeartSolid,+} from '@heroicons/react/24/solid';++export default function ToggleButtonColor() {+ const [toolbar, setToolbar] = useState<Record<string, boolean>>({+ bold: true,+ italic: false,+ underline: true,+ strikethrough: false,+ link: false,+ });+ const toggleToolbar = (key: string) =>+ setToolbar(prev => ({...prev, [key]: !prev[key]}));++ const [reactions, setReactions] = useState<Record<string, boolean>>({+ star: false,+ heart: false,+ bookmark: true,+ bell: false,+ });+ const toggleReaction = (key: string) =>+ setReactions(prev => ({...prev, [key]: !prev[key]}));++ return (+ <XDSStack direction="vertical" gap={4}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Toolbar+ </XDSText>+ <XDSStack direction="horizontal" gap={1}>+ <XDSToggleButton+ label="Bold"+ icon={<XDSIcon icon={BoldIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={BoldSolid} color="accent" />}+ isPressed={toolbar.bold}+ onPressedChange={() => toggleToolbar('bold')}+ isIconOnly+ />+ <XDSToggleButton+ label="Italic"+ icon={<XDSIcon icon={ItalicIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={ItalicSolid} color="accent" />}+ isPressed={toolbar.italic}+ onPressedChange={() => toggleToolbar('italic')}+ isIconOnly+ />+ <XDSToggleButton+ label="Underline"+ icon={<XDSIcon icon={UnderlineIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={UnderlineSolid} color="accent" />}+ isPressed={toolbar.underline}+ onPressedChange={() => toggleToolbar('underline')}+ isIconOnly+ />+ <XDSToggleButton+ label="Strikethrough"+ icon={<XDSIcon icon={StrikethroughIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={StrikethroughIcon} color="accent" />}+ isPressed={toolbar.strikethrough}+ onPressedChange={() => toggleToolbar('strikethrough')}+ isIconOnly+ />+ <XDSToggleButton+ label="Link"+ icon={<XDSIcon icon={LinkIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={LinkIcon} color="positive" />}+ isPressed={toolbar.link}+ onPressedChange={() => toggleToolbar('link')}+ isIconOnly+ />+ </XDSStack>+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Reactions+ </XDSText>+ <XDSStack direction="horizontal" gap={2}>+ <XDSToggleButton+ label="Star"+ icon={<XDSIcon icon={StarIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={StarSolid} color="yellow" />}+ isPressed={reactions.star}+ onPressedChange={() => toggleReaction('star')}+ isIconOnly+ />+ <XDSToggleButton+ label="Like"+ icon={<XDSIcon icon={HeartIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={HeartSolid} color="red" />}+ isPressed={reactions.heart}+ onPressedChange={() => toggleReaction('heart')}+ isIconOnly+ />+ <XDSToggleButton+ label="Save"+ icon={<XDSIcon icon={BookmarkIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={BookmarkSolid} color="blue" />}+ isPressed={reactions.bookmark}+ onPressedChange={() => toggleReaction('bookmark')}+ isIconOnly+ />+ <XDSToggleButton+ label="Follow"+ icon={<XDSIcon icon={BellIcon} color="secondary" />}+ pressedIcon={<XDSIcon icon={BellIcon} color="accent" />}+ isPressed={reactions.bell}+ onPressedChange={() => toggleReaction('bell')}+ isIconOnly+ />+ </XDSStack>+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonMultiSelect.doc.mjs b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonGroup.doc.mjssimilarity index 53%rename from packages/cli/templates/blocks/components/ToggleButton/ToggleButtonMultiSelect.doc.mjsrename to packages/cli/templates/blocks/components/ToggleButton/ToggleButtonGroup.doc.mjsindex 902f86b0f6..af8067c238 100644--- a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonMultiSelect.doc.mjs+++ b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonGroup.doc.mjs@@ -1,8 +1,8 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'ToggleButton — Multi Select',- description: 'Multi-select toggle group forming a text formatting toolbar. Multiple options can be active simultaneously — bold, italic, and underline.',+ name: 'ToggleButton — Group',+ description: 'Toggle button groups in single-select and multi-select modes. Single selection acts as a view mode switcher; multiple selection forms a formatting toolbar.',isReady: true,aspectRatio: 16 / 9,componentsUsed: ['ToggleButton', 'ToggleButtonGroup', 'Layout', 'Text', 'Icon'],diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonGroup.tsx b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonGroup.tsxnew file mode 100644index 0000000000..dc5cbf160e--- /dev/null+++ b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonGroup.tsx@@ -0,0 +1,79 @@+'use client';++import {useState} from 'react';+import {XDSToggleButton, XDSToggleButtonGroup} from '@xds/core/ToggleButton';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';+import {XDSIcon} from '@xds/core/Icon';+import {ListBulletIcon, Squares2X2Icon, TableCellsIcon} from '@heroicons/react/24/outline';+import {BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon} from '@heroicons/react/24/outline';++export default function ToggleButtonGroup() {+ const [view, setView] = useState<string | null>('list');+ const [formats, setFormats] = useState<string[]>(['bold']);++ return (+ <XDSStack direction="vertical" gap={4}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Single selection+ </XDSText>+ <XDSToggleButtonGroup value={view} onChange={setView} label="View mode">+ <XDSToggleButton+ value="list"+ label="List view"+ icon={<XDSIcon icon={ListBulletIcon} />}+ isIconOnly+ />+ <XDSToggleButton+ value="grid"+ label="Grid view"+ icon={<XDSIcon icon={Squares2X2Icon} />}+ isIconOnly+ />+ <XDSToggleButton+ value="table"+ label="Table view"+ icon={<XDSIcon icon={TableCellsIcon} />}+ isIconOnly+ />+ </XDSToggleButtonGroup>+ </XDSStack>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="supporting" color="secondary">+ Multiple selections+ </XDSText>+ <XDSToggleButtonGroup+ type="multiple"+ value={formats}+ onChange={setFormats}+ label="Text formatting">+ <XDSToggleButton+ value="bold"+ label="Bold"+ icon={<XDSIcon icon={BoldIcon} />}+ isIconOnly+ />+ <XDSToggleButton+ value="italic"+ label="Italic"+ icon={<XDSIcon icon={ItalicIcon} />}+ isIconOnly+ />+ <XDSToggleButton+ value="underline"+ label="Underline"+ icon={<XDSIcon icon={UnderlineIcon} />}+ isIconOnly+ />+ <XDSToggleButton+ value="strikethrough"+ label="Strikethrough"+ icon={<XDSIcon icon={StrikethroughIcon} />}+ isIconOnly+ />+ </XDSToggleButtonGroup>+ </XDSStack>+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonWithLabel.doc.mjs b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonLabel.doc.mjssimilarity index 91%rename from packages/cli/templates/blocks/components/ToggleButton/ToggleButtonWithLabel.doc.mjsrename to packages/cli/templates/blocks/components/ToggleButton/ToggleButtonLabel.doc.mjsindex aaa437f319..14af78f3ef 100644--- a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonWithLabel.doc.mjs+++ b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonLabel.doc.mjs@@ -1,7 +1,7 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'ToggleButton — With Label',+ name: 'ToggleButton — Label',description: 'Toggle buttons with visible text labels that show a font weight shift on press. Use when the icon alone is not enough to communicate the action.',isReady: true,aspectRatio: 16 / 9,diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonWithLabel.tsx b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonLabel.tsxsimilarity index 97%rename from packages/cli/templates/blocks/components/ToggleButton/ToggleButtonWithLabel.tsxrename to packages/cli/templates/blocks/components/ToggleButton/ToggleButtonLabel.tsxindex e5b40ddf0a..4611548d44 100644--- a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonWithLabel.tsx+++ b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonLabel.tsx@@ -7,7 +7,7 @@ import {XDSText} from '@xds/core/Text';import {XDSIcon} from '@xds/core/Icon';import {EyeIcon, EyeSlashIcon, FunnelIcon, MapPinIcon} from '@heroicons/react/24/outline';-export default function ToggleButtonWithLabel() {+export default function ToggleButtonLabel() {const [isVisible, setIsVisible] = useState(true);const [filters, setFilters] = useState<string[]>([]);diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonMultiSelect.tsx b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonMultiSelect.tsxdeleted file mode 100644index 22a802fa8b..0000000000--- a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonMultiSelect.tsx+++ /dev/null@@ -1,50 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSToggleButton, XDSToggleButtonGroup} from '@xds/core/ToggleButton';-import {XDSStack} from '@xds/core/Layout';-import {XDSText} from '@xds/core/Text';-import {XDSIcon} from '@xds/core/Icon';-import {BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon} from '@heroicons/react/24/outline';--export default function ToggleButtonMultiSelect() {- const [formats, setFormats] = useState<string[]>(['bold']);-- return (- <XDSStack direction="vertical" gap={4}>- <XDSText type="supporting" color="secondary">- Text formatting — multiple active at once- </XDSText>- <XDSToggleButtonGroup- type="multiple"- value={formats}- onChange={setFormats}- label="Text formatting">- <XDSToggleButton- value="bold"- label="Bold"- icon={<XDSIcon icon={BoldIcon} />}- isIconOnly- />- <XDSToggleButton- value="italic"- label="Italic"- icon={<XDSIcon icon={ItalicIcon} />}- isIconOnly- />- <XDSToggleButton- value="underline"- label="Underline"- icon={<XDSIcon icon={UnderlineIcon} />}- isIconOnly- />- <XDSToggleButton- value="strikethrough"- label="Strikethrough"- icon={<XDSIcon icon={StrikethroughIcon} />}- isIconOnly- />- </XDSToggleButtonGroup>- </XDSStack>- );-}diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonSingleSelect.doc.mjs b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonSingleSelect.doc.mjsdeleted file mode 100644index 115498e468..0000000000--- a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonSingleSelect.doc.mjs+++ /dev/null@@ -1,9 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'ToggleButton — Single Select',- description: 'Single-select toggle group acting as a view mode switcher. Only one option can be active at a time — clicking the active button deselects it.',- isReady: true,- aspectRatio: 16 / 9,- componentsUsed: ['ToggleButton', 'ToggleButtonGroup', 'Layout', 'Text', 'Icon'],-};diff --git a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonSingleSelect.tsx b/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonSingleSelect.tsxdeleted file mode 100644index 1edad146da..0000000000--- a/packages/cli/templates/blocks/components/ToggleButton/ToggleButtonSingleSelect.tsx+++ /dev/null@@ -1,40 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSToggleButton, XDSToggleButtonGroup} from '@xds/core/ToggleButton';-import {XDSStack} from '@xds/core/Layout';-import {XDSText} from '@xds/core/Text';-import {XDSIcon} from '@xds/core/Icon';-import {ListBulletIcon, Squares2X2Icon, TableCellsIcon} from '@heroicons/react/24/outline';--export default function ToggleButtonSingleSelect() {- const [view, setView] = useState<string | null>('list');-- return (- <XDSStack direction="vertical" gap={4}>- <XDSText type="supporting" color="secondary">- View mode switcher — one active at a time- </XDSText>- <XDSToggleButtonGroup value={view} onChange={setView} label="View mode">- <XDSToggleButton- value="list"- label="List view"- icon={<XDSIcon icon={ListBulletIcon} />}- isIconOnly- />- <XDSToggleButton- value="grid"- label="Grid view"- icon={<XDSIcon icon={Squares2X2Icon} />}- isIconOnly- />- <XDSToggleButton- value="table"- label="Table view"- icon={<XDSIcon icon={TableCellsIcon} />}- isIconOnly- />- </XDSToggleButtonGroup>- </XDSStack>- );-}