Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

refactor(templates): upgrade documentation template to Grade A (#1509)

rubyycheunge8f20b72c48f
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx
index 2be47f73aa..7363ebc7ed 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx
@@ -1,6 +1,7 @@
'use client';
import React, {useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
import {XDSAppShell} from '@xds/core/AppShell';
import {XDSTopNav, XDSTopNavHeading} from '@xds/core/TopNav';
import {XDSSideNav, XDSSideNavItem, XDSSideNavSection} from '@xds/core/SideNav';
@@ -27,6 +28,13 @@ import {
getComponentDocs,
} from './docsview-data';
+const localStyles = stylex.create({
+ previewCard: {
+ borderRadius: 12,
+ cursor: 'pointer',
+ },
+});
+
const XDS_WORDMARK = (
<svg
width="46"
@@ -216,31 +224,19 @@ export function DocsView({
}}
style={{cursor: 'pointer'}}>
<XDSCard
+ variant="muted"
padding={0}
- style={{
- border: 'none',
- boxShadow: 'none',
- outline: 'none',
- }}>
- <div
- style={{
- height: 160,
- backgroundColor:
- 'var(--color-background-muted, #c4cdd5)',
- borderRadius: 12,
- }}
- />
- <div style={{padding: '12px 0 0'}}>
- <XDSText type="body" style={{fontWeight: 700}}>
- {item.name}
- </XDSText>
- <div style={{marginTop: 0}}>
- <XDSText type="body" color="secondary">
- {item.desc}
- </XDSText>
- </div>
- </div>
- </XDSCard>
+ minHeight={160}
+ xstyle={localStyles.previewCard}
+ />
+ <div style={{paddingTop: 12}}>
+ <XDSText type="body" style={{fontWeight: 700}}>
+ {item.name}
+ </XDSText>
+ <XDSText type="body" color="secondary">
+ {item.desc}
+ </XDSText>
+ </div>
</div>
))}
</div>
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/documentation/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/documentation/page.tsx
index 884fc07e91..76d31b8d37 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/documentation/page.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/documentation/page.tsx
@@ -1,6 +1,7 @@
'use client';
import {useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
import {XDSHeading, XDSText} from '@xds/core/Text';
import {XDSButton} from '@xds/core/Button';
import {XDSCard} from '@xds/core/Card';
@@ -15,6 +16,13 @@ import {XDSDivider} from '@xds/core/Divider';
import {XDSTooltip} from '@xds/core/Tooltip';
import {XDSTable} from '@xds/core/Table';
+const localStyles = stylex.create({
+ previewCard: {
+ borderRadius: 12,
+ cursor: 'pointer',
+ },
+});
+
// ---------------------------------------------------------------------------
// Icons (Lucide-style inline SVGs)
// ---------------------------------------------------------------------------
@@ -985,33 +993,19 @@ export default function DocumentationPage() {
}}
style={{cursor: 'pointer'}}>
<XDSCard
+ variant="muted"
padding={0}
- style={{
- border: 'none',
- boxShadow: 'none',
- outline: 'none',
- }}>
- {/* Preview area */}
- <div
- style={{
- height: 160,
- backgroundColor:
- 'var(--color-background-muted, #c4cdd5)',
- borderRadius: 12,
- }}
- />
- {/* Card body */}
- <div style={{padding: '12px 0 0'}}>
- <XDSText type="body" style={{fontWeight: 700}}>
- {item.name}
- </XDSText>
- <div style={{marginTop: 0}}>
- <XDSText type="body" color="secondary">
- {item.desc}
- </XDSText>
- </div>
- </div>
- </XDSCard>
+ minHeight={160}
+ xstyle={localStyles.previewCard}
+ />
+ <div style={{paddingTop: 12}}>
+ <XDSText type="body" style={{fontWeight: 700}}>
+ {item.name}
+ </XDSText>
+ <XDSText type="body" color="secondary">
+ {item.desc}
+ </XDSText>
+ </div>
</div>
))}
</div>
diff --git a/packages/cli/templates/pages/documentation/page.tsx b/packages/cli/templates/pages/documentation/page.tsx
index 37b9af8354..731451c484 100644
--- a/packages/cli/templates/pages/documentation/page.tsx
+++ b/packages/cli/templates/pages/documentation/page.tsx
@@ -40,10 +40,11 @@ import {
} from '@heroicons/react/24/outline';
const styles = stylex.create({
- whiteSpaceNormal: {whiteSpace: 'normal'},
tabListFlush: {marginInlineStart: '-12px'},
- narrowContent: {maxWidth: 640},
- fullWidth: {width: '100%'},
+ previewCard: {
+ borderRadius: 12,
+ cursor: 'pointer',
+ },
});
// ---------------------------------------------------------------------------
@@ -583,72 +584,71 @@ function OverviewView({
onSelectComponent: (key: string) => void;
}) {
return (
- <XDSSection padding={8} maxWidth={1200} xstyle={styles.fullWidth}>
- <XDSVStack gap={10}>
- {/* Hero banner */}
- <XDSCard variant="blue" padding={10}>
- <XDSHStack gap={8} vAlign="center">
- <XDSStackItem size="fill">
- <XDSVStack gap={4}>
- <XDSText type="supporting" color="secondary">
- Product Name Design System
- </XDSText>
- <XDSText type="display-1">Web overview</XDSText>
- <XDSText type="large" color="secondary">
- An open-source UI library to help developers quickly build
- beautiful, accessible products.
- </XDSText>
- <XDSHStack>
- <XDSButton
- label="Get started"
- variant="primary"
- size="lg"
- onClick={() => onSelectComponent('getting-started')}
- />
- </XDSHStack>
- </XDSVStack>
- </XDSStackItem>
- <XDSStackItem size="fill" />
- </XDSHStack>
- </XDSCard>
+ <XDSCenter axis="horizontal">
+ <XDSSection padding={8} maxWidth={1200} width="100%">
+ <XDSVStack gap={10}>
+ {/* Hero banner */}
+ <XDSCard variant="cyan" padding={10}>
+ <XDSHStack gap={8} vAlign="center">
+ <XDSStackItem size="fill">
+ <XDSVStack gap={4}>
+ <XDSText type="display-1">Web overview</XDSText>
+ <XDSText type="large" weight="normal" color="secondary">
+ An open-source UI library to help developers quickly build
+ beautiful, accessible products.
+ </XDSText>
+ <XDSHStack>
+ <XDSButton
+ label="Get started"
+ variant="primary"
+ size="lg"
+ onClick={() => onSelectComponent('getting-started')}
+ />
+ </XDSHStack>
+ </XDSVStack>
+ </XDSStackItem>
+ <XDSStackItem size="fill" />
+ </XDSHStack>
+ </XDSCard>
- {/* Category sections */}
- {COMPONENT_CATEGORIES.map(category => (
- <XDSVStack key={category.label} gap={4}>
- <XDSText type="display-2">{category.label}</XDSText>
- <XDSGrid columns={{minWidth: 260}} gap={8}>
- {category.items.map(item => (
- <XDSCard
- key={item.key}
- padding={0}
- onClick={() => onSelectComponent(item.key)}>
- <XDSVStack gap={2}>
- <XDSSection variant="wash" padding={0} minHeight={160} />
- <XDSSection padding={3} variant="transparent">
- <XDSVStack gap={0.5}>
- <XDSText type="body" weight="bold">
- {item.name}
- </XDSText>
- <XDSText type="body" color="secondary">
- {item.desc}
- </XDSText>
- </XDSVStack>
- </XDSSection>
+ {/* Category sections */}
+ {COMPONENT_CATEGORIES.map(category => (
+ <XDSVStack key={category.label} gap={4}>
+ <XDSText type="display-2">{category.label}</XDSText>
+ <XDSGrid columns={{minWidth: 260}} gap={8}>
+ {category.items.map(item => (
+ <XDSVStack key={item.key} gap={3}>
+ <XDSCard
+ variant="muted"
+ padding={0}
+ minHeight={160}
+ xstyle={styles.previewCard}
+ onClick={() => onSelectComponent(item.key)}
+ />
+ <XDSVStack gap={0.5}>
+ <XDSText type="body" weight="bold">
+ {item.name}
+ </XDSText>
+ <XDSText type="body" color="secondary">
+ {item.desc}
+ </XDSText>
+ </XDSVStack>
</XDSVStack>
- </XDSCard>
- ))}
- </XDSGrid>
- </XDSVStack>
- ))}
- </XDSVStack>
- </XDSSection>
+ ))}
+ </XDSGrid>
+ </XDSVStack>
+ ))}
+ </XDSVStack>
+ </XDSSection>
+ </XDSCenter>
);
}
function GettingStartedView() {
return (
- <XDSSection padding={8} maxWidth={740}>
- <XDSVStack gap={8}>
+ <XDSCenter axis="horizontal">
+ <XDSSection padding={8} maxWidth={740} width="100%">
+ <XDSVStack gap={8}>
{/* Header */}
<XDSVStack gap={2}>
<XDSText type="display-1">
@@ -819,7 +819,8 @@ export default function App({ children }) {
</XDSList>
</XDSVStack>
</XDSVStack>
- </XDSSection>
+ </XDSSection>
+ </XDSCenter>
);
}
@@ -879,76 +880,77 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
const previews = EXAMPLE_PREVIEWS[activeNav] ?? [];
return (
- <XDSSection padding={8} maxWidth={960}>
- <XDSVStack gap={8}>
- {/* Header */}
- <XDSVStack gap={2}>
- <XDSText type="display-1">{getComponentName(activeNav)}</XDSText>
- <XDSText type="supporting" color="secondary">
- March 30, 2026 · Updated 5:40 p.m. PST
- </XDSText>
- </XDSVStack>
+ <XDSCenter axis="horizontal">
+ <XDSSection padding={8} maxWidth={960} width="100%">
+ <XDSVStack gap={8}>
+ {/* Header */}
+ <XDSVStack gap={2}>
+ <XDSText type="display-1">{getComponentName(activeNav)}</XDSText>
+ <XDSText type="supporting" color="secondary">
+ March 30, 2026 · Updated 5:40 p.m. PST
+ </XDSText>
+ </XDSVStack>
- <XDSDivider />
+ <XDSDivider />
- {/* Live Preview Card */}
- <XDSCard variant="muted" padding={0}>
- <XDSCenter height={360}>
- {COMPONENT_PREVIEWS[activeNav] ?? (
- <XDSText type="supporting" color="secondary">
- Preview coming soon
- </XDSText>
- )}
- </XDSCenter>
- </XDSCard>
+ {/* Live Preview Card */}
+ <XDSCard variant="muted" padding={0}>
+ <XDSCenter height={360}>
+ {COMPONENT_PREVIEWS[activeNav] ?? (
+ <XDSText type="supporting" color="secondary">
+ Preview coming soon
+ </XDSText>
+ )}
+ </XDSCenter>
+ </XDSCard>
- {/* Usage & Best Practices */}
- <XDSVStack gap={4} xstyle={styles.narrowContent}>
- <XDSHeading level={2}>Usage</XDSHeading>
- <XDSText type="large" weight="normal">
- {docs.usage}
- </XDSText>
- <XDSHeading level={3}>Best practices</XDSHeading>
- <XDSTable
- data={docs.bestPractices as Record<string, unknown>[]}
- columns={[
- {
- key: 'type',
- header: 'Guidance',
- width: pixel(125),
- renderCell: (item: Record<string, unknown>) => (
- <XDSBadge
- label={item.type === 'do' ? 'Do' : 'Dont'}
- variant={item.type === 'do' ? 'success' : 'error'}
- />
- ),
- },
- {
- key: 'text',
- header: 'Practices',
- renderCell: (item: Record<string, unknown>) => (
- <XDSText type="body" xstyle={styles.whiteSpaceNormal}>
- {item.text as string}
- </XDSText>
- ),
- },
- ]}
- density="spacious"
- dividers="rows"
- />
- </XDSVStack>
+ {/* Usage & Best Practices */}
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>Usage</XDSHeading>
+ <XDSText type="large" weight="normal">
+ {docs.usage}
+ </XDSText>
+ <XDSHeading level={3}>Best practices</XDSHeading>
+ <XDSTable
+ data={docs.bestPractices as Record<string, unknown>[]}
+ columns={[
+ {
+ key: 'type',
+ header: 'Guidance',
+ width: pixel(125),
+ renderCell: (item: Record<string, unknown>) => (
+ <XDSBadge
+ label={item.type === 'do' ? 'Do' : 'Dont'}
+ variant={item.type === 'do' ? 'success' : 'error'}
+ />
+ ),
+ },
+ {
+ key: 'text',
+ header: 'Practices',
+ renderCell: (item: Record<string, unknown>) => (
+ <XDSText type="body" textWrap="wrap">
+ {item.text as string}
+ </XDSText>
+ ),
+ },
+ ]}
+ density="spacious"
+ dividers="rows"
+ />
+ </XDSVStack>
- <XDSDivider />
+ <XDSDivider />
- {/* Examples */}
- <XDSVStack gap={4} xstyle={styles.narrowContent}>
- <XDSHeading level={2}>Examples</XDSHeading>
- <XDSText type="large" weight="normal">
- Explore common configurations, variations, and states for this
- component.
- </XDSText>
- </XDSVStack>
- <XDSVStack gap={8}>
+ {/* Examples */}
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>Examples</XDSHeading>
+ <XDSText type="large" weight="normal">
+ Explore common configurations, variations, and states for this
+ component.
+ </XDSText>
+ </XDSVStack>
+ <XDSVStack gap={8}>
{docs.examples.map((example, i) => {
const tabKey = `${activeNav}-${i}`;
const activeTab = exampleTabs[tabKey] ?? 'description';
@@ -1017,9 +1019,10 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
</XDSCard>
);
})}
+ </XDSVStack>
</XDSVStack>
- </XDSVStack>
- </XDSSection>
+ </XDSSection>
+ </XDSCenter>
);
}
@@ -1028,15 +1031,7 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
// ---------------------------------------------------------------------------
export default function DocumentationPage() {
- const [activeNav, setActiveNav] = useState('button');
- const [selectedComponent, setSelectedComponent] = useState<string | null>(
- null,
- );
-
- const handleSelectComponent = (key: string) => {
- setSelectedComponent(key);
- setActiveNav(key);
- };
+ const [activePage, setActivePage] = useState<string>('home');
return (
<XDSAppShell
@@ -1047,38 +1042,43 @@ export default function DocumentationPage() {
header={
<XDSSideNavHeading heading="Product Name" />
}>
- <XDSSideNavItem
- label="Overview"
- isSelected={selectedComponent === null}
- onClick={() => setSelectedComponent(null)}
- />
- <XDSSideNavItem
- label="Getting started"
- isSelected={activeNav === 'getting-started'}
- onClick={() => handleSelectComponent('getting-started')}
- />
+ <XDSSideNavSection title="Navigation" isHeaderHidden>
+ <XDSSideNavItem
+ label="Home"
+ isSelected={activePage === 'home'}
+ onClick={() => setActivePage('home')}
+ />
+ <XDSSideNavItem
+ label="Getting started"
+ isSelected={activePage === 'getting-started'}
+ onClick={() => setActivePage('getting-started')}
+ />
+ </XDSSideNavSection>
+
{COMPONENT_CATEGORIES.map(category => (
<XDSSideNavSection key={category.label} title={category.label}>
{category.items.map(item => (
<XDSSideNavItem
key={item.key}
label={item.name}
- isSelected={
- selectedComponent !== null && activeNav === item.key
+ isSelected={activePage === item.key}
+ onClick={
+ item.key === 'button'
+ ? () => setActivePage(item.key)
+ : undefined
}
- onClick={() => handleSelectComponent(item.key)}
/>
))}
</XDSSideNavSection>
))}
</XDSSideNav>
}>
- {selectedComponent === null ? (
- <OverviewView onSelectComponent={handleSelectComponent} />
- ) : activeNav === 'getting-started' ? (
+ {activePage === 'home' ? (
+ <OverviewView onSelectComponent={setActivePage} />
+ ) : activePage === 'getting-started' ? (
<GettingStartedView />
) : (
- <ComponentDetailView activeNav={activeNav} />
+ <ComponentDetailView activeNav={activePage} />
)}
</XDSAppShell>
);
diff --git a/packages/cli/templates/pages/editor/page.tsx b/packages/cli/templates/pages/editor/page.tsx
index bc429cb8aa..412f5b957a 100644
--- a/packages/cli/templates/pages/editor/page.tsx
+++ b/packages/cli/templates/pages/editor/page.tsx
@@ -1,384 +1,52 @@
'use client';
import {useState, useCallback} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {colorVars} from '@xds/core/theme/tokens.stylex';
-import {XDSButton} from '@xds/core/Button';
-import {XDSList, XDSListItem} from '@xds/core/List';
+import {XDSAppShell} from '@xds/core/AppShell';
+import {
+ XDSSideNav,
+ XDSSideNavSection,
+ XDSSideNavItem,
+} from '@xds/core/SideNav';
+import {XDSTopNav, XDSTopNavHeading} from '@xds/core/TopNav';
+import {XDSNavIcon} from '@xds/core/NavIcon';
import {XDSHStack, XDSVStack} from '@xds/core/Layout';
+import {XDSCenter} from '@xds/core/Center';
import {XDSText, XDSHeading} from '@xds/core/Text';
+import {XDSCard} from '@xds/core/Card';
+import {XDSButton} from '@xds/core/Button';
+import {XDSIcon} from '@xds/core/Icon';
import {XDSTextInput} from '@xds/core/TextInput';
import {XDSTextArea} from '@xds/core/TextArea';
-import {XDSToolbar} from '@xds/core/Toolbar';
-import {XDSCard} from '@xds/core/Card';
-import {XDSDivider} from '@xds/core/Divider';
import {XDSSelector} from '@xds/core/Selector';
-import {XDSTabList, XDSTab} from '@xds/core/TabList';
import {
XDSSegmentedControl,
XDSSegmentedControlItem,
} from '@xds/core/SegmentedControl';
-
-// ---------------------------------------------------------------------------
-// Inline SVG Icons (16×16 unless noted)
-// ---------------------------------------------------------------------------
-
-const LayoutIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1}
- y={1}
- width={14}
- height={5}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <rect
- x={1}
- y={9}
- width={6}
- height={6}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <rect
- x={9}
- y={9}
- width={6}
- height={6}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- </svg>
-);
-
-const TypeIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M3 3h10M8 3v10M5.5 13h5"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const ImageIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1.5}
- y={2.5}
- width={13}
- height={11}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <circle cx={5} cy={6} r={1.5} stroke="currentColor" strokeWidth={1.2} />
- <path
- d="M1.5 11l3.5-3 3 2.5 2-1.5 4.5 3"
- stroke="currentColor"
- strokeWidth={1.2}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const ButtonIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1}
- y={4}
- width={14}
- height={8}
- rx={3}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <line
- x1={5}
- y1={8}
- x2={11}
- y2={8}
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const SidebarCollapseIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1}
- y={2}
- width={14}
- height={12}
- rx={2}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <line
- x1={6}
- y1={2}
- x2={6}
- y2={14}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <path
- d="M10 7L8.5 8l1.5 1"
- stroke="currentColor"
- strokeWidth={1.2}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const SidebarExpandIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1}
- y={2}
- width={14}
- height={12}
- rx={2}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <line
- x1={6}
- y1={2}
- x2={6}
- y2={14}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <path
- d="M8.5 7L10 8l-1.5 1"
- stroke="currentColor"
- strokeWidth={1.2}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const GridIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1}
- y={1}
- width={6}
- height={6}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <rect
- x={9}
- y={1}
- width={6}
- height={6}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <rect
- x={1}
- y={9}
- width={6}
- height={6}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <rect
- x={9}
- y={9}
- width={6}
- height={6}
- rx={1}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- </svg>
-);
-
-const StarIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M8 1l2.1 4.3 4.7.7-3.4 3.3.8 4.7L8 11.8 3.8 14l.8-4.7L1.2 6l4.7-.7z"
- stroke="currentColor"
- strokeWidth={1.3}
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const MegaphoneIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M12 3v10M12 4c-2 1-5 1-7 1H4a2 2 0 0 0 0 4h1c2 0 5 0 7 1"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- <path
- d="M5 9v3a1 1 0 0 0 1 1h1"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- <line
- x1={14}
- y1={6}
- x2={14}
- y2={10}
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const PlusIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M8 3v10M3 8h10"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const TrashIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M3 4h10M5.5 4V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1M6 7v4M8 7v4M10 7v4"
- stroke="currentColor"
- strokeWidth={1.3}
- strokeLinecap="round"
- />
- <path
- d="M4 4l.5 9a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1L12 4"
- stroke="currentColor"
- strokeWidth={1.3}
- />
- </svg>
-);
-
-const ChevronUpIcon = () => (
- <svg width={12} height={12} viewBox="0 0 12 12" fill="none">
- <path
- d="M3 7.5l3-3 3 3"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const ChevronDownIcon = () => (
- <svg width={12} height={12} viewBox="0 0 12 12" fill="none">
- <path
- d="M3 4.5l3 3 3-3"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const DesktopIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={1}
- y={2}
- width={14}
- height={9}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <path
- d="M5 14h6M8 11v3"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const TabletIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={3}
- y={1}
- width={10}
- height={14}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <line
- x1={6.5}
- y1={12.5}
- x2={9.5}
- y2={12.5}
- stroke="currentColor"
- strokeWidth={1.2}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const PhoneIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <rect
- x={4}
- y={1}
- width={8}
- height={14}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <line
- x1={6.5}
- y1={12.5}
- x2={9.5}
- y2={12.5}
- stroke="currentColor"
- strokeWidth={1.2}
- strokeLinecap="round"
- />
- </svg>
-);
-
-const EyeIcon = () => (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M1.5 8s2.5-4.5 6.5-4.5S14.5 8 14.5 8s-2.5 4.5-6.5 4.5S1.5 8 1.5 8z"
- stroke="currentColor"
- strokeWidth={1.5}
- />
- <circle cx={8} cy={8} r={2} stroke="currentColor" strokeWidth={1.5} />
- </svg>
-);
-
-// ---------------------------------------------------------------------------
-// Types & helpers
-// ---------------------------------------------------------------------------
+import {XDSDivider} from '@xds/core/Divider';
+import {XDSGrid} from '@xds/core/Grid';
+import {XDSEmptyState} from '@xds/core/EmptyState';
+import {XDSToolbar} from '@xds/core/Toolbar';
+import {XDSBadge} from '@xds/core/Badge';
+import {XDSSection} from '@xds/core/Section';
+import {
+ Squares2X2Icon,
+ DocumentTextIcon,
+ PhotoIcon,
+ CursorArrowRaysIcon,
+ ViewColumnsIcon,
+ SparklesIcon,
+ MegaphoneIcon,
+ PlusCircleIcon,
+ TrashIcon,
+ ChevronUpIcon,
+ ChevronDownIcon,
+ ComputerDesktopIcon,
+ DeviceTabletIcon,
+ DevicePhoneMobileIcon,
+ EyeIcon,
+ XMarkIcon,
+ PencilSquareIcon,
+} from '@heroicons/react/24/outline';
type BlockType =
| 'hero'
@@ -397,19 +65,23 @@ interface Block {
}
type ViewportSize = 'desktop' | 'tablet' | 'phone';
-type SidebarTab = 'blocks' | 'properties';
-const BLOCK_TYPE_META: Record<
- BlockType,
- {label: string; icon: React.ReactNode}
-> = {
- hero: {label: 'Hero', icon: <LayoutIcon />},
- text: {label: 'Text', icon: <TypeIcon />},
- image: {label: 'Image', icon: <ImageIcon />},
- button: {label: 'Button', icon: <ButtonIcon />},
- cards: {label: 'Cards', icon: <GridIcon />},
- features: {label: 'Features', icon: <StarIcon />},
- cta: {label: 'CTA', icon: <MegaphoneIcon />},
+type IconComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>;
+
+const BLOCK_META: Record<BlockType, {label: string; icon: IconComponent}> = {
+ hero: {label: 'Hero', icon: Squares2X2Icon},
+ text: {label: 'Text', icon: DocumentTextIcon},
+ image: {label: 'Image', icon: PhotoIcon},
+ button: {label: 'Button', icon: CursorArrowRaysIcon},
+ cards: {label: 'Cards', icon: ViewColumnsIcon},
+ features: {label: 'Features', icon: SparklesIcon},
+ cta: {label: 'CTA', icon: MegaphoneIcon},
+};
+
+const VIEWPORT_WIDTH: Record<ViewportSize, number> = {
+ desktop: 960,
+ tablet: 768,
+ phone: 375,
};
let nextId = 5;
@@ -417,7 +89,7 @@ function uid() {
return String(nextId++);
}
-const DEFAULT_BLOCKS: Block[] = [
+const INITIAL_BLOCKS: Block[] = [
{
id: '1',
type: 'hero',
@@ -425,7 +97,7 @@ const DEFAULT_BLOCKS: Block[] = [
props: {
heading: 'Build something amazing',
subheading:
- 'A modern page builder powered by XDS components. Drag, drop, and customize blocks to create beautiful pages in minutes.',
+ 'A modern page builder powered by XDS components. Customize blocks to create beautiful pages in minutes.',
buttonLabel: 'Get Started',
alignment: 'center',
},
@@ -438,11 +110,13 @@ const DEFAULT_BLOCKS: Block[] = [
cards: [
{
title: 'Fast',
- description: 'Optimised for performance with zero runtime overhead.',
+ description:
+ 'Optimised for performance with zero runtime overhead.',
},
{
title: 'Flexible',
- description: 'Adapts to any design system with configurable tokens.',
+ description:
+ 'Adapts to any design system with configurable tokens.',
},
{
title: 'Accessible',
@@ -474,75 +148,308 @@ const DEFAULT_BLOCKS: Block[] = [
},
];
-const VIEWPORT_MAX: Record<ViewportSize, number> = {
- desktop: 960,
- tablet: 768,
- phone: 375,
-};
+function defaultProps(type: BlockType): Record<string, unknown> {
+ switch (type) {
+ case 'hero':
+ return {
+ heading: 'New Hero',
+ subheading: 'Subtitle goes here',
+ buttonLabel: 'Click Me',
+ alignment: 'center',
+ };
+ case 'text':
+ return {content: 'Enter your text here.'};
+ case 'image':
+ return {};
+ case 'button':
+ return {label: 'Button', variant: 'primary', size: 'md'};
+ case 'cards':
+ return {
+ cards: [
+ {title: 'Pricing', description: 'Flexible plans for every team size.'},
+ {title: 'Support', description: 'Get help whenever you need it.'},
+ ],
+ };
+ case 'features':
+ return {
+ cards: [
+ {title: 'Lightning Fast', description: 'Sub-second load times out of the box.'},
+ ],
+ };
+ case 'cta':
+ return {
+ heading: 'Call to Action',
+ description: 'Description text',
+ primaryLabel: 'Primary',
+ secondaryLabel: 'Secondary',
+ };
+ }
+}
-// ---------------------------------------------------------------------------
-// Component
-// ---------------------------------------------------------------------------
+function PropertiesForm({
+ block,
+ onUpdate,
+}: {
+ block: Block;
+ onUpdate: (key: string, value: unknown) => void;
+}) {
+ const {type, props} = block;
+
+ switch (type) {
+ case 'hero':
+ return (
+ <XDSVStack gap={4}>
+ <XDSTextInput
+ label="Heading"
+ value={(props.heading as string) ?? ''}
+ onChange={(v: string) => onUpdate('heading', v)}
+ />
+ <XDSTextArea
+ label="Subheading"
+ value={(props.subheading as string) ?? ''}
+ onChange={(v: string) => onUpdate('subheading', v)}
+ />
+ <XDSTextInput
+ label="Button Label"
+ value={(props.buttonLabel as string) ?? ''}
+ onChange={(v: string) => onUpdate('buttonLabel', v)}
+ />
+ <XDSSelector
+ label="Alignment"
+ value={(props.alignment as string) ?? 'center'}
+ onChange={(v: string) => onUpdate('alignment', v)}
+ options={[
+ {label: 'Left', value: 'left'},
+ {label: 'Center', value: 'center'},
+ {label: 'Right', value: 'right'},
+ ]}
+ />
+ </XDSVStack>
+ );
-const editorStyles = stylex.create({
- body: {backgroundColor: colorVars['--color-background-body']},
- card: {backgroundColor: colorVars['--color-background-card']},
-});
+ case 'text':
+ return (
+ <XDSTextArea
+ label="Content"
+ value={(props.content as string) ?? ''}
+ onChange={(v: string) => onUpdate('content', v)}
+ />
+ );
-export default function EditorPage() {
- const [blocks, setBlocks] = useState<Block[]>(DEFAULT_BLOCKS);
- const [selectedId, setSelectedId] = useState<string | null>(null);
- const [sidebarTab, setSidebarTab] = useState<SidebarTab>('blocks');
- const [pageTitle, setPageTitle] = useState('Page Editor');
- const [isEditingTitle, setIsEditingTitle] = useState(false);
- const [isPanelCollapsed, setIsPanelCollapsed] = useState(false);
- const [viewport, setViewport] = useState<ViewportSize>('desktop');
- const [dragId, setDragId] = useState<string | null>(null);
- const [dragOverId, setDragOverId] = useState<string | null>(null);
+ case 'cta':
+ return (
+ <XDSVStack gap={4}>
+ <XDSTextInput
+ label="Heading"
+ value={(props.heading as string) ?? ''}
+ onChange={(v: string) => onUpdate('heading', v)}
+ />
+ <XDSTextArea
+ label="Description"
+ value={(props.description as string) ?? ''}
+ onChange={(v: string) => onUpdate('description', v)}
+ />
+ <XDSTextInput
+ label="Primary Button"
+ value={(props.primaryLabel as string) ?? ''}
+ onChange={(v: string) => onUpdate('primaryLabel', v)}
+ />
+ <XDSTextInput
+ label="Secondary Button"
+ value={(props.secondaryLabel as string) ?? ''}
+ onChange={(v: string) => onUpdate('secondaryLabel', v)}
+ />
+ </XDSVStack>
+ );
- const handleDragStart = useCallback((id: string) => {
- setDragId(id);
- }, []);
+ case 'button':
+ return (
+ <XDSVStack gap={4}>
+ <XDSTextInput
+ label="Label"
+ value={(props.label as string) ?? ''}
+ onChange={(v: string) => onUpdate('label', v)}
+ />
+ <XDSSelector
+ label="Variant"
+ value={(props.variant as string) ?? 'primary'}
+ onChange={(v: string) => onUpdate('variant', v)}
+ options={[
+ {label: 'Primary', value: 'primary'},
+ {label: 'Secondary', value: 'secondary'},
+ {label: 'Ghost', value: 'ghost'},
+ ]}
+ />
+ <XDSSelector
+ label="Size"
+ value={(props.size as string) ?? 'md'}
+ onChange={(v: string) => onUpdate('size', v)}
+ options={[
+ {label: 'Small', value: 'sm'},
+ {label: 'Medium', value: 'md'},
+ {label: 'Large', value: 'lg'},
+ ]}
+ />
+ </XDSVStack>
+ );
- const handleDragOver = useCallback((e: React.DragEvent, id: string) => {
- e.preventDefault();
- setDragOverId(id);
- }, []);
+ default:
+ return (
+ <XDSEmptyState title="No configurable properties" isCompact />
+ );
+ }
+}
- const handleDrop = useCallback(
- (targetId: string) => {
- if (!dragId || dragId === targetId) {
- setDragId(null);
- setDragOverId(null);
- return;
- }
- setBlocks(prev => {
- const fromIdx = prev.findIndex(b => b.id === dragId);
- const toIdx = prev.findIndex(b => b.id === targetId);
- if (fromIdx === -1 || toIdx === -1) return prev;
- const next = [...prev];
- const [moved] = next.splice(fromIdx, 1);
- next.splice(toIdx, 0, moved);
- return next;
- });
- setDragId(null);
- setDragOverId(null);
- },
- [dragId],
- );
+function BlockPreview({
+ block,
+ isSelected,
+}: {
+ block: Block;
+ isSelected: boolean;
+}) {
+ const {type, props} = block;
+ const variant = isSelected ? 'blue' : 'default';
+
+ switch (type) {
+ case 'hero':
+ return (
+ <XDSCard variant={variant}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>
+ {(props.heading as string) || 'Hero Heading'}
+ </XDSHeading>
+ <XDSText type="supporting" color="secondary">
+ {(props.subheading as string) || 'Subtitle text goes here'}
+ </XDSText>
+ {(props.buttonLabel as string) && (
+ <XDSButton label={props.buttonLabel as string} />
+ )}
+ </XDSVStack>
+ </XDSCard>
+ );
- const handleDragEnd = useCallback(() => {
- setDragId(null);
- setDragOverId(null);
- }, []);
+ case 'text':
+ return (
+ <XDSCard variant={variant}>
+ <XDSText type="body">
+ {(props.content as string) || 'Text content goes here'}
+ </XDSText>
+ </XDSCard>
+ );
- const selectedBlock = blocks.find(b => b.id === selectedId) ?? null;
+ case 'image':
+ return (
+ <XDSCard variant={variant}>
+ <XDSEmptyState
+ title="Image Block"
+ description="Drop an image or enter a URL"
+ icon={<XDSIcon icon={PhotoIcon} />}
+ isCompact
+ />
+ </XDSCard>
+ );
- // --- block helpers -------------------------------------------------------
+ case 'button':
+ return (
+ <XDSCard variant={variant} padding={6}>
+ <XDSButton
+ label={(props.label as string) || 'Button'}
+ variant={
+ (props.variant as 'primary' | 'secondary' | 'ghost') ||
+ 'primary'
+ }
+ size={(props.size as 'sm' | 'md' | 'lg') || 'md'}
+ />
+ </XDSCard>
+ );
- const updateBlock = useCallback(
- (id: string, updater: (b: Block) => Block) => {
- setBlocks(prev => prev.map(b => (b.id === id ? updater(b) : b)));
+ case 'features': {
+ const featureCards =
+ (props.cards as Array<{title: string; description: string}>) || [];
+ return (
+ <XDSCard variant={variant}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={3}>Features</XDSHeading>
+ <XDSGrid columns={{minWidth: 200}} gap={4}>
+ {featureCards.map((card, i) => (
+ <XDSSection key={i} variant="wash" padding={4}>
+ <XDSVStack gap={2}>
+ <XDSIcon icon={SparklesIcon} color="accent" />
+ <XDSHeading level={4}>{card.title}</XDSHeading>
+ <XDSText type="supporting" color="secondary">{card.description}</XDSText>
+ </XDSVStack>
+ </XDSSection>
+ ))}
+ </XDSGrid>
+ </XDSVStack>
+ </XDSCard>
+ );
+ }
+
+ case 'cards': {
+ const cardItems =
+ (props.cards as Array<{title: string; description: string}>) || [];
+ return (
+ <XDSCard variant={variant}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={3}>Cards</XDSHeading>
+ <XDSGrid columns={{minWidth: 200}} gap={4}>
+ {cardItems.map((card, i) => (
+ <XDSSection key={i} variant="wash" padding={4}>
+ <XDSVStack gap={2}>
+ <XDSHeading level={4}>{card.title}</XDSHeading>
+ <XDSText type="supporting" color="secondary">{card.description}</XDSText>
+ </XDSVStack>
+ </XDSSection>
+ ))}
+ </XDSGrid>
+ </XDSVStack>
+ </XDSCard>
+ );
+ }
+
+ case 'cta':
+ return (
+ <XDSCard variant={variant}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={3}>
+ {(props.heading as string) || 'Call to Action'}
+ </XDSHeading>
+ <XDSText type="supporting" color="secondary">
+ {(props.description as string) || 'Description text'}
+ </XDSText>
+ <XDSHStack gap={3}>
+ <XDSButton
+ label={(props.primaryLabel as string) || 'Primary'}
+ />
+ <XDSButton
+ label={(props.secondaryLabel as string) || 'Secondary'}
+ variant="secondary"
+ />
+ </XDSHStack>
+ </XDSVStack>
+ </XDSCard>
+ );
+
+ default:
+ return null;
+ }
+}
+
+export default function EditorPage() {
+ const [blocks, setBlocks] = useState<Block[]>(INITIAL_BLOCKS);
+ const [selectedId, setSelectedId] = useState<string | null>(null);
+ const [viewport, setViewport] = useState<ViewportSize>('desktop');
+
+ const selectedBlock = blocks.find(b => b.id === selectedId) ?? null;
+
+ const updateBlockProp = useCallback(
+ (id: string, key: string, value: unknown) => {
+ setBlocks(prev =>
+ prev.map(b =>
+ b.id === id ? {...b, props: {...b.props, [key]: value}} : b,
+ ),
+ );
},
[],
);
@@ -568,1133 +475,202 @@ export default function EditorPage() {
);
const addBlock = useCallback((type: BlockType) => {
- const meta = BLOCK_TYPE_META[type];
const id = uid();
- const newBlock: Block = {id, type, label: meta.label, props: {}};
-
- switch (type) {
- case 'hero':
- newBlock.props = {
- heading: 'New Hero',
- subheading: 'Subtitle goes here',
- buttonLabel: 'Click Me',
- alignment: 'center',
- };
- break;
- case 'text':
- newBlock.props = {content: 'Enter your text here.'};
- break;
- case 'image':
- newBlock.props = {};
- break;
- case 'button':
- newBlock.props = {label: 'Button', variant: 'primary', size: 'md'};
- break;
- case 'cards':
- newBlock.props = {
- cards: [
- {title: 'Card 1', description: 'Description'},
- {title: 'Card 2', description: 'Description'},
- ],
- };
- break;
- case 'features':
- newBlock.props = {
- cards: [{title: 'Feature', description: 'Description'}],
- };
- break;
- case 'cta':
- newBlock.props = {
- heading: 'Call to Action',
- description: 'Description text',
- primaryLabel: 'Primary',
- secondaryLabel: 'Secondary',
- };
- break;
- }
-
+ const newBlock: Block = {
+ id,
+ type,
+ label: BLOCK_META[type].label,
+ props: defaultProps(type),
+ };
setBlocks(prev => [...prev, newBlock]);
setSelectedId(id);
- setSidebarTab('properties');
- }, []);
-
- const selectBlock = useCallback((id: string) => {
- setSelectedId(id);
- setSidebarTab('properties');
}, []);
- // --- sidebar renderers ---------------------------------------------------
-
- const renderBlocksTab = () => (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- gap: 16,
- padding: '16px 8px',
- }}>
- {/* Add Block */}
- <div>
- <XDSHeading
- level={4}
- style={{marginBottom: 4, paddingLeft: 8, paddingRight: 8}}>
- Add Block
- </XDSHeading>
- <XDSList density="compact" hasDividers={false}>
- {(Object.keys(BLOCK_TYPE_META) as BlockType[]).map(type => (
- <XDSListItem
- key={type}
- label={BLOCK_TYPE_META[type].label}
- startContent={
- <span
- style={{
- display: 'inline-flex',
- color: 'var(--xds-color-text-secondary, #666)',
- }}>
- {BLOCK_TYPE_META[type].icon}
- </span>
- }
- onClick={() => addBlock(type)}
- />
- ))}
- </XDSList>
- </div>
-
- {/* Layers */}
- <div>
- <XDSHeading
- level={4}
- style={{marginBottom: 4, paddingLeft: 8, paddingRight: 8}}>
- Layers
- </XDSHeading>
- <XDSList density="compact" hasDividers={false}>
- {blocks.map(block => (
- <XDSListItem
- key={block.id}
- label={block.label}
- isSelected={block.id === selectedId}
- onClick={() =>
- selectBlock(
- block.id === selectedId
- ? (null as unknown as string)
- : block.id,
- )
- }
- startContent={
- <span
- style={{
- display: 'inline-flex',
- color: 'var(--xds-color-text-secondary, #666)',
- }}>
- {BLOCK_TYPE_META[block.type].icon}
- </span>
- }
- endContent={
- <XDSHStack gap={1}>
- <XDSButton
- label="Move up"
- icon={<ChevronUpIcon />}
- variant="ghost"
- size="sm"
- onClick={(e: React.MouseEvent) => {
- e.stopPropagation();
- moveBlock(block.id, -1);
- }}
- isIconOnly
- />
- <XDSButton
- label="Move down"
- icon={<ChevronDownIcon />}
- variant="ghost"
- size="sm"
- onClick={(e: React.MouseEvent) => {
- e.stopPropagation();
- moveBlock(block.id, 1);
- }}
- isIconOnly
- />
- <XDSButton
- label="Delete"
- icon={<TrashIcon />}
- variant="ghost"
- size="sm"
- onClick={(e: React.MouseEvent) => {
- e.stopPropagation();
- deleteBlock(block.id);
- }}
- isIconOnly
- />
- </XDSHStack>
+ return (
+ <XDSAppShell
+ topNav={
+ <XDSTopNav
+ label="Page Editor"
+ heading={
+ <XDSTopNavHeading
+ heading="Page Editor"
+ logo={
+ <XDSNavIcon
+ icon={<XDSIcon icon={PencilSquareIcon} />}
+ />
}
/>
- ))}
- </XDSList>
- </div>
- </div>
- );
-
- const renderPropertiesTab = () => {
- if (!selectedBlock) {
- return (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- flex: 1,
- padding: 24,
- textAlign: 'center' as const,
- gap: 8,
- height: '100%',
- }}>
- <svg width={32} height={32} viewBox="0 0 24 24" fill="none">
- <rect
- x={3}
- y={3}
- width={8}
- height={8}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- opacity={0.4}
- />
- <rect
- x={13}
- y={3}
- width={8}
- height={8}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- opacity={0.4}
- />
- <rect
- x={3}
- y={13}
- width={8}
- height={8}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- opacity={0.4}
- />
- <rect
- x={13}
- y={13}
- width={8}
- height={8}
- rx={1.5}
- stroke="currentColor"
- strokeWidth={1.5}
- opacity={0.4}
- />
- </svg>
- <XDSText type="body" color="secondary">
- Select a block to edit its properties
- </XDSText>
- </div>
- );
- }
-
- const {id, type, label, props} = selectedBlock;
- const set = (key: string, value: unknown) =>
- updateBlock(id, b => ({...b, props: {...b.props, [key]: value}}));
-
- return (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- gap: 16,
- padding: 16,
- }}>
- {type === 'hero' && (
- <>
- <XDSTextInput
- label="Heading"
- value={(props.heading as string) ?? ''}
- onChange={(v: string) => set('heading', v)}
- />
- <XDSTextArea
- label="Subheading"
- value={(props.subheading as string) ?? ''}
- onChange={(v: string) => set('subheading', v)}
- />
- <XDSTextInput
- label="Button Label"
- value={(props.buttonLabel as string) ?? ''}
- onChange={(v: string) => set('buttonLabel', v)}
- />
- <XDSSelector
- label="Alignment"
- value={(props.alignment as string) ?? 'center'}
- onChange={(v: string) => set('alignment', v)}
- options={[
- {label: 'Left', value: 'left'},
- {label: 'Center', value: 'center'},
- {label: 'Right', value: 'right'},
- ]}
- />
- </>
- )}
-
- {type === 'text' && (
- <XDSTextArea
- label="Content"
- value={(props.content as string) ?? ''}
- onChange={(v: string) => set('content', v)}
- />
- )}
-
- {type === 'cta' && (
- <>
- <XDSTextInput
- label="Heading"
- value={(props.heading as string) ?? ''}
- onChange={(v: string) => set('heading', v)}
- />
- <XDSTextArea
- label="Description"
- value={(props.description as string) ?? ''}
- onChange={(v: string) => set('description', v)}
- />
- <XDSTextInput
- label="Primary Button"
- value={(props.primaryLabel as string) ?? ''}
- onChange={(v: string) => set('primaryLabel', v)}
- />
- <XDSTextInput
- label="Secondary Button"
- value={(props.secondaryLabel as string) ?? ''}
- onChange={(v: string) => set('secondaryLabel', v)}
- />
- </>
- )}
-
- {type === 'button' && (
- <>
- <XDSTextInput
- label="Label"
- value={(props.label as string) ?? ''}
- onChange={(v: string) => set('label', v)}
- />
- <XDSSelector
- label="Variant"
- value={(props.variant as string) ?? 'primary'}
- onChange={(v: string) => set('variant', v)}
- options={[
- {label: 'Primary', value: 'primary'},
- {label: 'Secondary', value: 'secondary'},
- {label: 'Ghost', value: 'ghost'},
- ]}
- />
- <XDSSelector
- label="Size"
- value={(props.size as string) ?? 'md'}
- onChange={(v: string) => set('size', v)}
- options={[
- {label: 'Small', value: 'sm'},
- {label: 'Medium', value: 'md'},
- {label: 'Large', value: 'lg'},
- ]}
- />
- </>
- )}
-
- {type === 'image' && (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- padding: 24,
- gap: 8,
- textAlign: 'center' as const,
- }}>
- <XDSText type="body" color="secondary">
- No configurable properties
- </XDSText>
- </div>
- )}
-
- {type === 'cards' && (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- padding: 24,
- gap: 8,
- textAlign: 'center' as const,
- }}>
- <XDSText type="body" color="secondary">
- No configurable properties
- </XDSText>
- </div>
- )}
-
- {type === 'features' && (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- padding: 24,
- gap: 8,
- textAlign: 'center' as const,
- }}>
- <XDSText type="body" color="secondary">
- No configurable properties
- </XDSText>
- </div>
- )}
- </div>
- );
- };
-
- // --- block preview renderers ---------------------------------------------
-
- const renderBlockPreview = (block: Block) => {
- const {type, props} = block;
- const isSelected = block.id === selectedId;
- const ring = isSelected
- ? '0 0 0 2px var(--xds-color-accent, #0066ff)'
- : 'none';
- const handleClick = () =>
- selectBlock(
- block.id === selectedId ? (null as unknown as string) : block.id,
- );
- const cream = '#f5f3ef';
- const dark = '#1a1a1a';
-
- switch (type) {
- case 'hero': {
- const align = (props.alignment as string) ?? 'left';
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- overflow: 'hidden' as const,
- cursor: 'pointer' as const,
- background: cream,
- padding: '64px 56px',
- display: 'grid',
- gridTemplateColumns: '1fr 1fr',
- gap: 48,
- alignItems: 'center' as const,
- }}>
- <div>
- <div
- style={{
- fontSize: 48,
- fontWeight: 700,
- letterSpacing: '-0.03em',
- lineHeight: 1.05,
- color: dark,
- marginBottom: 20,
- }}>
- {(props.heading as string) ??
- 'Invest your way, commission-free'}
- </div>
- <div
- style={{
- fontSize: 15,
- lineHeight: 1.6,
- color: 'rgba(0,0,0,0.55)',
- marginBottom: 32,
- maxWidth: 380,
- }}>
- {(props.subheading as string) ??
- 'Build your own portfolio with thousands of stocks, ETFs, and options — all on our powerful platform.'}
- </div>
- {(props.buttonLabel as string) && (
- <div
- style={{
- display: 'inline-block',
- background: dark,
- color: '#fff',
- borderRadius: 100,
- padding: '11px 24px',
- fontSize: 14,
- fontWeight: 600,
- }}>
- {props.buttonLabel as string}
- </div>
- )}
- </div>
- <div
- style={{
- background:
- 'linear-gradient(160deg, #c8dce8 0%, #b5cfa8 50%, #d4b896 100%)',
- borderRadius: 12,
- aspectRatio: '4/3',
- display: 'flex',
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- overflow: 'hidden' as const,
- }}>
- <div
- style={{
- background: 'rgba(255,255,255,0.85)',
- backdropFilter: 'blur(8px)',
- borderRadius: 10,
- padding: 16,
- width: 180,
- boxShadow: '0 4px 20px rgba(0,0,0,0.1)',
- }}>
- <div
- style={{
- fontSize: 11,
- color: 'rgba(0,0,0,0.4)',
- marginBottom: 10,
- }}>
- Portfolio
- </div>
- {['AAPL', 'TSLA', 'VFV'].map((t, i) => (
- <div
- key={t}
- style={{
- display: 'flex',
- justifyContent: 'space-between',
- alignItems: 'center',
- marginBottom: 8,
- }}>
- <span style={{fontSize: 12, fontWeight: 600}}>{t}</span>
- <span
- style={{
- fontSize: 11,
- color: i === 1 ? '#d63' : '#2a7',
- fontWeight: 500,
- }}>
- {i === 1 ? '-1.2%' : '+3.4%'}
- </span>
- </div>
- ))}
- </div>
- </div>
- </div>
- );
- }
-
- case 'text':
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- cursor: 'pointer' as const,
- background: cream,
- padding: '56px',
- }}>
- <div
- style={{
- maxWidth: 680,
- fontSize: 17,
- lineHeight: 1.8,
- color: dark,
- }}>
- {(props.content as string) ??
- 'Your text content goes here. Clean, readable body copy with generous line height and a comfortable measure for easy scanning.'}
- </div>
- </div>
- );
-
- case 'image':
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- overflow: 'hidden' as const,
- cursor: 'pointer' as const,
- background:
- 'linear-gradient(160deg, #c8dce8 0%, #c5d5b0 60%, #d4b896 100%)',
- aspectRatio: '16/7',
- display: 'flex',
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- }}>
- <div
- style={{
- background: 'rgba(255,255,255,0.7)',
- backdropFilter: 'blur(12px)',
- borderRadius: 8,
- padding: '10px 16px',
- fontSize: 12,
- color: 'rgba(0,0,0,0.4)',
- letterSpacing: '0.04em',
- }}>
- Image
- </div>
- </div>
- );
-
- case 'button':
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- cursor: 'pointer' as const,
- background: cream,
- padding: '40px 56px',
- display: 'flex',
- justifyContent: 'flex-start' as const,
- }}>
- <div
- style={{
- background:
- (props.variant as string) === 'ghost'
- ? 'transparent'
- : (props.variant as string) === 'secondary'
- ? 'transparent'
- : dark,
- color:
- (props.variant as string) === 'secondary' ||
- (props.variant as string) === 'ghost'
- ? dark
- : '#fff',
- border:
- (props.variant as string) !== 'primary'
- ? `1px solid ${dark}`
- : 'none',
- borderRadius: 100,
- padding:
- (props.size as string) === 'lg'
- ? '13px 32px'
- : (props.size as string) === 'sm'
- ? '8px 18px'
- : '11px 24px',
- fontSize:
- (props.size as string) === 'lg'
- ? 16
- : (props.size as string) === 'sm'
- ? 13
- : 14,
- fontWeight: 600,
- }}>
- {(props.label as string) ?? 'Get started'}
- </div>
- </div>
- );
-
- case 'features': {
- const featureCards = (props.cards as {
- title: string;
- description: string;
- }[]) ?? [
- {
- title: 'Low fees, more value',
- description:
- 'The more assets you have with us, the better your perks. Pay lower option trading and FX fees as a Premium or Generation client.',
- },
- {
- title: 'Fast and flexible',
- description:
- 'Start trading on your terms and timeline. Instant transfers and extended hours keep you ready for any market moment.',
- },
- {
- title: 'Everything you need to trade',
- description:
- 'Buy and sell all common stocks, ETFs, and options on mobile or web, with multiple different accounts to choose from.',
- },
- ];
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- cursor: 'pointer' as const,
- background: cream,
- padding: '56px',
- }}>
- <div
- style={{
- fontSize: 40,
- fontWeight: 700,
- letterSpacing: '-0.025em',
- lineHeight: 1.1,
- color: dark,
- marginBottom: 48,
- maxWidth: 480,
- }}>
- Self-directed trading that earns you more
- </div>
- <div
- style={{
- display: 'grid',
- gridTemplateColumns: `repeat(${Math.min(featureCards.length, 3)}, 1fr)`,
- gap: 32,
- }}>
- {featureCards.map((card, i) => (
- <div key={i}>
- <div
- style={{
- fontSize: 13,
- fontWeight: 700,
- color: dark,
- marginBottom: 8,
- }}>
- {card.title}
- </div>
- <div
- style={{
- fontSize: 13,
- lineHeight: 1.65,
- color: 'rgba(0,0,0,0.5)',
- }}>
- {card.description}
- </div>
- </div>
- ))}
- </div>
- </div>
- );
- }
-
- case 'cards': {
- const cardItems = (props.cards as {
- title: string;
- description: string;
- }[]) ?? [
- {title: '$0 commission trading', description: 'Stocks & ETFs'},
- {
- title: 'Trade options for $0 — a first in Canada',
- description: 'Options',
- },
- {
- title: 'Get margin rates lower than your bank',
- description: 'Margin',
- },
- ];
- const cardBg = ['#c8d8b0', '#b5c8a0', '#c0b090'];
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- overflow: 'hidden' as const,
- cursor: 'pointer' as const,
- background: cream,
- padding: '56px',
- }}>
- <div
- style={{
- display: 'flex',
- justifyContent: 'space-between',
- alignItems: 'flex-end',
- marginBottom: 32,
- }}>
- <div
- style={{
- fontSize: 40,
- fontWeight: 700,
- letterSpacing: '-0.025em',
- lineHeight: 1.1,
- color: dark,
- maxWidth: 400,
- }}>
- Strategies to suit any portfolio
- </div>
- <div
- style={{
- border: '1px solid rgba(0,0,0,0.2)',
- borderRadius: 100,
- padding: '9px 20px',
- fontSize: 13,
- fontWeight: 500,
- color: dark,
- flexShrink: 0,
- }}>
- Invest now
- </div>
- </div>
- <div
- style={{
- display: 'grid',
- gridTemplateColumns: `repeat(${Math.min(cardItems.length, 3)}, 1fr)`,
- gap: 12,
- }}>
- {cardItems.map((card, i) => (
- <div
- key={i}
- style={{
- background: cardBg[i % cardBg.length],
- borderRadius: 12,
- padding: '24px 20px 20px',
- display: 'flex',
- flexDirection: 'column' as const,
- justifyContent: 'space-between',
- minHeight: 200,
- }}>
- <div
- style={{
- width: '100%',
- height: 80,
- borderRadius: 8,
- background: 'rgba(255,255,255,0.25)',
- marginBottom: 24,
- }}
- />
- <div>
- <div
- style={{
- fontSize: 11,
- color: 'rgba(0,0,0,0.45)',
- marginBottom: 6,
- }}>
- {card.description}
- </div>
- <div
- style={{
- fontSize: 15,
- fontWeight: 700,
- color: dark,
- lineHeight: 1.25,
- }}>
- {card.title}
- </div>
- </div>
- </div>
- ))}
- </div>
- </div>
- );
- }
-
- case 'cta':
- return (
- <div
- key={block.id}
- onClick={handleClick}
- style={{
- boxShadow: ring,
- borderRadius: 16,
- overflow: 'hidden' as const,
- cursor: 'pointer' as const,
- background: cream,
- display: 'grid',
- gridTemplateColumns: '1fr 1fr',
- gap: 0,
- }}>
- <div
- style={{
- background:
- 'linear-gradient(160deg, #c8dce8 0%, #c5d5b0 60%, #d4b896 100%)',
- padding: 40,
- minHeight: 260,
- display: 'flex',
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- }}>
- <div
- style={{
- background: 'rgba(255,255,255,0.8)',
- backdropFilter: 'blur(8px)',
- borderRadius: 10,
- padding: 20,
- width: '80%',
- boxShadow: '0 4px 20px rgba(0,0,0,0.08)',
- }}>
- {[
- ['NVDA', '$500.00 USD'],
- ['Recurring investments', '●'],
- ['Dividend reinvestments', '●'],
- ].map(([label, val], i) => (
- <div
- key={i}
- style={{
- display: 'flex',
- justifyContent: 'space-between',
- alignItems: 'center',
- padding: '8px 0',
- borderBottom:
- i < 2 ? '1px solid rgba(0,0,0,0.06)' : 'none',
- }}>
- <span
- style={{fontSize: 12, fontWeight: i === 0 ? 600 : 400}}>
- {label}
- </span>
- <span
- style={{
- fontSize: i === 0 ? 12 : 18,
- color: i > 0 ? '#2a7' : 'rgba(0,0,0,0.5)',
- }}>
- {val}
- </span>
- </div>
- ))}
- </div>
- </div>
- <div style={{padding: '48px 40px'}}>
- <div
- style={{
- fontSize: 36,
- fontWeight: 700,
- letterSpacing: '-0.025em',
- lineHeight: 1.1,
- color: dark,
- marginBottom: 32,
- }}>
- {(props.heading as string) ??
- 'Automation for smarter investing'}
- </div>
- {[
- {
- title:
- (props.primaryLabel as string) || 'Recurring investments',
- body:
- (props.description as string) ||
- 'Auto-buy your favourite stocks and ETFs on your schedule.',
- },
- {
- title:
- (props.secondaryLabel as string) || 'Dividend reinvestment',
- body: 'Keep growing by reinvesting 100% of your earnings with zero commissions.',
- },
- ].map((item, i) => (
- <div key={i} style={{marginBottom: 20}}>
- <div
- style={{
- fontSize: 13,
- fontWeight: 700,
- color: dark,
- marginBottom: 4,
- }}>
- {item.title}
- </div>
- <div
- style={{
- fontSize: 13,
- lineHeight: 1.6,
- color: 'rgba(0,0,0,0.5)',
- }}>
- {item.body}
- </div>
- </div>
- ))}
- </div>
- </div>
- );
-
- default:
- return null;
- }
- };
-
- // --- main render ---------------------------------------------------------
-
- return (
- <div
- style={{
- position: 'fixed' as const,
- inset: 0,
- display: 'flex',
- flexDirection: 'column' as const,
- color: 'var(--xds-color-text-primary, #1a1a1a)',
- ...stylex.props(editorStyles.body).style,
- }}>
- {/* Body: Sidebar + Preview */}
- <div
- style={{
- display: 'flex',
- flex: 1,
- overflow: 'hidden' as const,
- position: 'relative' as const,
- }}>
- {/* Floating Sidebar */}
- <div
- style={{
- position: 'absolute' as const,
- top: 16,
- left: 16,
- bottom: isPanelCollapsed ? 'auto' : 16,
- width: 320,
- zIndex: 10,
- ...stylex.props(editorStyles.card).style,
- borderRadius: 12,
- boxShadow:
- '0 2px 8px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06)',
- display: 'flex',
- flexDirection: 'column' as const,
- overflow: 'hidden' as const,
- }}>
- {/* Header */}
- <div style={{padding: 16}}>
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- marginBottom: 16,
- }}>
- <div style={{flex: 1}}>
- {isEditingTitle ? (
- <div onBlurCapture={() => setIsEditingTitle(false)}>
- <XDSTextInput
- label="Page title"
- isLabelHidden
- value={pageTitle}
- onChange={setPageTitle}
- onKeyDown={(e: React.KeyboardEvent) => {
- if (e.key === 'Enter') setIsEditingTitle(false);
- }}
- hasAutoFocus
- />
- </div>
- ) : (
- <span
- style={{cursor: 'pointer'}}
- onClick={() => setIsEditingTitle(true)}>
- <XDSHeading level={2}>{pageTitle}</XDSHeading>
- </span>
- )}
- </div>
- <XDSButton
- label={isPanelCollapsed ? 'Expand panel' : 'Collapse panel'}
- icon={
- isPanelCollapsed ? (
- <SidebarExpandIcon />
- ) : (
- <SidebarCollapseIcon />
- )
- }
- variant="ghost"
- size="sm"
- style={{marginRight: -8, marginTop: -8}}
- onClick={() => setIsPanelCollapsed(v => !v)}
- isIconOnly
- />
- </div>
-
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- gap: 8,
- }}>
+ }
+ endContent={
+ <XDSHStack gap={3} vAlign="center">
<XDSSegmentedControl
label="Viewport size"
value={viewport}
- onChange={(v: string) => setViewport(v as ViewportSize)}>
+ onChange={(v: string) =>
+ setViewport(v as ViewportSize)
+ }>
<XDSSegmentedControlItem
value="desktop"
label="Desktop"
- icon={<DesktopIcon />}
+ icon={<XDSIcon icon={ComputerDesktopIcon} size="sm" />}
isLabelHidden
/>
<XDSSegmentedControlItem
value="tablet"
label="Tablet"
- icon={<TabletIcon />}
+ icon={<XDSIcon icon={DeviceTabletIcon} size="sm" />}
isLabelHidden
/>
<XDSSegmentedControlItem
value="phone"
label="Phone"
- icon={<PhoneIcon />}
+ icon={
+ <XDSIcon icon={DevicePhoneMobileIcon} size="sm" />
+ }
isLabelHidden
/>
</XDSSegmentedControl>
- <XDSHStack gap={2}>
- <XDSButton
- label="Preview"
- icon={<EyeIcon />}
- variant="ghost"
- isIconOnly
- />
- <XDSButton label="Publish" variant="primary" />
- </XDSHStack>
- </div>
- </div>
- {!isPanelCollapsed && (
- <>
- <XDSDivider />
- <div className="full-width-tabs" style={{padding: 0}}>
- <style>{`
- .full-width-tabs nav { width: 100%; }
- .full-width-tabs nav > button,
- .full-width-tabs nav > a { flex: 1; justify-content: center; }
- `}</style>
- <XDSTabList
- value={sidebarTab}
- onChange={(v: string) => setSidebarTab(v as SidebarTab)}>
- <XDSTab value="blocks" label="Blocks" />
- <XDSTab value="properties" label="Properties" />
- </XDSTabList>
- </div>
- <XDSDivider />
- <div style={{flex: 1, overflowY: 'auto' as const}}>
- {sidebarTab === 'blocks'
- ? renderBlocksTab()
- : renderPropertiesTab()}
- </div>
- </>
- )}
- </div>
-
- {/* Preview */}
- <div
- style={{
- flex: 1,
- overflowY: 'auto' as const,
- padding: 32,
- paddingLeft: 368,
- display: 'flex',
- justifyContent: 'center' as const,
- alignItems: 'flex-start' as const,
- }}>
- <div
- style={{
- width: '100%',
- maxWidth: VIEWPORT_MAX[viewport],
- ...stylex.props(editorStyles.body).style,
- borderRadius: 12,
- padding: 24,
- transition: 'max-width 0.3s ease',
- }}>
+ <XDSButton
+ label="Preview"
+ icon={<XDSIcon icon={EyeIcon} size="sm" />}
+ variant="secondary"
+ isIconOnly
+ />
+ <XDSButton label="Publish" variant="primary" />
+ </XDSHStack>
+ }
+ />
+ }
+ sideNav={
+ <XDSSideNav>
+ <XDSSideNavSection title="Add Block">
+ {(Object.keys(BLOCK_META) as BlockType[]).map(type => (
+ <XDSSideNavItem
+ key={type}
+ label={BLOCK_META[type].label}
+ icon={BLOCK_META[type].icon}
+ onClick={() => addBlock(type)}
+ />
+ ))}
+ </XDSSideNavSection>
+ <XDSSideNavSection title="Page Layers">
+ {blocks.map(block => (
+ <XDSSideNavItem
+ key={block.id}
+ label={block.label}
+ icon={BLOCK_META[block.type].icon}
+ isSelected={block.id === selectedId}
+ onClick={() =>
+ setSelectedId(prev =>
+ prev === block.id ? null : block.id,
+ )
+ }
+ endContent={
+ <XDSBadge label={BLOCK_META[block.type].label} />
+ }
+ />
+ ))}
+ </XDSSideNavSection>
+ </XDSSideNav>
+ }
+ variant="elevated"
+ contentPadding={6}
+ height="auto">
+ <XDSVStack gap={6}>
+ {selectedBlock && (
+ <XDSCard>
<XDSVStack gap={4}>
- {blocks.map(block => renderBlockPreview(block))}
+ <XDSToolbar
+ label="Block properties"
+ startContent={
+ <XDSHeading level={4}>
+ {selectedBlock.label} Properties
+ </XDSHeading>
+ }
+ endContent={
+ <XDSHStack gap={2}>
+ <XDSButton
+ label="Move up"
+ icon={
+ <XDSIcon icon={ChevronUpIcon} size="sm" />
+ }
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ onClick={() =>
+ moveBlock(selectedBlock.id, -1)
+ }
+ />
+ <XDSButton
+ label="Move down"
+ icon={
+ <XDSIcon icon={ChevronDownIcon} size="sm" />
+ }
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ onClick={() =>
+ moveBlock(selectedBlock.id, 1)
+ }
+ />
+ <XDSButton
+ label="Delete block"
+ icon={<XDSIcon icon={TrashIcon} size="sm" />}
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ onClick={() =>
+ deleteBlock(selectedBlock.id)
+ }
+ />
+ <XDSButton
+ label="Deselect"
+ icon={<XDSIcon icon={XMarkIcon} size="sm" />}
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ onClick={() => setSelectedId(null)}
+ />
+ </XDSHStack>
+ }
+ />
+ <XDSDivider />
+ <PropertiesForm
+ block={selectedBlock}
+ onUpdate={(key, value) =>
+ updateBlockProp(selectedBlock.id, key, value)
+ }
+ />
</XDSVStack>
+ </XDSCard>
+ )}
- {blocks.length === 0 && (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column' as const,
- alignItems: 'center' as const,
- justifyContent: 'center' as const,
- minHeight: 400,
- gap: 12,
- color: 'var(--xds-color-text-secondary, #999)',
- }}>
- <PlusIcon />
- <XDSText type="body" color="secondary">
- Add blocks from the sidebar to get started
- </XDSText>
- </div>
+ <XDSCenter axis="horizontal" width="100%">
+ <XDSCard
+ width="100%"
+ maxWidth={VIEWPORT_WIDTH[viewport]}
+ padding={4}
+ variant="muted">
+ {blocks.length > 0 ? (
+ <XDSVStack gap={4}>
+ {blocks.map(block => (
+ <BlockPreview
+ key={block.id}
+ block={block}
+ isSelected={block.id === selectedId}
+ />
+ ))}
+ </XDSVStack>
+ ) : (
+ <XDSEmptyState
+ title="No blocks yet"
+ description="Add blocks from the sidebar to start building your page"
+ icon={<XDSIcon icon={PlusCircleIcon} />}
+ />
)}
- </div>
- </div>
- </div>
- </div>
+ </XDSCard>
+ </XDSCenter>
+ </XDSVStack>
+ </XDSAppShell>
);
}
diff --git a/packages/cli/templates/pages/file-explorer/page.tsx b/packages/cli/templates/pages/file-explorer/page.tsx
index f2251ad8f7..f1679bec24 100644
--- a/packages/cli/templates/pages/file-explorer/page.tsx
+++ b/packages/cli/templates/pages/file-explorer/page.tsx
@@ -1,20 +1,36 @@
'use client';
import {useState, useMemo} from 'react';
-import {XDSButton} from '@xds/core/Button';
+import * as stylex from '@stylexjs/stylex';
+import {XDSLayout, XDSLayoutContent} from '@xds/core/Layout';
+import {XDSToolbar} from '@xds/core/Toolbar';
import {XDSList, XDSListItem} from '@xds/core/List';
import {XDSHStack, XDSVStack} from '@xds/core/Layout';
-import {XDSText, XDSHeading} from '@xds/core/Text';
-import {XDSToolbar} from '@xds/core/Toolbar';
-import {XDSDivider} from '@xds/core';
+import {XDSText} from '@xds/core/Text';
+import {XDSIcon} from '@xds/core/Icon';
+import {XDSIconButton} from '@xds/core/IconButton';
+import {XDSSection} from '@xds/core/Section';
+import {XDSAvatar} from '@xds/core/Avatar';
+import {XDSMetadataList, XDSMetadataListItem} from '@xds/core/MetadataList';
import {
XDSSegmentedControl,
XDSSegmentedControlItem,
} from '@xds/core/SegmentedControl';
-
-// =============================================================================
-// Types
-// =============================================================================
+import {
+ ChevronLeftIcon,
+ ChevronRightIcon,
+ MagnifyingGlassIcon,
+ ShareIcon,
+ TagIcon,
+ EllipsisHorizontalIcon,
+ ViewColumnsIcon,
+ Squares2X2Icon,
+ Bars4Icon,
+ TableCellsIcon,
+ AdjustmentsHorizontalIcon,
+ DocumentIcon,
+} from '@heroicons/react/24/outline';
+import {FolderIcon} from '@heroicons/react/24/solid';
interface FileSystemItem {
id: string;
@@ -23,353 +39,6 @@ interface FileSystemItem {
children?: FileSystemItem[];
}
-// =============================================================================
-// Icons
-// =============================================================================
-
-function FolderIcon({color = '#5AADFE'}: {color?: string}) {
- return (
- <svg width={16} height={16} viewBox="0 0 20 20" fill="none">
- <path
- d="M2 5.5A1.5 1.5 0 013.5 4h3.764a1.5 1.5 0 011.073.453l1.326 1.36a.5.5 0 00.358.152L16.5 6A1.5 1.5 0 0118 7.5v7a1.5 1.5 0 01-1.5 1.5h-13A1.5 1.5 0 012 14.5v-9z"
- fill={color}
- />
- </svg>
- );
-}
-
-function FileIcon({
- color = '#8E8E93',
- size = 16,
-}: {
- color?: string;
- size?: number;
-}) {
- return (
- <svg width={size} height={size} viewBox="0 0 20 20" fill="none">
- <path
- d="M5 2.5A1.5 1.5 0 016.5 1h4.879a1.5 1.5 0 011.06.44l3.122 3.12A1.5 1.5 0 0116 5.622V17.5a1.5 1.5 0 01-1.5 1.5h-8A1.5 1.5 0 015 17.5v-15z"
- fill="white"
- stroke={color}
- strokeWidth={1}
- />
- <path d="M11 1v3.5a1 1 0 001 1h3.5" stroke={color} strokeWidth={1} />
- </svg>
- );
-}
-
-function AppIcon({label, bg}: {label: string; bg: string}) {
- return (
- <div
- style={{
- width: 16,
- height: 16,
- borderRadius: 4,
- backgroundColor: bg,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- fontSize: 8,
- fontWeight: 700,
- color: 'white',
- flexShrink: 0,
- }}>
- {label}
- </div>
- );
-}
-
-function ChevronRight({color = '#C7C7CC'}: {color?: string}) {
- return (
- <svg width={8} height={13} viewBox="0 0 8 13" fill="none">
- <path
- d="M1.5 1.5l5 5-5 5"
- stroke={color}
- strokeWidth={1.8}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- );
-}
-
-function BackIcon() {
- return (
- <svg width={16} height={16} viewBox="0 0 12 20" fill="none">
- <path
- d="M10.5 1.5l-8 8.5 8 8.5"
- stroke="currentColor"
- strokeWidth={2}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- );
-}
-
-function ForwardIcon() {
- return (
- <svg width={16} height={16} viewBox="0 0 12 20" fill="none">
- <path
- d="M1.5 1.5l8 8.5-8 8.5"
- stroke="currentColor"
- strokeWidth={2}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- );
-}
-
-function ColumnViewIcon() {
- return (
- <svg width={18} height={18} viewBox="0 0 18 18" fill="none">
- <rect
- x="1"
- y="1"
- width="4.5"
- height="16"
- rx="1"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="6.75"
- y="1"
- width="4.5"
- height="16"
- rx="1"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="12.5"
- y="1"
- width="4.5"
- height="16"
- rx="1"
- fill="currentColor"
- fillOpacity={0.5}
- />
- </svg>
- );
-}
-
-function GridViewIcon() {
- return (
- <svg width={18} height={18} viewBox="0 0 18 18" fill="none">
- <rect
- x="1"
- y="1"
- width="7"
- height="7"
- rx="1.5"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="10"
- y="1"
- width="7"
- height="7"
- rx="1.5"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="1"
- y="10"
- width="7"
- height="7"
- rx="1.5"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="10"
- y="10"
- width="7"
- height="7"
- rx="1.5"
- fill="currentColor"
- fillOpacity={0.5}
- />
- </svg>
- );
-}
-
-function ListViewIcon() {
- return (
- <svg width={18} height={18} viewBox="0 0 18 18" fill="none">
- <rect
- x="1"
- y="2"
- width="16"
- height="3"
- rx="1"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="1"
- y="7.5"
- width="16"
- height="3"
- rx="1"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="1"
- y="13"
- width="16"
- height="3"
- rx="1"
- fill="currentColor"
- fillOpacity={0.5}
- />
- </svg>
- );
-}
-
-function GalleryViewIcon() {
- return (
- <svg width={18} height={18} viewBox="0 0 18 18" fill="none">
- <rect
- x="3"
- y="1"
- width="12"
- height="12"
- rx="1.5"
- fill="currentColor"
- fillOpacity={0.5}
- />
- <rect
- x="1"
- y="15"
- width="4"
- height="2"
- rx="0.5"
- fill="currentColor"
- fillOpacity={0.3}
- />
- <rect
- x="7"
- y="15"
- width="4"
- height="2"
- rx="0.5"
- fill="currentColor"
- fillOpacity={0.3}
- />
- <rect
- x="13"
- y="15"
- width="4"
- height="2"
- rx="0.5"
- fill="currentColor"
- fillOpacity={0.3}
- />
- </svg>
- );
-}
-
-function SearchIcon() {
- return (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <circle cx="6.5" cy="6.5" r="5" stroke="#8E8E93" strokeWidth={1.5} />
- <path
- d="M10.5 10.5L14.5 14.5"
- stroke="#8E8E93"
- strokeWidth={1.5}
- strokeLinecap="round"
- />
- </svg>
- );
-}
-
-function ShareIcon() {
- return (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M8 1v9M4.5 4.5L8 1l3.5 3.5"
- stroke="#8E8E93"
- strokeWidth={1.3}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- <path
- d="M3 8v5.5a1 1 0 001 1h8a1 1 0 001-1V8"
- stroke="#8E8E93"
- strokeWidth={1.3}
- strokeLinecap="round"
- />
- </svg>
- );
-}
-
-function TagIcon() {
- return (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <path
- d="M1.5 8.793V2.5a1 1 0 011-1h6.293a1 1 0 01.707.293l5.207 5.207a1 1 0 010 1.414L9.414 14.707a1 1 0 01-1.414 0L1.793 8.5a1 1 0 01-.293-.707z"
- stroke="#8E8E93"
- strokeWidth={1.3}
- />
- <circle cx="5" cy="5" r="1" fill="#8E8E93" />
- </svg>
- );
-}
-
-function MoreIcon() {
- return (
- <svg width={16} height={16} viewBox="0 0 16 16" fill="none">
- <circle cx="3" cy="8" r="1.5" fill="#8E8E93" />
- <circle cx="8" cy="8" r="1.5" fill="#8E8E93" />
- <circle cx="13" cy="8" r="1.5" fill="#8E8E93" />
- </svg>
- );
-}
-
-function GroupIcon() {
- return (
- <svg width={18} height={16} viewBox="0 0 18 16" fill="none">
- <rect
- x="1"
- y="1"
- width="16"
- height="4"
- rx="1"
- fill="#8E8E93"
- fillOpacity={0.4}
- />
- <rect
- x="1"
- y="7"
- width="16"
- height="3"
- rx="0.5"
- fill="#8E8E93"
- fillOpacity={0.3}
- />
- <rect
- x="1"
- y="12"
- width="16"
- height="3"
- rx="0.5"
- fill="#8E8E93"
- fillOpacity={0.3}
- />
- </svg>
- );
-}
-
-// =============================================================================
-// Data — filesystem tree
-// =============================================================================
-
const FILESYSTEM: FileSystemItem[] = [
{
id: 'applications',
@@ -589,110 +258,12 @@ const FILESYSTEM: FileSystemItem[] = [
},
];
-const APP_ICONS: Record<string, {label: string; bg: string}> = {
- 'Component Lab.app': {label: 'CL', bg: '#5856D6'},
- 'Google Chat.app': {label: 'G', bg: '#34C759'},
- 'Workchat.app': {label: 'W', bg: '#30B0C7'},
- 'Figma.app': {label: 'F', bg: '#A259FF'},
- 'Safari.app': {label: 'S', bg: '#007AFF'},
- 'Slack.app': {label: 'S', bg: '#611F69'},
- 'Terminal.app': {label: '>', bg: '#1D1D1F'},
- 'Visual Studio Code.app': {label: 'VS', bg: '#007ACC'},
- 'Xcode.app': {label: 'X', bg: '#147EFB'},
-};
-
-// =============================================================================
-// Styles — inline for layout, minimal StyleX for tokens only
-// =============================================================================
-
-const FONT =
- '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif';
-
-const inlineStyles = {
- page: {
- display: 'flex',
- flexDirection: 'column' as const,
- height: '100vh',
- width: '100vw',
- overflow: 'hidden',
- userSelect: 'none' as const,
- fontFamily: FONT,
- backgroundColor: 'var(--xds-color-background-surface, #FFFFFF)',
- position: 'fixed' as const,
- inset: 0,
- },
- toolbar: {
- flexShrink: 0,
- },
- body: {
- display: 'flex',
- flex: 1,
- overflow: 'hidden',
- },
- column: (isLast: boolean) => ({
- display: 'flex',
- flexDirection: 'column' as const,
- width: 240,
- flex: 'none',
- borderRight: isLast ? 'none' : '1px solid var(--xds-color-border, #E5E5EA)',
- overflowY: 'auto' as const,
- overflowX: 'hidden' as const,
- backgroundColor: 'var(--xds-color-background-surface, #FFFFFF)',
- flexShrink: 0,
- }),
- columnContent: {
- paddingTop: 2,
- paddingBottom: 2,
- },
- row: (isSelected: boolean) => ({
- display: 'flex',
- alignItems: 'center',
- gap: 5,
- height: 22,
- paddingLeft: isSelected ? 5 : 8,
- paddingRight: isSelected ? 5 : 8,
- marginLeft: isSelected ? 4 : 0,
- marginRight: isSelected ? 4 : 0,
- cursor: 'pointer',
- fontSize: 12,
- fontFamily: FONT,
- color: isSelected
- ? 'var(--xds-color-on-accent, #FFFFFF)'
- : 'var(--xds-color-text-primary, #1D1D1F)',
- backgroundColor: isSelected
- ? 'var(--xds-color-accent, #007AFF)'
- : 'transparent',
- borderRadius: isSelected ? 5 : 0,
- flexShrink: 0,
- whiteSpace: 'nowrap' as const,
- overflow: 'hidden' as const,
- textOverflow: 'ellipsis' as const,
- lineHeight: '22px',
- }),
- rowName: {
- flex: 1,
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap' as const,
- },
- rowChevron: {
- flexShrink: 0,
- display: 'flex',
- alignItems: 'center',
- },
- iconWrapper: {
- flexShrink: 0,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- width: 16,
- height: 16,
- },
-};
-
-// =============================================================================
-// Helpers
-// =============================================================================
+const styles = stylex.create({
+ fillHeight: {height: '100%'},
+ scrollable: {overflowY: 'auto'},
+ fixedColumn: {flexShrink: 0, alignSelf: 'stretch'},
+ fillRemaining: {flex: 1, alignSelf: 'stretch'},
+});
function findItem(items: FileSystemItem[], id: string): FileSystemItem | null {
for (const item of items) {
@@ -705,22 +276,11 @@ function findItem(items: FileSystemItem[], id: string): FileSystemItem | null {
return null;
}
-// =============================================================================
-// Component
-// =============================================================================
+function getFileExtension(name: string): string {
+ const dot = name.lastIndexOf('.');
+ return dot > 0 ? name.substring(dot + 1).toUpperCase() : 'File';
+}
-/**
- * File Explorer template — macOS Finder column view.
- *
- * A multi-column file browser that drills down through a filesystem tree.
- * Each selection opens a new column to the right showing the children.
- *
- * Demonstrates:
- * - Multi-column panel navigation (Finder-style)
- * - StyleX for all layout and theming
- * - XDS design token integration
- * - Dynamic column rendering based on selection depth
- */
export default function FileExplorerPage() {
const [selectedPath, setSelectedPath] = useState<string[]>([
'applications',
@@ -730,12 +290,7 @@ export default function FileExplorerPage() {
const columns = useMemo(() => {
const cols: {items: FileSystemItem[]; selectedId: string | null}[] = [];
-
- cols.push({
- items: FILESYSTEM,
- selectedId: selectedPath[0] ?? null,
- });
-
+ cols.push({items: FILESYSTEM, selectedId: selectedPath[0] ?? null});
let currentItems: FileSystemItem[] = FILESYSTEM;
for (let i = 0; i < selectedPath.length; i++) {
const selected = currentItems.find(item => item.id === selectedPath[i]);
@@ -749,7 +304,6 @@ export default function FileExplorerPage() {
break;
}
}
-
return cols;
}, [selectedPath]);
@@ -768,295 +322,206 @@ export default function FileExplorerPage() {
return 'Home';
}, [selectedPath]);
- // Check if the last selected item is a file (for preview pane)
const selectedFile = useMemo(() => {
if (selectedPath.length === 0) return null;
const lastId = selectedPath[selectedPath.length - 1];
const item = findItem(FILESYSTEM, lastId);
- if (item && item.type === 'file') return item;
- return null;
+ return item?.type === 'file' ? item : null;
}, [selectedPath]);
const handleSelect = (columnIndex: number, itemId: string) => {
- const newPath = [...selectedPath.slice(0, columnIndex), itemId];
- setSelectedPath(newPath);
+ setSelectedPath([...selectedPath.slice(0, columnIndex), itemId]);
};
- const handleBack = () => {
- if (selectedPath.length > 0) {
- setSelectedPath(selectedPath.slice(0, -1));
- }
- };
-
- function renderPreviewIcon(item: FileSystemItem) {
- const appIcon = APP_ICONS[item.name];
- if (appIcon) {
- return (
- <div
- style={{
- width: 128,
- height: 128,
- borderRadius: 28,
- backgroundColor: appIcon.bg,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- fontSize: 48,
- fontWeight: 700,
- color: 'white',
- boxShadow: '0 4px 24px rgba(0,0,0,0.1)',
- }}>
- {appIcon.label}
- </div>
- );
- }
- return (
- <div
- style={{
- width: 128,
- height: 128,
- borderRadius: 16,
- backgroundColor: 'var(--xds-color-background-body, #F5F5F7)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- boxShadow: '0 4px 24px rgba(0,0,0,0.08)',
- }}>
- <FileIcon color="var(--xds-color-icon-secondary, #86868B)" size={64} />
- </div>
- );
- }
-
- function getFileExtension(name: string): string {
- const dot = name.lastIndexOf('.');
- return dot > 0 ? name.substring(dot + 1).toUpperCase() : 'File';
- }
-
- function renderIcon(item: FileSystemItem, isSelected: boolean) {
- if (item.type === 'folder') {
- return (
- <div style={inlineStyles.iconWrapper}>
- <FolderIcon color={isSelected ? '#A0CCFF' : '#5AADFE'} />
- </div>
- );
- }
-
- const appIcon = APP_ICONS[item.name];
- if (appIcon) {
- return (
- <div style={inlineStyles.iconWrapper}>
- <AppIcon label={appIcon.label} bg={appIcon.bg} />
- </div>
- );
- }
-
- return (
- <div style={inlineStyles.iconWrapper}>
- <FileIcon color={isSelected ? '#FFFFFF' : '#8E8E93'} />
- </div>
- );
- }
-
return (
- <div style={inlineStyles.page}>
- {/* Toolbar */}
- <XDSToolbar
- label="File Explorer"
- padding={0}
- style={{...inlineStyles.toolbar, paddingTop: 8, paddingBottom: 8}}
- startContent={
- <XDSHStack gap={1} vAlign="center">
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<BackIcon />}
- onClick={handleBack}
- isDisabled={selectedPath.length === 0}
- label="Go back"
- aria-label="Go back"
- isIconOnly
- />
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<ForwardIcon />}
- isDisabled
- label="Go forward"
- aria-label="Go forward"
- isIconOnly
- />
- <XDSText type="label" style={{marginLeft: 6}}>
- {currentFolderName}
- </XDSText>
- </XDSHStack>
- }
- centerContent={
- <XDSSegmentedControl
- value="column"
- onChange={() => {}}
- label="View mode">
- <XDSSegmentedControlItem
- value="grid"
- label="Grid"
- icon={<GridViewIcon />}
- isLabelHidden
- />
- <XDSSegmentedControlItem
- value="list"
- label="List"
- icon={<ListViewIcon />}
- isLabelHidden
- />
- <XDSSegmentedControlItem
- value="column"
- label="Column"
- icon={<ColumnViewIcon />}
- isLabelHidden
- />
- <XDSSegmentedControlItem
- value="gallery"
- label="Gallery"
- icon={<GalleryViewIcon />}
- isLabelHidden
- />
- </XDSSegmentedControl>
- }
- endContent={
- <XDSHStack gap={1} vAlign="center">
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<GroupIcon />}
- label="Group"
- aria-label="Group"
- isIconOnly
- />
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<ShareIcon />}
- label="Share"
- aria-label="Share"
- isIconOnly
- />
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<TagIcon />}
- label="Tags"
- aria-label="Tags"
- isIconOnly
- />
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<MoreIcon />}
- label="More"
- aria-label="More"
- isIconOnly
- />
- <XDSButton
- variant="ghost"
- size="sm"
- icon={<SearchIcon />}
- label="Search"
- aria-label="Search"
- isIconOnly
- />
+ <XDSLayout
+ height="fill"
+ header={
+ <XDSToolbar
+ label="File Explorer"
+ size="sm"
+ padding={0}
+ dividers={['bottom']}
+ style={{paddingBlock: 4}}
+ startContent={
+ <>
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={ChevronLeftIcon} size="sm" />}
+ onClick={() => {
+ if (selectedPath.length > 0) {
+ setSelectedPath(selectedPath.slice(0, -1));
+ }
+ }}
+ isDisabled={selectedPath.length === 0}
+ label="Go back"
+ />
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={ChevronRightIcon} size="sm" />}
+ isDisabled
+ label="Go forward"
+ />
+ <XDSText type="label">{currentFolderName}</XDSText>
+ </>
+ }
+ centerContent={
+ <XDSSegmentedControl
+ value="column"
+ onChange={() => {}}
+ label="View mode">
+ <XDSSegmentedControlItem
+ value="grid"
+ label="Grid"
+ icon={<XDSIcon icon={Squares2X2Icon} size="sm" />}
+ isLabelHidden
+ />
+ <XDSSegmentedControlItem
+ value="list"
+ label="List"
+ icon={<XDSIcon icon={Bars4Icon} size="sm" />}
+ isLabelHidden
+ />
+ <XDSSegmentedControlItem
+ value="column"
+ label="Column"
+ icon={<XDSIcon icon={ViewColumnsIcon} size="sm" />}
+ isLabelHidden
+ />
+ <XDSSegmentedControlItem
+ value="gallery"
+ label="Gallery"
+ icon={<XDSIcon icon={TableCellsIcon} size="sm" />}
+ isLabelHidden
+ />
+ </XDSSegmentedControl>
+ }
+ endContent={
+ <>
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={AdjustmentsHorizontalIcon} size="sm" />}
+ label="Group"
+ />
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={ShareIcon} size="sm" />}
+ label="Share"
+ />
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={TagIcon} size="sm" />}
+ label="Tags"
+ />
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={EllipsisHorizontalIcon} size="sm" />}
+ label="More"
+ />
+ <XDSIconButton
+ variant="ghost"
+ size="sm"
+ icon={<XDSIcon icon={MagnifyingGlassIcon} size="sm" />}
+ label="Search"
+ />
+ </>
+ }
+ />
+ }
+ content={
+ <XDSLayoutContent padding={0} isScrollable={false}>
+ <XDSHStack xstyle={styles.fillHeight}>
+ {columns.map((col, colIndex) => {
+ const showDivider =
+ colIndex < columns.length - 1 || selectedFile != null;
+ return (
+ <XDSSection
+ key={colIndex}
+ width={240}
+ padding={2}
+ variant="transparent"
+ dividers={showDivider ? ['end'] : undefined}
+ xstyle={[styles.scrollable, styles.fixedColumn]}>
+ <XDSList density="compact" hasDividers={false}>
+ {col.items.map(item => {
+ const isSelected = col.selectedId === item.id;
+ const hasChildren =
+ item.type === 'folder' &&
+ item.children != null &&
+ item.children.length > 0;
+ return (
+ <XDSListItem
+ key={item.id}
+ label={item.name}
+ startContent={
+ <XDSIcon
+ icon={
+ item.type === 'folder'
+ ? FolderIcon
+ : DocumentIcon
+ }
+ color={
+ item.type === 'folder'
+ ? 'accent'
+ : 'secondary'
+ }
+ size="sm"
+ />
+ }
+ endContent={
+ hasChildren ? (
+ <XDSIcon
+ icon={ChevronRightIcon}
+ size="xsm"
+ color="secondary"
+ />
+ ) : undefined
+ }
+ onClick={() => handleSelect(colIndex, item.id)}
+ isSelected={isSelected}
+ />
+ );
+ })}
+ </XDSList>
+ </XDSSection>
+ );
+ })}
+ {selectedFile && (
+ <XDSSection
+ padding={6}
+ variant="transparent"
+ xstyle={[styles.scrollable, styles.fillRemaining]}>
+ <XDSVStack gap={4} hAlign="center">
+ <XDSAvatar name={selectedFile.name} size={96} />
+ <XDSVStack gap={1} hAlign="center">
+ <XDSText type="label">{selectedFile.name}</XDSText>
+ <XDSText type="supporting">
+ {getFileExtension(selectedFile.name)} Document
+ </XDSText>
+ </XDSVStack>
+ <XDSMetadataList title="Information">
+ <XDSMetadataListItem label="Created">
+ March 28, 2026 at 2:15 PM
+ </XDSMetadataListItem>
+ <XDSMetadataListItem label="Modified">
+ Yesterday, 10:27 PM
+ </XDSMetadataListItem>
+ <XDSMetadataListItem label="Kind">
+ {getFileExtension(selectedFile.name)} Document
+ </XDSMetadataListItem>
+ </XDSMetadataList>
+ </XDSVStack>
+ </XDSSection>
+ )}
</XDSHStack>
- }
- />
- <XDSDivider />
- {/* Columns */}
- <XDSHStack style={inlineStyles.body}>
- {columns.map((col, colIndex) => {
- const isLast = colIndex === columns.length - 1;
- return (
- <div key={colIndex} style={inlineStyles.column(isLast)}>
- <XDSList
- density="compact"
- hasDividers={false}
- style={{padding: 8}}>
- {col.items.map(item => {
- const isSelected = col.selectedId === item.id;
- const hasChildren =
- item.type === 'folder' &&
- item.children != null &&
- item.children.length > 0;
-
- return (
- <XDSListItem
- key={item.id}
- label={item.name}
- startContent={renderIcon(item, isSelected)}
- endContent={
- hasChildren ? (
- <ChevronRight
- color={'var(--xds-color-icon-secondary, #86868B)'}
- />
- ) : undefined
- }
- onClick={() => handleSelect(colIndex, item.id)}
- isSelected={isSelected}
- />
- );
- })}
- </XDSList>
- </div>
- );
- })}
-
- {/* Preview Pane */}
- {selectedFile && (
- <div
- style={{
- flex: 1,
- flexShrink: 0,
- borderLeft: '1px solid var(--xds-color-border, #E5E5EA)',
- overflowY: 'auto' as const,
- backgroundColor: 'var(--xds-color-background-surface, #FFFFFF)',
- padding: 16,
- }}>
- <XDSVStack
- gap={4}
- hAlign="center"
- style={{maxWidth: 300, margin: '0 auto'}}>
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- paddingBlock: 32,
- }}>
- {renderPreviewIcon(selectedFile)}
- </div>
- <XDSVStack gap={1} hAlign="center" style={{width: '100%'}}>
- <XDSText type="label">{selectedFile.name}</XDSText>
- <XDSText type="supporting">
- {getFileExtension(selectedFile.name)} Document
- </XDSText>
- </XDSVStack>
- <XDSVStack gap={2} style={{width: '100%'}}>
- <XDSText type="label">Information</XDSText>
- <XDSHStack hAlign="between">
- <XDSText type="supporting">Created</XDSText>
- <XDSText type="supporting">March 28, 2026 at 2:15 PM</XDSText>
- </XDSHStack>
- <XDSHStack hAlign="between">
- <XDSText type="supporting">Modified</XDSText>
- <XDSText type="supporting">Yesterday, 10:27 PM</XDSText>
- </XDSHStack>
- </XDSVStack>
- <XDSVStack gap={1} style={{width: '100%'}}>
- <XDSText type="label">Tags</XDSText>
- <XDSText type="supporting" color="secondary">
- Add Tags...
- </XDSText>
- </XDSVStack>
- </XDSVStack>
- </div>
- )}
- </XDSHStack>
- </div>
+ </XDSLayoutContent>
+ }
+ />
);
}