An open source design system that's fully customizable and agent ready
TypeScript
refactor(templates): tighten settings XDS purity (grade 90→97) (#2621)
rubyycheung53d0aae2201b
diff --git a/packages/cli/templates/pages/settings/page.tsx b/packages/cli/templates/pages/settings/page.tsxindex a2a2283658..2304aa27c2 100644--- a/packages/cli/templates/pages/settings/page.tsx+++ b/packages/cli/templates/pages/settings/page.tsx@@ -3,6 +3,7 @@'use client';import {useState} from 'react';+import {useMediaQuery} from '@xds/core/hooks';import {XDSVStack,XDSHStack,@@ -14,29 +15,25 @@ import {} from '@xds/core/Layout';import {XDSGrid} from '@xds/core/Grid';import {XDSList, XDSListItem} from '@xds/core/List';+import {XDSTabList, XDSTab} from '@xds/core/TabList';import {XDSText, XDSHeading} from '@xds/core/Text';import {XDSTextInput} from '@xds/core/TextInput';import {XDSButton} from '@xds/core/Button';import {XDSDivider} from '@xds/core/Divider';import {XDSCheckboxInput} from '@xds/core/CheckboxInput';-import {XDSSection} from '@xds/core/Section';import {XDSTypeahead} from '@xds/core/Typeahead';import * as stylex from '@stylexjs/stylex';-import {spacingVars} from '@xds/core/theme/tokens.stylex';import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';import type {XDSSearchableItem, XDSSearchSource} from '@xds/core/Typeahead';+// Caps + centers the whole layout shell (header + sidebar + content). XDSLayout+// has no max-width prop for the outer shell — contentWidth only caps slot+// content, not the sidebar/header. Tracked in #2625.const styles = stylex.create({constrainedShell: {maxWidth: 1440,marginInline: 'auto',},- headerPadding: {- padding: spacingVars['--spacing-4'],- },- sideNavWidth: {- minWidth: 260,- },});const NAV_ITEMS = [@@ -68,6 +65,7 @@ const settingsSearchSource: XDSSearchSource<XDSSearchableItem> = {};export default function SettingsTemplate() {+ const isNarrow = useMediaQuery('(max-width: 768px)');const [activeNav, setActiveNav] = useState('Profile');const [username, setUsername] = useState('nicol43');const [firstName, setFirstName] = useState('Stephanie');@@ -89,7 +87,7 @@ export default function SettingsTemplate() {xstyle={styles.constrainedShell}header={<XDSLayoutHeader hasDivider>- <XDSHStack vAlign="center" xstyle={styles.headerPadding}>+ <XDSHStack vAlign="center"><XDSStackItem size="fill"><XDSHeading level={1}>Settings</XDSHeading></XDSStackItem>@@ -107,11 +105,8 @@ export default function SettingsTemplate() {</XDSLayoutHeader>}start={- <XDSLayoutPanel hasDivider={false} padding={0}>- <XDSSection- padding={2}- variant="transparent"- xstyle={styles.sideNavWidth}>+ isNarrow ? undefined : (+ <XDSLayoutPanel hasDivider={false} width={260} padding={2}><XDSList density="balanced">{NAV_ITEMS.map(item => (<XDSListItem@@ -122,12 +117,23 @@ export default function SettingsTemplate() {/>))}</XDSList>- </XDSSection>- </XDSLayoutPanel>+ </XDSLayoutPanel>+ )}content={<XDSLayoutContent padding={4}><XDSVStack gap={4}>+ {/* Mobile: the sidebar nav collapses to a horizontal, centered+ tab bar above the content. */}+ {isNarrow && (+ <XDSVStack hAlign="center">+ <XDSTabList value={activeNav} onChange={setActiveNav}>+ {NAV_ITEMS.map(item => (+ <XDSTab key={item} value={item} label={item} />+ ))}+ </XDSTabList>+ </XDSVStack>+ )}<XDSGrid columns={{minWidth: 320}} gap={10}><XDSVStack gap={1}><XDSHeading level={3}>Basic information</XDSHeading>