An open source design system that's fully customizable and agent ready
TypeScript
feat(sandbox): add settings template variants (#1050)
rubyycheungfa91f76dc226
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/template-settings-02/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/template-settings-02/page.tsxnew file mode 100644index 0000000000..98d652e64e--- /dev/null+++ b/apps/sandbox/src/app/(fullscreen)/pages/template-settings-02/page.tsx@@ -0,0 +1,556 @@+'use client';++import {useState} from 'react';+import * as stylex from '@stylexjs/stylex';+import {XDSVStack} from '@xds/core/Layout';+import {XDSList, XDSListItem} from '@xds/core/List';+import {XDSText, XDSHeading} from '@xds/core/Text';+import {XDSLink} from '@xds/core/Link';+import {XDSCard} from '@xds/core/Card';+import {XDSSwitch} from '@xds/core/Switch';+import {XDSDivider} from '@xds/core/Divider';+import {XDSTabList, XDSTab} from '@xds/core/TabList';+import {XDSBadge} from '@xds/core/Badge';+import {colorVars} from '@xds/core/theme/tokens.stylex';+import {+ UserIcon,+ LockClosedIcon,+ ShieldCheckIcon,+ BellIcon,+ DocumentTextIcon,+ CreditCardIcon,+ GlobeAltIcon,+ BriefcaseIcon,+ WrenchScrewdriverIcon,+ ComputerDesktopIcon,+} from '@heroicons/react/24/outline';++const styles = stylex.create({+ pageBg: {+ backgroundColor: colorVars['--color-background-surface'],+ },+ flatCard: {+ backgroundColor: colorVars['--color-background-body'],+ borderWidth: 0,+ },+});++const NAV_ITEMS = [+ {label: 'Personal information', icon: UserIcon},+ {label: 'Login & security', icon: LockClosedIcon},+ {label: 'Privacy', icon: ShieldCheckIcon},+ {label: 'Notifications', icon: BellIcon},+ {label: 'Taxes', icon: DocumentTextIcon},+ {label: 'Payments', icon: CreditCardIcon},+ {label: 'Languages & currency', icon: GlobeAltIcon},+ {label: 'Travel for work', icon: BriefcaseIcon},+];++interface InfoRow {+ label: string;+ value: string;+ action: string;+ icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;+}++const LOGIN_ROWS: InfoRow[] = [+ {label: 'Password', value: 'Not created', action: 'Create'},+];++const SOCIAL_ROWS: InfoRow[] = [+ {label: 'Google', value: 'Connected', action: 'Disconnect'},+];++const DEVICE_ROWS: {+ label: string;+ badge?: string;+ location: string;+ action?: string;+}[] = [+ {+ label: 'OS X 10.15.7 · Chrome',+ badge: 'CURRENT SESSION',+ location: 'McKinney, Texas · March 30, 2026 at 19:31',+ },+ {label: 'Session', location: 'August 9, 2023 at 04:19', action: 'Log out'},+ {+ label: 'OS X 10.15.7 · unknown',+ location: 'Sunnyvale, California · April 14, 2023 at 17:47',+ action: 'Log out',+ },+];++function InfoRowItem({label, value, action}: InfoRow) {+ return (+ <>+ <div+ style={{+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'flex-start',+ padding: '16px 0',+ }}>+ <div>+ <XDSText type="body" weight="semibold" display="block">+ {label}+ </XDSText>+ <XDSText type="supporting" color="secondary" display="block">+ {value}+ </XDSText>+ </div>+ <XDSLink label={action} href="#">+ {action}+ </XDSLink>+ </div>+ <XDSDivider />+ </>+ );+}++export default function SettingsSecurityTemplate() {+ const [activeNav, setActiveNav] = useState('Login & security');+ const [activeTab, setActiveTab] = useState('login');+ const [readReceipts, setReadReceipts] = useState(true);+ const [searchEngines, setSearchEngines] = useState(true);+ const [showCity, setShowCity] = useState(true);+ const [showTripType, setShowTripType] = useState(true);+ const [showStayLength, setShowStayLength] = useState(true);+ const [showServices, setShowServices] = useState(true);+ const [aiFeatures, setAiFeatures] = useState(true);++ return (+ <div+ {...stylex.props(styles.pageBg)}+ style={{minHeight: '100svh', display: 'flex', flexDirection: 'column'}}>+ {/* Body — constrained */}+ <div+ style={{+ display: 'flex',+ flex: 1,+ maxWidth: 1000,+ margin: '0 auto',+ width: '100%',+ }}>+ {/* Sidebar */}+ <nav+ style={{+ width: 280,+ paddingTop: 16,+ paddingLeft: 12,+ paddingRight: 12,+ paddingBottom: 16,+ borderRight: '1px solid var(--xds-color-border-primary, #e5e5e5)',+ flexShrink: 0,+ overflowY: 'auto',+ }}>+ <XDSVStack gap={4}>+ <div style={{paddingLeft: 16, paddingRight: 16}}>+ <XDSHeading level={2}>Account settings</XDSHeading>+ </div>+ <XDSList density="spacious">+ {NAV_ITEMS.map(item => (+ <XDSListItem+ key={item.label}+ label={item.label}+ startContent={<item.icon style={{width: 20, height: 20}} />}+ isSelected={activeNav === item.label}+ onClick={() => setActiveNav(item.label)}+ />+ ))}+ </XDSList>+ <XDSDivider />+ <XDSList density="spacious">+ <XDSListItem+ label="Professional hosting tools"+ startContent={+ <WrenchScrewdriverIcon style={{width: 20, height: 20}} />+ }+ onClick={() => {}}+ />+ </XDSList>+ </XDSVStack>+ </nav>++ {/* Content */}+ <div+ style={{+ flex: 1,+ paddingTop: 16,+ paddingLeft: 32,+ paddingRight: 32,+ paddingBottom: 16,+ overflowY: 'auto',+ }}>+ {activeNav === 'Login & security' && (+ <XDSVStack gap={6}>+ <XDSHeading level={2}>Login & security</XDSHeading>++ <div style={{marginLeft: -12, overflow: 'hidden'}}>+ <XDSTabList+ value={activeTab}+ onChange={setActiveTab}+ hasDivider>+ <XDSTab value="login" label="Login" />+ <XDSTab value="shared" label="Shared access" />+ </XDSTabList>+ </div>++ {activeTab === 'login' && (+ <XDSVStack gap={8}>+ {/* Login section */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Login</XDSHeading>+ <div style={{marginTop: 8}}>+ <XDSDivider />+ </div>+ {LOGIN_ROWS.map(row => (+ <InfoRowItem key={row.label} {...row} />+ ))}+ </XDSVStack>++ {/* Social accounts */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Social accounts</XDSHeading>+ <div style={{marginTop: 8}}>+ <XDSDivider />+ </div>+ {SOCIAL_ROWS.map(row => (+ <InfoRowItem key={row.label} {...row} />+ ))}+ </XDSVStack>++ {/* Device history */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Device history</XDSHeading>+ <div style={{marginTop: 8}}>+ <XDSDivider />+ </div>+ {DEVICE_ROWS.map((device, i) => (+ <div key={i}>+ <div+ style={{+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'flex-start',+ padding: '16px 0',+ gap: 12,+ }}>+ <ComputerDesktopIcon+ style={{+ width: 32,+ height: 32,+ flexShrink: 0,+ marginTop: 2,+ }}+ />+ <div style={{flex: 1}}>+ <div+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: 8,+ }}>+ <XDSText type="body" weight="semibold">+ {device.label}+ </XDSText>+ {device.badge && (+ <XDSBadge label={device.badge} />+ )}+ </div>+ <XDSText type="supporting" color="secondary">+ {device.location}+ </XDSText>+ </div>+ {device.action && (+ <XDSLink label={device.action} href="#">+ {device.action}+ </XDSLink>+ )}+ </div>+ <XDSDivider />+ </div>+ ))}+ </XDSVStack>++ {/* Account */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Account</XDSHeading>+ <div style={{marginTop: 8}}>+ <XDSDivider />+ </div>+ <div+ style={{+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'flex-start',+ padding: '16px 0',+ }}>+ <div>+ <XDSText type="body" weight="semibold" display="block">+ Deactivate your account+ </XDSText>+ <XDSText+ type="supporting"+ color="secondary"+ display="block">+ This action cannot be undone+ </XDSText>+ </div>+ <XDSLink label="Deactivate" href="#">+ Deactivate+ </XDSLink>+ </div>+ <XDSDivider />+ </XDSVStack>+ </XDSVStack>+ )}++ {activeTab === 'shared' && (+ <XDSVStack gap={8}>+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Shared access</XDSHeading>+ <div style={{marginTop: 8}}>+ <XDSDivider />+ </div>+ <div style={{paddingTop: 16}}>+ <XDSText type="body" color="secondary">+ Review each request carefully before approving access.+ We'll email your employee or co-worker a 4-digit+ code that lets them log into your account with their+ trusted device.+ </XDSText>+ </div>+ </XDSVStack>++ <XDSCard+ padding={4}+ xstyle={styles.flatCard}>+ <div+ style={{+ display: 'flex',+ gap: 16,+ alignItems: 'flex-start',+ }}>+ <div+ style={{+ width: 48,+ height: 48,+ borderRadius: 12,+ backgroundColor:+ 'var(--xds-color-background-surface, #fff)',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ flexShrink: 0,+ }}>+ <LockClosedIcon style={{width: 24, height: 24}} />+ </div>+ <XDSVStack gap={1}>+ <XDSText type="body" weight="bold">+ Adding devices from people you trust+ </XDSText>+ <XDSText type="body" color="secondary">+ When you approve a request, you grant someone full+ access to your account. They'll be able to change+ reservations and send messages on your behalf.+ </XDSText>+ </XDSVStack>+ </div>+ </XDSCard>+ </XDSVStack>+ )}+ </XDSVStack>+ )}++ {activeNav === 'Privacy' && (+ <XDSVStack gap={6}>+ <XDSHeading level={2}>Privacy</XDSHeading>++ <XDSVStack gap={8}>+ {/* Messages */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Messages</XDSHeading>+ <div style={{marginTop: 16}}>+ <XDSSwitch+ label="Show people when I've read their messages."+ value={readReceipts}+ onChange={setReadReceipts}+ labelPosition="start"+ labelSpacing="spread"+ />+ </div>+ <div style={{padding: '16px 0'}}>+ <div+ style={{+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'center',+ }}>+ <XDSText type="body" weight="semibold">+ Blocked people+ </XDSText>+ <XDSLink label="View" href="#">+ View+ </XDSLink>+ </div>+ </div>+ <XDSDivider />+ </XDSVStack>++ {/* Listings */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Listings</XDSHeading>+ <div style={{marginTop: 16}}>+ <XDSSwitch+ label="Include my listing(s) in search engines"+ description="Turning this on means search engines, like Google, will display your listing page(s) in search results."+ value={searchEngines}+ onChange={setSearchEngines}+ labelPosition="start"+ labelSpacing="spread"+ />+ </div>+ <div style={{marginTop: 8}}>+ <XDSDivider />+ </div>+ </XDSVStack>++ {/* Reviews */}+ <XDSVStack gap={0}>+ <XDSHeading level={3}>Reviews</XDSHeading>+ <div>+ <XDSText type="supporting" color="secondary">+ Choose what's shared when you write a review.{' '}+ <XDSLink label="Learn more" href="#" type="supporting">+ Learn more+ </XDSLink>+ </XDSText>+ </div>+ <div style={{marginTop: 16}}>+ <XDSVStack gap={4}>+ <XDSSwitch+ label="Show my home city and country"+ description="Ex: City and country"+ value={showCity}+ onChange={setShowCity}+ labelPosition="start"+ labelSpacing="spread"+ />+ <XDSSwitch+ label="Show my trip type"+ description="Ex: Stayed with kids or pets"+ value={showTripType}+ onChange={setShowTripType}+ labelPosition="start"+ labelSpacing="spread"+ />+ <XDSSwitch+ label="Show my length of stay"+ description="Ex: A few nights, about a week, etc."+ value={showStayLength}+ onChange={setShowStayLength}+ labelPosition="start"+ labelSpacing="spread"+ />+ <XDSSwitch+ label="Show my booked services"+ description="Ex: Gourmet brunch or tasting menu"+ value={showServices}+ onChange={setShowServices}+ labelPosition="start"+ labelSpacing="spread"+ />+ </XDSVStack>+ </div>+ <div style={{marginTop: 16}}>+ <XDSDivider />+ </div>+ </XDSVStack>++ {/* Data privacy */}+ <XDSVStack gap={4}>+ <XDSHeading level={3}>Data privacy</XDSHeading>+ <XDSCard padding={4}>+ <div+ style={{+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'center',+ }}>+ <XDSText type="body">Request my personal data</XDSText>+ <XDSLink label="Request" href="#">+ Request+ </XDSLink>+ </div>+ </XDSCard>+ <XDSSwitch+ label="Help improve AI-powered features"+ description="When this is on, we use your data to develop and improve AI models."+ value={aiFeatures}+ onChange={setAiFeatures}+ labelPosition="start"+ labelSpacing="spread"+ />+ <XDSCard padding={4}>+ <div+ style={{+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'center',+ }}>+ <XDSText type="body">Delete my account</XDSText>+ <XDSLink label="Delete" href="#">+ Delete+ </XDSLink>+ </div>+ </XDSCard>+ <XDSCard+ padding={4}+ xstyle={styles.flatCard}>+ <div+ style={{+ display: 'flex',+ gap: 16,+ alignItems: 'flex-start',+ }}>+ <div+ style={{+ width: 48,+ height: 48,+ borderRadius: 12,+ backgroundColor:+ 'var(--xds-color-background-surface, #fff)',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ flexShrink: 0,+ }}>+ <ShieldCheckIcon style={{width: 24, height: 24}} />+ </div>+ <XDSVStack gap={1}>+ <XDSText type="body" weight="bold">+ Committed to privacy+ </XDSText>+ <XDSText type="supporting" color="secondary">+ We're committed to keeping your data protected.+ See details in our{' '}+ <XDSLink+ label="Privacy Policy"+ href="#"+ type="supporting">+ Privacy Policy+ </XDSLink>+ .+ </XDSText>+ </XDSVStack>+ </div>+ </XDSCard>+ </XDSVStack>+ </XDSVStack>+ </XDSVStack>+ )}+ </div>+ </div>+ </div>+ );+}diff --git a/apps/sandbox/src/app/(fullscreen)/pages/template-settings/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/template-settings/page.tsxindex 3eb851504a..938bb42b10 100644--- a/apps/sandbox/src/app/(fullscreen)/pages/template-settings/page.tsx+++ b/apps/sandbox/src/app/(fullscreen)/pages/template-settings/page.tsx@@ -9,6 +9,9 @@ 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 {XDSTypeahead} from '@xds/core/Typeahead';+import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';+import type {XDSSearchableItem, XDSSearchSource} from '@xds/core/Typeahead';const styles = stylex.create({sidebarItem: {@@ -22,7 +25,33 @@ const styles = stylex.create({},});-const NAV_ITEMS = ['Profile', 'Account', 'Members', 'Billing', 'Invoices', 'API'];+const NAV_ITEMS = [+ 'Profile',+ 'Account',+ 'Members',+ 'Billing',+ 'Invoices',+ 'API',+];++const SETTINGS_ITEMS: XDSSearchableItem[] = [+ {id: '1', label: 'Username'},+ {id: '2', label: 'First name'},+ {id: '3', label: 'Last name'},+ {id: '4', label: 'Email address'},+ {id: '5', label: 'Change password'},+ {id: '6', label: 'Data Export Access'},+ {id: '7', label: 'Allow Admin to Add Members'},+ {id: '8', label: 'Two-Factor Authentication'},+];++const settingsSearchSource: XDSSearchSource<XDSSearchableItem> = {+ search: (query: string) =>+ SETTINGS_ITEMS.filter(item =>+ item.label.toLowerCase().includes(query.toLowerCase()),+ ),+ bootstrap: () => SETTINGS_ITEMS,+};export default function SettingsTemplate() {const [activeNav, setActiveNav] = useState('Profile');@@ -36,21 +65,66 @@ export default function SettingsTemplate() {const [dataExport, setDataExport] = useState(false);const [adminMembers, setAdminMembers] = useState(false);const [twoFactor, setTwoFactor] = useState(false);+ const [searchValue, setSearchValue] = useState<XDSSearchableItem | null>(+ null,+ );return (- <div style={{height: '100svh', display: 'flex', flexDirection: 'column', overflow: 'hidden'}}>- {/* Header */}- <div style={{display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: 16, borderBottom: '1px solid var(--xds-color-border-primary, #e5e5e5)', flexShrink: 0}}>- <XDSHeading level={1}>Settings</XDSHeading>- <div style={{width: 240}}>- <XDSTextInput label="Search" isLabelHidden placeholder="Search" value="" onChange={() => {}} />+ <div+ style={{minHeight: '100svh', display: 'flex', flexDirection: 'column'}}>+ {/* Header — full width with edge-to-edge divider */}+ <div+ style={{+ borderBottom: '1px solid var(--xds-color-border-primary, #e5e5e5)',+ flexShrink: 0,+ }}>+ <div+ style={{+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'space-between',+ padding: '16px 16px',+ maxWidth: 1000,+ margin: '0 auto',+ }}>+ <XDSHeading level={1}>Settings</XDSHeading>+ <div style={{width: 344}}>+ <XDSTypeahead+ label="Search"+ isLabelHidden+ placeholder="Search settings..."+ searchSource={settingsSearchSource}+ value={searchValue}+ onChange={setSearchValue}+ hasEntriesOnFocus+ startIcon={MagnifyingGlassIcon}+ />+ </div></div></div>- {/* Body */}- <div style={{display: 'flex', flex: 1, overflow: 'hidden'}}>+ {/* Body — constrained */}+ <div+ style={{+ display: 'flex',+ flex: 1,+ overflow: 'hidden',+ maxWidth: 1000,+ margin: '0 auto',+ width: '100%',+ }}>{/* Sidebar */}- <nav style={{width: 200, padding: 8, borderRight: '1px solid var(--xds-color-border-primary, #e5e5e5)', flexShrink: 0, overflowY: 'auto'}}>+ <nav+ style={{+ width: 240,+ paddingTop: 16,+ paddingLeft: 12,+ paddingRight: 12,+ paddingBottom: 8,+ borderRight: '1px solid var(--xds-color-border-primary, #e5e5e5)',+ flexShrink: 0,+ overflowY: 'auto',+ }}><XDSList density="compact">{NAV_ITEMS.map(item => (<XDSListItem@@ -65,23 +139,45 @@ export default function SettingsTemplate() {{/* Content */}<div style={{flex: 1, padding: 16, maxWidth: 960, overflowY: 'auto'}}>- <XDSVStack gap={8}>+ <XDSVStack gap={4}>{/* Basic information */}- <div style={{display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 40}}>+ <div+ style={{+ display: 'grid',+ gridTemplateColumns: '1fr 1fr',+ gap: 40,+ }}><div><XDSVStack gap={1}><XDSHeading level={3}>Basic information</XDSHeading><XDSText type="supporting" color="secondary">- View and update your personal details and account information.+ View and update your personal details and account+ information.</XDSText></XDSVStack></div><div><XDSVStack gap={4}>- <XDSTextInput label="Username" value={username} onChange={setUsername} />- <XDSTextInput label="First name" value={firstName} onChange={setFirstName} />- <XDSTextInput label="Last name" value={lastName} onChange={setLastName} />- <XDSTextInput label="Email address" value={email} onChange={setEmail} />+ <XDSTextInput+ label="Username"+ value={username}+ onChange={setUsername}+ />+ <XDSTextInput+ label="First name"+ value={firstName}+ onChange={setFirstName}+ />+ <XDSTextInput+ label="Last name"+ value={lastName}+ onChange={setLastName}+ />+ <XDSTextInput+ label="Email address"+ value={email}+ onChange={setEmail}+ /><div><XDSButton label="Save" variant="primary" /></div>@@ -92,7 +188,12 @@ export default function SettingsTemplate() {<XDSDivider />{/* Change password */}- <div style={{display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 40}}>+ <div+ style={{+ display: 'grid',+ gridTemplateColumns: '1fr 1fr',+ gap: 40,+ }}><div><XDSVStack gap={1}><XDSHeading level={3}>Change password</XDSHeading>@@ -103,9 +204,24 @@ export default function SettingsTemplate() {</div><div><XDSVStack gap={4}>- <XDSTextInput label="Verify current password" type="password" value={currentPw} onChange={setCurrentPw} />- <XDSTextInput label="New password" type="password" value={newPw} onChange={setNewPw} />- <XDSTextInput label="Confirm password" type="password" value={confirmPw} onChange={setConfirmPw} />+ <XDSTextInput+ label="Verify current password"+ type="password"+ value={currentPw}+ onChange={setCurrentPw}+ />+ <XDSTextInput+ label="New password"+ type="password"+ value={newPw}+ onChange={setNewPw}+ />+ <XDSTextInput+ label="Confirm password"+ type="password"+ value={confirmPw}+ onChange={setConfirmPw}+ /><div><XDSButton label="Save" variant="primary" /></div>@@ -116,7 +232,12 @@ export default function SettingsTemplate() {<XDSDivider />{/* Advanced settings */}- <div style={{display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 40}}>+ <div+ style={{+ display: 'grid',+ gridTemplateColumns: '1fr 1fr',+ gap: 40,+ }}><div><XDSVStack gap={1}><XDSHeading level={3}>Advanced settings</XDSHeading>diff --git a/apps/sandbox/src/app/sandboxPages.ts b/apps/sandbox/src/app/sandboxPages.tsindex dda40938ab..cbe3ae7f74 100644--- a/apps/sandbox/src/app/sandboxPages.ts+++ b/apps/sandbox/src/app/sandboxPages.ts@@ -108,6 +108,12 @@ export const categories: SandboxCategory[] = [href: '/pages/template-settings/',description: 'Settings page with tabs, forms, and toggles',},+ {+ name: 'Settings (Account)',+ href: '/pages/template-settings-02/',+ description:+ 'Account settings with sidebar nav, info rows, and device history',+ },{name: 'Data Table',href: '/pages/template-data-table/',