Skip to content

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

TypeScript

feat(docsite): profile layout, crafted cards, and basePath fixes (#1429)

rubyycheunge73e7cc61bc9
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/AppTopNav.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/AppTopNav.tsx
index cdf8505d6f..a7a87cba77 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/AppTopNav.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/AppTopNav.tsx
@@ -9,7 +9,7 @@ import {XDSList, XDSListItem} from '@xds/core/List';
import {XDSDropdownMenu} from '@xds/core/DropdownMenu';
import {XDSCommandPalette} from '@xds/core/CommandPalette';
import {SearchIcon, ProfileIcon, FilterIcon} from './docsite-icons';
-import {SEARCH_COMMANDS} from './constants';
+import {SEARCH_COMMANDS, basePath} from './constants';
const XDS_WORDMARK = (
<svg
@@ -104,7 +104,7 @@ export function AppTopNav({
heading={
<XDSTopNavHeading
logo={XDS_WORDMARK}
- headingHref="/pages/docsite/"
+ headingHref={`${basePath}/pages/docsite/`}
menu={headingMenu}
/>
}
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/ChatPanel.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/ChatPanel.tsx
index dae3e92d34..39c4e5974f 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/ChatPanel.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/ChatPanel.tsx
@@ -20,7 +20,9 @@ import {MOCK_CODE} from './constants';
const composerStyles = stylex.create({
border: {
- border: '1px solid var(--color-border)',
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized, #CCD3DB)',
},
});
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx
index 050de6f062..2be47f73aa 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/DocsView.tsx
@@ -20,7 +20,7 @@ import {
ProfileIcon,
} from './docsite-icons';
import {COMPONENT_PREVIEWS} from './ComponentPreviews';
-import {SEARCH_COMMANDS} from './constants';
+import {SEARCH_COMMANDS, basePath} from './constants';
import {
COMPONENT_CATEGORIES,
getComponentName,
@@ -85,7 +85,7 @@ export function DocsView({
heading={
<XDSTopNavHeading
logo={XDS_WORDMARK}
- headingHref="/pages/docsite/"
+ headingHref={`${basePath}/pages/docsite/`}
menu={headingMenu}
/>
}
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/ProfileView.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/ProfileView.tsx
index 108aeb9567..438d29e02d 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/ProfileView.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/ProfileView.tsx
@@ -1,24 +1,520 @@
'use client';
-import React, {useState, useMemo} from 'react';
+import {useState, useMemo, useCallback} from 'react';
import {XDSText, XDSHeading} from '@xds/core/Text';
import {XDSButton} from '@xds/core/Button';
import {XDSDialog, XDSDialogHeader} from '@xds/core/Dialog';
-import {XDSList, XDSListItem} from '@xds/core/List';
-import {XDSDivider} from '@xds/core/Divider';
-import {XDSCard} from '@xds/core/Card';
-import {XDSPopover} from '@xds/core/Popover';
import {XDSTextInput} from '@xds/core/TextInput';
-import {XDSToolbar} from '@xds/core/Toolbar';
+import {XDSTabList, XDSTab} from '@xds/core/TabList';
+import {XDSHStack, XDSVStack, XDSStackItem} from '@xds/core/Layout';
+import {XDSRadioList, XDSRadioListItem} from '@xds/core/RadioList';
+import {XDSGrid} from '@xds/core/Grid';
+import {XDSBadge} from '@xds/core/Badge';
import {XDSDropdownMenu} from '@xds/core/DropdownMenu';
-import {XDSIcon} from '@xds/core/Icon';
-import {XDSToken} from '@xds/core/Token';
+import {XDSEmptyState} from '@xds/core/EmptyState';
+import {XDSCard} from '@xds/core/Card';
import {XDSLink} from '@xds/core/Link';
-import {TEMPLATES, PROFILE_CRAFT_ITEMS, THEME_PICKER_ENTRIES, FILTER_COLUMNS} from './constants';
-import {TemplateCard} from './TemplateCard';
-import {SparklesIcon, SearchIcon, PaletteIcon, ContrastIcon, MoonIcon, VerifiedIcon} from './docsite-icons';
+import {XDSBanner} from '@xds/core/Banner';
+import {XDSList, XDSListItem} from '@xds/core/List';
+import {XDSSelector} from '@xds/core/Selector';
+import {XDSCheckboxInput} from '@xds/core/CheckboxInput';
+import {XDSTable, pixel, proportional, useXDSTableSortable, useXDSTableSortableState} from '@xds/core/Table';
+import type {XDSTableColumn} from '@xds/core/Table';
+import {
+ PROFILE_CRAFT_ITEMS,
+ PROFILE_USED_ITEMS,
+ PROFILE_LIKED_ITEMS,
+ PROFILE_COLLECTIONS,
+ THEME_PICKER_ENTRIES,
+} from './constants';
+import {SearchIcon, BookmarkIcon, BookmarkFilledIcon, FolderIcon} from './docsite-icons';
+
+
+import {TemplatePreviewModal} from './TemplatePreviewModal';
+import {
+ getComponentName,
+ getComponentDocs,
+} from './docsview-data';
+import {COMPONENT_PREVIEWS} from './ComponentPreviews';
import {AppTopNav} from './AppTopNav';
-import {BookmarkIcon, Cog6ToothIcon, ClockIcon} from '@heroicons/react/24/outline';
+import {
+ Cog6ToothIcon,
+ EllipsisHorizontalIcon,
+ PencilIcon,
+ DocumentDuplicateIcon,
+ TrashIcon,
+ ArrowUpTrayIcon,
+ ArrowLeftIcon,
+ EyeIcon,
+ CursorArrowRaysIcon,
+ ClockIcon,
+ PlusIcon,
+} from '@heroicons/react/24/outline';
+
+function seededRandom(seed: number) {
+ let s = seed;
+ return () => {
+ s = (s * 16807 + 0) % 2147483647;
+ return s / 2147483647;
+ };
+}
+
+function generateSparklineData(seed: number, length = 12): number[] {
+ const rng = seededRandom(seed);
+ const points: number[] = [rng() * 40 + 30];
+ for (let i = 1; i < length; i++) {
+ const prev = points[i - 1];
+ points.push(Math.max(5, Math.min(95, prev + (rng() - 0.4) * 20)));
+ }
+ return points;
+}
+
+function Sparkline({data, width = '100%', height = 40}: {data: number[]; width?: string | number; height?: number}) {
+ const viewW = 200;
+ const viewH = height;
+ const max = Math.max(...data);
+ const min = Math.min(...data);
+ const range = max - min || 1;
+ const stepX = viewW / (data.length - 1);
+
+ const points = data.map((v, i) => {
+ const x = i * stepX;
+ const y = viewH - ((v - min) / range) * (viewH * 0.8) - viewH * 0.1;
+ return `${x},${y}`;
+ });
+
+ const linePath = `M${points.join('L')}`;
+ const areaPath = `${linePath}L${viewW},${viewH}L0,${viewH}Z`;
+
+ return (
+ <svg viewBox={`0 0 ${viewW} ${viewH}`} width={width} height={height} preserveAspectRatio="none">
+ <defs>
+ <linearGradient id="sparkFill" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0%" stopColor="var(--color-positive)" stopOpacity="0.15" />
+ <stop offset="100%" stopColor="var(--color-positive)" stopOpacity="0.02" />
+ </linearGradient>
+ </defs>
+ <path d={areaPath} fill="url(#sparkFill)" />
+ <path d={linePath} fill="none" stroke="var(--color-positive)" strokeWidth="2" vectorEffect="non-scaling-stroke" />
+ </svg>
+ );
+}
+
+function TrendIndicator({value}: {value: number}) {
+ const isPositive = value >= 0;
+ return (
+ <span style={{display: 'inline-flex', alignItems: 'center', gap: 4, color: 'var(--color-positive)'}}>
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
+ {isPositive ? (
+ <path d="M2 10C4 7 6 5 8 6C10 7 11 4 12 3" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
+ ) : (
+ <path d="M2 4C4 7 6 9 8 8C10 7 11 10 12 11" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
+ )}
+ </svg>
+ <span style={{fontSize: 13}}>{isPositive ? '+' : ''}{value}%</span>
+ </span>
+ );
+}
+
+function timeAgo(dateStr: string): string {
+ const now = new Date();
+ const then = new Date(dateStr);
+ const diffMs = now.getTime() - then.getTime();
+ const days = Math.floor(diffMs / (1000 * 60 * 60 * 24));
+ if (days < 1) return 'today';
+ if (days < 7) return `${days}d ago`;
+ if (days < 30) return `${Math.floor(days / 7)}w ago`;
+ if (days < 365) return `${Math.floor(days / 30)}mo ago`;
+ return `${Math.floor(days / 365)}y ago`;
+}
+
+const STATUS_VARIANT: Record<string, 'success' | 'warning' | 'neutral' | 'error'> = {
+ Published: 'success',
+ 'In Review': 'warning',
+ Draft: 'neutral',
+ 'Needs Fixes': 'error',
+};
+
+const TYPE_VARIANT: Record<string, 'blue' | 'purple' | 'teal'> = {
+ Template: 'blue',
+ Theme: 'purple',
+ Component: 'teal',
+};
+
+type CraftItem = (typeof PROFILE_CRAFT_ITEMS)[number] & Record<string, unknown>;
+
+function makeCraftColumns(
+ onPreview: (item: CraftItem) => void,
+): XDSTableColumn<CraftItem>[] {
+ return [
+ {
+ key: 'name',
+ header: 'Name',
+ width: proportional(3, {minWidth: 200}),
+ renderCell: (item) => (
+ <XDSHStack
+ gap={3}
+ vAlign="center"
+ style={{cursor: 'pointer'}}
+ onClick={() => onPreview(item)}>
+ <div
+ style={{
+ width: 80,
+ height: 52,
+ borderRadius: 8,
+ overflow: 'hidden',
+ flexShrink: 0,
+ backgroundColor: 'var(--color-background-muted, #f0f0f0)',
+ }}>
+ <img
+ src={item.img}
+ alt=""
+ style={{width: '100%', height: '100%', objectFit: 'cover', display: 'block'}}
+ />
+ </div>
+ <XDSVStack gap={0}>
+ <XDSText type="body" style={{fontWeight: 600}}>{item.name}</XDSText>
+ <XDSText type="supporting" color="secondary">{item.type}</XDSText>
+ </XDSVStack>
+ </XDSHStack>
+ ),
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ width: pixel(120),
+ sortable: true,
+ renderCell: (item) => (
+ <XDSBadge label={item.status} variant={STATUS_VARIANT[item.status]} />
+ ),
+ },
+ {
+ key: 'views',
+ header: 'Views',
+ width: pixel(100),
+ align: 'end',
+ sortable: true,
+ renderCell: (item) => (
+ (item.status === 'Draft' || item.status === 'Needs Fixes' || item.status === 'In Review') ? <XDSText type="body" color="secondary">—</XDSText> :
+ <XDSText type="body" color="secondary">{item.views.toLocaleString()}</XDSText>
+ ),
+ },
+ {
+ key: 'used',
+ header: 'Uses',
+ width: pixel(80),
+ align: 'end',
+ sortable: true,
+ renderCell: (item) => (
+ (item.status === 'Draft' || item.status === 'Needs Fixes' || item.status === 'In Review') ? <XDSText type="body" color="secondary">—</XDSText> :
+ <XDSText type="body" color="secondary">{item.used.toLocaleString()}</XDSText>
+ ),
+ },
+ {
+ key: 'lastUpdated',
+ header: 'Updated',
+ width: pixel(100),
+ sortable: true,
+ renderCell: (item) => (
+ <XDSText type="body" color="secondary">{timeAgo(item.lastUpdated)}</XDSText>
+ ),
+ },
+ {
+ key: 'actions',
+ header: '',
+ width: pixel(48),
+ renderCell: (item) => (
+ <div style={{position: 'relative'}}>
+ <XDSDropdownMenu
+ button={{
+ label: 'Actions',
+ variant: 'ghost',
+ size: 'sm',
+ isIconOnly: true,
+ icon: <EllipsisHorizontalIcon style={{width: 18, height: 18}} />,
+ }}
+ hasChevron={false}
+ items={[
+ {label: 'Edit', icon: PencilIcon, onClick: () => {}},
+ {label: 'Duplicate', icon: DocumentDuplicateIcon, onClick: () => {}},
+ {
+ label: item.status === 'Published' ? 'Unpublish' : 'Publish',
+ icon: ArrowUpTrayIcon,
+ onClick: () => {},
+ },
+ {type: 'divider' as const},
+ {label: 'Delete', icon: TrashIcon, onClick: () => {}},
+ ]}
+ />
+ </div>
+ ),
+ },
+ ];
+}
+
+type UsedItem = (typeof PROFILE_USED_ITEMS)[number] & Record<string, unknown>;
+
+function makeUsedColumns(
+ onPreviewTemplate: (item: UsedItem) => void,
+ onOpenComponentDocs: (componentKey: string) => void,
+): XDSTableColumn<UsedItem>[] {
+ return [
+ {
+ key: 'name',
+ header: 'Name',
+ width: proportional(3, {minWidth: 200}),
+ renderCell: (item) => (
+ <XDSHStack
+ gap={3}
+ vAlign="center"
+ style={{cursor: 'pointer'}}
+ onClick={() => {
+ if (item.type === 'Component') {
+ onOpenComponentDocs(item.name.toLowerCase().replace(/\s+/g, ''));
+ } else {
+ onPreviewTemplate(item);
+ }
+ }}>
+ <div
+ style={{
+ width: 80,
+ height: 52,
+ borderRadius: 8,
+ overflow: 'hidden',
+ flexShrink: 0,
+ backgroundColor: 'var(--color-background-muted, #f0f0f0)',
+ }}>
+ <img
+ src={item.img}
+ alt=""
+ style={{width: '100%', height: '100%', objectFit: 'cover', display: 'block'}}
+ />
+ </div>
+ <XDSVStack gap={0.5} style={{minWidth: 0}}>
+ <XDSText type="body" style={{fontWeight: 600}}>{item.name}</XDSText>
+ <XDSText
+ type="supporting"
+ color="secondary"
+ style={{overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'}}>
+ {item.description}
+ </XDSText>
+ </XDSVStack>
+ </XDSHStack>
+ ),
+ },
+ {
+ key: 'type',
+ header: 'Type',
+ width: pixel(120),
+ sortable: true,
+ renderCell: (item) => (
+ <XDSBadge label={item.type} variant={TYPE_VARIANT[item.type]} />
+ ),
+ },
+ {
+ key: 'usageCount',
+ header: 'Times Used',
+ width: pixel(100),
+ align: 'end',
+ sortable: true,
+ renderCell: (item) => (
+ <XDSText type="body" color="secondary">{item.usageCount}</XDSText>
+ ),
+ },
+ {
+ key: 'lastUsed',
+ header: 'Last Used',
+ width: pixel(100),
+ sortable: true,
+ renderCell: (item) => (
+ <XDSText type="body" color="secondary">{timeAgo(item.lastUsed)}</XDSText>
+ ),
+ },
+ ];
+}
+
+function BookmarkCard({
+ item,
+ index,
+ onRemove,
+ onClick,
+}: {
+ item: (typeof PROFILE_LIKED_ITEMS)[number];
+ index: number;
+ onRemove: () => void;
+ onClick: () => void;
+}) {
+ const [hovered, setHovered] = useState(false);
+ return (
+ <div
+ style={{
+ animation: `craftCardFadeIn 400ms ${index * 60}ms cubic-bezier(0.16, 1, 0.3, 1) both`,
+ }}>
+ <XDSCard padding={0}>
+ <div
+ style={{
+ position: 'relative',
+ cursor: 'pointer',
+ overflow: 'hidden',
+ }}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ onClick={onClick}>
+ <img
+ src={item.img}
+ alt={item.name}
+ style={{
+ display: 'block',
+ width: '100%',
+ aspectRatio: '1920 / 1205',
+ objectFit: 'cover',
+ objectPosition: 'top',
+ }}
+ />
+ <div
+ style={{
+ position: 'absolute',
+ inset: 0,
+ backgroundColor: 'var(--color-overlay, rgba(0,0,0,0.5))',
+ opacity: hovered ? 1 : 0,
+ transition: 'opacity 300ms ease',
+ }}>
+ {/* Top-right: remove bookmark */}
+ <div
+ style={{
+ position: 'absolute',
+ top: 12,
+ right: 12,
+ }}
+ onClick={e => e.stopPropagation()}>
+ <XDSButton
+ label="Remove bookmark"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={
+ <BookmarkFilledIcon style={{width: 16, height: 16}} />
+ }
+ style={{color: '#fff'}}
+ onClick={onRemove}
+ />
+ </div>
+ {/* Bottom: info + actions */}
+ <div
+ onClick={e => e.stopPropagation()}
+ style={{
+ position: 'absolute',
+ bottom: 0,
+ left: 0,
+ right: 0,
+ padding: 16,
+ background:
+ 'linear-gradient(to top, rgba(0,0,0,0.6), transparent)',
+ display: 'flex',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ }}>
+ <XDSVStack gap={0}>
+ <XDSHeading level={3} style={{color: '#fff'}}>
+ {item.name}
+ </XDSHeading>
+ <XDSText
+ type="supporting"
+ style={{color: 'rgba(255,255,255,0.7)'}}>
+ {item.type} · Bookmarked {timeAgo(item.bookmarkedAt)}
+ </XDSText>
+ </XDSVStack>
+ <XDSHStack gap={2} style={{flexShrink: 0}}>
+ <XDSButton
+ label="Use"
+ variant="secondary"
+ size="sm"
+ style={{backgroundColor: 'var(--color-background-surface)'}}
+ onClick={() => {}}
+ />
+ <XDSButton
+ label="Craft"
+ variant="secondary"
+ size="sm"
+ style={{backgroundColor: 'var(--color-background-surface)'}}
+ onClick={() => {}}
+ />
+ </XDSHStack>
+ </div>
+ </div>
+ </div>
+ </XDSCard>
+ </div>
+ );
+}
+
+function PreviewDialogShell({
+ isOpen,
+ onClose,
+ imgSrc,
+ imgAlt,
+ children,
+}: {
+ isOpen: boolean;
+ onClose: () => void;
+ imgSrc: string;
+ imgAlt: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <XDSDialog
+ isOpen={isOpen}
+ onOpenChange={(open) => { if (!open) onClose(); }}
+ width="90vw"
+ maxHeight="90vh"
+ purpose="info"
+ style={{padding: 0, overflow: 'visible', maxWidth: 1600, '--xds-dialog-padding': '0px'} as React.CSSProperties}>
+ {isOpen && (
+ <>
+ <div style={{position: 'absolute', top: 0, right: -40, zIndex: 1}}>
+ <XDSCard padding={0} style={{borderRadius: '50%'}}>
+ <XDSButton
+ label="Close"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<span style={{fontSize: 16, lineHeight: 1}}>✕</span>}
+ onClick={onClose}
+ />
+ </XDSCard>
+ </div>
+ <div style={{overflowY: 'auto', height: '100%'}}>
+ <div style={{display: 'flex', minHeight: '100%', padding: '0 32px'}}>
+ <XDSVStack
+ gap={3}
+ style={{flex: 1, minWidth: 0, padding: '32px 32px 32px 0'}}>
+ <div
+ style={{
+ flex: 1,
+ aspectRatio: '16 / 10',
+ backgroundColor: 'var(--color-background-muted, #f9f9f9)',
+ borderRadius: 12,
+ overflowY: 'auto',
+ overflowX: 'hidden',
+ border: '1px solid var(--color-border, #e0e0e0)',
+ }}>
+ <img
+ src={imgSrc}
+ alt={imgAlt}
+ style={{width: '100%', display: 'block'}}
+ />
+ </div>
+ </XDSVStack>
+ <XDSVStack style={{width: 360, flexShrink: 0, padding: '32px 0'}}>
+ {children}
+ </XDSVStack>
+ </div>
+ </div>
+ </>
+ )}
+ </XDSDialog>
+ );
+}
export function DialogPreview() {
const [isOpen, setIsOpen] = useState(false);
@@ -36,253 +532,1395 @@ export function DialogPreview() {
);
}
-function SearchableFilterDropdown({label, items, selectedFilters, onToggle, verifiedItems}: {label: string; items: string[]; selectedFilters: Set<string>; onToggle: (item: string) => void; verifiedItems?: Set<string>}) {
- const [isOpen, setIsOpen] = useState(false);
- const [search, setSearch] = useState('');
- const filtered = items.filter(item => item.toLowerCase().includes(search.toLowerCase()));
- return (
- <XDSPopover label={label} placement="below" alignment="start" width={280} isOpen={isOpen} onOpenChange={open => { setIsOpen(open); if (!open) setSearch(''); }}
- content={
- <div style={{display: 'flex', flexDirection: 'column', gap: 4}}>
- <div tabIndex={0} style={{position: 'absolute', opacity: 0, width: 0, height: 0, overflow: 'hidden'}} />
- <XDSTextInput label="Search" isLabelHidden placeholder={`Search ${label.toLowerCase()}...`} value={search} onChange={setSearch} size="lg" startIcon={SearchIcon} />
- <div style={{maxHeight: 280, overflowY: 'auto', margin: '0 -8px'}}>
- {filtered.length === 0 ? (
- <div style={{padding: '12px 16px'}}><XDSText type="body" color="secondary">No results</XDSText></div>
- ) : (
- <XDSList density="spacious">
- {filtered.map(item => (
- <XDSListItem key={item} label={item} isSelected={selectedFilters.has(item)} onClick={() => onToggle(item)}
- endContent={verifiedItems?.has(item) ? <XDSIcon icon={VerifiedIcon} size="sm" color="accent" /> : undefined} />
- ))}
- </XDSList>
- )}
- </div>
- </div>
- }>
- <XDSButton label={label} variant="ghost" size="sm" endContent={<XDSIcon icon="chevronDown" size="sm" color="inherit" />} />
- </XDSPopover>
- );
-}
+const PROFILE_TABS = ['Crafted', 'Used', 'Bookmarks'] as const;
+
+const CRAFT_TYPE_OPTIONS = [
+ {value: 'all', label: 'All types'},
+ {value: 'Template', label: 'Template'},
+ {value: 'Theme', label: 'Theme'},
+ {value: 'Component', label: 'Component'},
+];
+
+const CRAFT_STATUS_OPTIONS = [
+ {value: 'all', label: 'All statuses'},
+ {value: 'Published', label: 'Published'},
+ {value: 'In Review', label: 'In Review'},
+ {value: 'Needs Fixes', label: 'Needs Fixes'},
+ {value: 'Draft', label: 'Draft'},
+];
+
+const CRAFT_SORT_OPTIONS = [
+ {value: 'recent', label: 'Most recent'},
+ {value: 'views', label: 'Most views'},
+ {value: 'uses', label: 'Most used'},
+];
-const NAV_ITEMS = [
- {label: 'Crafted', icon: SparklesIcon},
- {label: 'Used', icon: ClockIcon},
- {label: 'Bookmarks', icon: BookmarkIcon},
- {label: 'Settings', icon: Cog6ToothIcon},
+const USED_SORT_OPTIONS = [
+ {value: 'recent', label: 'Last used'},
+ {value: 'frequency', label: 'Most used'},
+ {value: 'name', label: 'Name'},
];
-const GRID_NAVS = ['Used', 'Bookmarks'] as const;
-export function ProfileView({activeView, setActiveView}: {activeView: 'craft' | 'explore' | 'docs' | 'profile'; setActiveView: (v: 'craft' | 'explore' | 'docs' | 'profile') => void}) {
- const [activeNav, setActiveNav] = useState('Crafted');
+export function ProfileView({
+ activeView,
+ setActiveView,
+ onStartCrafting,
+ profileTab,
+ onTabChange,
+ profileCraftName,
+ onCraftPreviewChange,
+ profileUsedName,
+ onUsedPreviewChange,
+ profileSettingsOpen,
+ onSettingsChange,
+ profileCollectionName,
+ onCollectionChange,
+}: {
+ activeView: 'craft' | 'explore' | 'docs' | 'profile';
+ setActiveView: (v: 'craft' | 'explore' | 'docs' | 'profile') => void;
+ onStartCrafting: () => void;
+ profileTab: 'Crafted' | 'Used' | 'Bookmarks';
+ onTabChange: (tab: 'Crafted' | 'Used' | 'Bookmarks') => void;
+ profileCraftName: string | null;
+ onCraftPreviewChange: (name: string | null) => void;
+ profileUsedName: string | null;
+ onUsedPreviewChange: (name: string | null) => void;
+ profileSettingsOpen: boolean;
+ onSettingsChange: (open: boolean) => void;
+ profileCollectionName: string | null;
+ onCollectionChange: (name: string | null) => void;
+}) {
+ const activeTab = profileTab;
+ const setActiveTab = onTabChange;
+ const isSettingsOpen = profileSettingsOpen;
+ const setIsSettingsOpen = onSettingsChange;
+
+ const previewItem = useMemo(() => {
+ if (!profileCraftName) return null;
+ return (
+ (PROFILE_CRAFT_ITEMS.find(i => i.name === profileCraftName) ??
+ null) as CraftItem | null
+ );
+ }, [profileCraftName]);
+ const setPreviewItem = useCallback(
+ (item: CraftItem | null) => onCraftPreviewChange(item ? item.name : null),
+ [onCraftPreviewChange],
+ );
+
+ const [selectedTheme, setSelectedTheme] = useState('default');
+ const [sendTo, setSendTo] = useState('clipboard');
+
+ // Crafted tab state
const [craftTypeFilter, setCraftTypeFilter] = useState('all');
const [craftStatusFilter, setCraftStatusFilter] = useState('all');
- const craftTypeCounts = useMemo(() => ({
- template: PROFILE_CRAFT_ITEMS.filter(i => i.type === 'Template').length,
- theme: PROFILE_CRAFT_ITEMS.filter(i => i.type === 'Theme').length,
- component: PROFILE_CRAFT_ITEMS.filter(i => i.type === 'Component').length,
- }), []);
- const craftStatusCounts = useMemo(() => ({
- published: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'Published').length,
- draft: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'Draft').length,
- review: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'In Review').length,
- }), []);
- const filteredCraftItems = useMemo(() => {
- let items = PROFILE_CRAFT_ITEMS;
- if (craftTypeFilter !== 'all') items = items.filter(i => i.type === craftTypeFilter);
- if (craftStatusFilter !== 'all') items = items.filter(i => i.status === craftStatusFilter);
- return items;
- }, [craftTypeFilter, craftStatusFilter]);
-
- const [previewMode, setPreviewMode] = useState<'light' | 'dark'>('light');
- const [previewTheme, setPreviewTheme] = useState('default');
- const [sortOption, setSortOption] = useState('trending');
- const [resultFilters, setResultFilters] = useState<Set<string>>(() => new Set());
- const handleToggleResultFilter = (filter: string) => {
- setResultFilters(prev => { const next = new Set(prev); if (next.has(filter)) next.delete(filter); else next.add(filter); return next; });
- };
- const previewImageFilter = useMemo(() => {
- const filters: string[] = [];
- if (previewMode === 'dark') filters.push('invert(0.88)', 'hue-rotate(180deg)');
- const tf: Record<string, string> = {neutral: 'saturate(0.3)', brutalist: 'contrast(1.2) saturate(0.5)', meta: 'sepia(0.15) saturate(1.4) hue-rotate(200deg)', whatsapp: 'sepia(0.2) saturate(1.3) hue-rotate(100deg)'};
- if (tf[previewTheme]) filters.push(tf[previewTheme]);
- return filters.length > 0 ? filters.join(' ') : undefined;
- }, [previewMode, previewTheme]);
- const templateAuthors = useMemo(() => {
- const authors = Array.from(new Set(TEMPLATES.map(t => t.author)));
- return authors.sort((a, b) => { if (a === 'XDS Design') return -1; if (b === 'XDS Design') return 1; return a.localeCompare(b); });
+ const [craftSort, setCraftSort] = useState('recent');
+
+ const handlePreview = useCallback(
+ (item: CraftItem) => {
+ setPreviewItem(item);
+ },
+ [setPreviewItem],
+ );
+
+ const craftColumns = useMemo(
+ () => makeCraftColumns(handlePreview),
+ [handlePreview],
+ );
+
+ // Crafted table sorting
+ const craftSortState = useXDSTableSortableState<CraftItem, 'lastUpdated' | 'views' | 'used'>({
+ data: [] as CraftItem[],
+ defaultSort: [{sortKey: 'lastUpdated', direction: 'descending'}],
+ comparators: {
+ views: (a, b) => a.views - b.views,
+ used: (a, b) => a.used - b.used,
+ lastUpdated: (a, b) =>
+ new Date(a.lastUpdated).getTime() - new Date(b.lastUpdated).getTime(),
+ },
+ });
+ const craftSortPlugin = useXDSTableSortable<CraftItem, 'lastUpdated' | 'views' | 'used'>(craftSortState.sortConfig);
+
+ // Used tab state
+ const [usedSearch, setUsedSearch] = useState('');
+ const [usedSort, setUsedSort] = useState('recent');
+ const [usedTypeFilter, setUsedTypeFilter] = useState('all');
+ const previewUsedItem = useMemo(() => {
+ if (!profileUsedName) return null;
+ return (
+ (PROFILE_USED_ITEMS.find(i => i.name === profileUsedName) ??
+ null) as UsedItem | null
+ );
+ }, [profileUsedName]);
+ const setPreviewUsedItem = useCallback(
+ (item: UsedItem | null) => onUsedPreviewChange(item ? item.name : null),
+ [onUsedPreviewChange],
+ );
+
+ const [componentDrawerKey, setComponentDrawerKey] = useState<string | null>(null);
+
+ const handlePreviewUsed = useCallback(
+ (item: UsedItem) => {
+ setPreviewUsedItem(item);
+ },
+ [setPreviewUsedItem],
+ );
+
+ const handleOpenComponentDocs = useCallback((key: string) => {
+ setComponentDrawerKey(key);
}, []);
- const filteredTemplates = useMemo(() => TEMPLATES.map((t, i) => ({...t, originalIndex: i})), []);
- const [selectedTheme, setSelectedTheme] = useState('default');
- const [sendTo, setSendTo] = useState('clipboard');
+
+ const usedColumns = useMemo(
+ () => makeUsedColumns(handlePreviewUsed, handleOpenComponentDocs),
+ [handlePreviewUsed, handleOpenComponentDocs],
+ );
+
+ // Used table sorting
+ const usedSortState = useXDSTableSortableState<UsedItem, 'lastUsed' | 'usageCount'>({
+ data: [] as UsedItem[],
+ defaultSort: [{sortKey: 'lastUsed', direction: 'descending'}],
+ comparators: {
+ usageCount: (a, b) => a.usageCount - b.usageCount,
+ lastUsed: (a, b) =>
+ new Date(a.lastUsed).getTime() - new Date(b.lastUsed).getTime(),
+ },
+ });
+ const usedSortPlugin = useXDSTableSortable<UsedItem, 'lastUsed' | 'usageCount'>(usedSortState.sortConfig);
+
+ // Bookmarks tab state
+ const [bookmarkSearch, setBookmarkSearch] = useState('');
+ const [removedBookmarks, setRemovedBookmarks] = useState<Set<string>>(
+ () => new Set(),
+ );
+ const [previewBookmarkItem, setPreviewBookmarkItem] = useState<
+ (typeof PROFILE_LIKED_ITEMS)[number] | null
+ >(null);
+ const [editingCollectionName, setEditingCollectionName] = useState(false);
+ const [collectionNameDraft, setCollectionNameDraft] = useState('');
+ const [editingCollectionItems, setEditingCollectionItems] = useState(false);
+ const [collectionItemsDraft, setCollectionItemsDraft] = useState<Set<string>>(() => new Set());
+ const [isNewCollection, setIsNewCollection] = useState(false);
+
+ const handleBookmarkClick = useCallback(
+ (item: (typeof PROFILE_LIKED_ITEMS)[number]) => {
+ if (item.type === 'Component') {
+ setComponentDrawerKey(item.name.toLowerCase().replace(/\s+/g, ''));
+ } else {
+ setPreviewBookmarkItem(item);
+ }
+ },
+ [],
+ );
+ const selectedCollection = useMemo(() => {
+ if (isNewCollection) {
+ return {name: collectionNameDraft || 'Untitled', count: 0, color: '#6B7280', items: [] as string[]};
+ }
+ if (!profileCollectionName) return null;
+ return (
+ PROFILE_COLLECTIONS.find(c => c.name === profileCollectionName) ?? null
+ );
+ }, [profileCollectionName, isNewCollection, collectionNameDraft]);
+ const setSelectedCollection = useCallback(
+ (col: (typeof PROFILE_COLLECTIONS)[number] | null) =>
+ onCollectionChange(col ? col.name : null),
+ [onCollectionChange],
+ );
+
+ const filteredCrafts = useMemo(() => {
+ let items = [...PROFILE_CRAFT_ITEMS];
+ if (craftTypeFilter !== 'all') {
+ items = items.filter(i => i.type === craftTypeFilter);
+ }
+ if (craftStatusFilter !== 'all') {
+ items = items.filter(i => i.status === craftStatusFilter);
+ }
+ items.sort((a, b) => {
+ if (craftSort === 'views') return b.views - a.views;
+ if (craftSort === 'uses') return b.used - a.used;
+ return (
+ new Date(b.lastUpdated).getTime() - new Date(a.lastUpdated).getTime()
+ );
+ });
+ return items;
+ }, [craftTypeFilter, craftStatusFilter, craftSort]);
+
+ const filteredUsed = useMemo(() => {
+ let items = [...PROFILE_USED_ITEMS];
+ if (usedTypeFilter !== 'all') {
+ items = items.filter(i => i.type === usedTypeFilter);
+ }
+ if (usedSearch) {
+ const q = usedSearch.toLowerCase();
+ items = items.filter(
+ i =>
+ i.name.toLowerCase().includes(q) ||
+ i.description.toLowerCase().includes(q),
+ );
+ }
+ items.sort((a, b) => {
+ if (usedSort === 'frequency') return b.usageCount - a.usageCount;
+ if (usedSort === 'name') return a.name.localeCompare(b.name);
+ return (
+ new Date(b.lastUsed).getTime() - new Date(a.lastUsed).getTime()
+ );
+ });
+ return items;
+ }, [usedSearch, usedSort, usedTypeFilter]);
+
+ const filteredBookmarks = useMemo(() => {
+ let items = PROFILE_LIKED_ITEMS.filter(
+ i => !removedBookmarks.has(i.name),
+ );
+ if (bookmarkSearch) {
+ const q = bookmarkSearch.toLowerCase();
+ items = items.filter(
+ i =>
+ i.name.toLowerCase().includes(q) ||
+ i.description.toLowerCase().includes(q),
+ );
+ }
+ return items;
+ }, [bookmarkSearch, removedBookmarks]);
+
+ const collectionItems = useMemo(() => {
+ if (!selectedCollection) return [];
+ const itemNames = new Set(selectedCollection.items);
+ return PROFILE_LIKED_ITEMS.filter(
+ i => itemNames.has(i.name) && !removedBookmarks.has(i.name),
+ );
+ }, [selectedCollection, removedBookmarks]);
+
return (
- <div style={{display: 'flex', flexDirection: 'column' as const, height: '100vh'}}>
- <AppTopNav activeView={activeView} setActiveView={setActiveView} activeTab="all" onActiveTabChange={() => setActiveView('craft')} />
- <div style={{flex: 1, display: 'flex', overflow: 'hidden'}}>
- <nav style={{width: 280, flexShrink: 0, height: '100%', overflowY: 'auto' as const, marginLeft: 8, marginRight: 8}}>
- <div style={{display: 'flex', flexDirection: 'column' as const}}>
- <div style={{padding: 16}}><XDSHeading level={2}>Profile</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>
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'column' as const,
+ height: '100vh',
+ }}>
+ <AppTopNav
+ activeView={activeView}
+ setActiveView={setActiveView}
+ activeTab="all"
+ onActiveTabChange={() => setActiveView('craft')}
+ />
+ <div
+ style={{
+ flex: 1,
+ overflowY: 'auto' as const,
+ padding: '32px 24px 140px',
+ }}>
+ <style>{`
+ @keyframes craftCardFadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
+ `}</style>
+
+ <div style={{maxWidth: 1400, margin: '0 auto'}}>
+ {/* Profile header */}
+ <div style={{marginBottom: 32}}>
+ <XDSText type="display-1">Your crafts</XDSText>
</div>
- </nav>
- <div style={{flex: 1, overflowY: 'auto' as const, height: '100%', padding: '16px 24px 140px'}}>
- <style>{`
- @keyframes craftCardFadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
- @keyframes craftTitleSlideIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
- `}</style>
-
- {activeNav === 'Crafted' && (
- <div style={{maxWidth: 2000, margin: '0 auto'}}>
- <div style={{animation: 'craftTitleSlideIn 400ms cubic-bezier(0.16, 1, 0.3, 1)', marginBottom: 16}}>
- <XDSText type="display-1">Crafted</XDSText>
- </div>
- <div style={{display: 'flex', gap: 6, flexWrap: 'wrap' as const, marginBottom: 8, animation: 'craftTitleSlideIn 400ms 100ms cubic-bezier(0.16, 1, 0.3, 1) both'}}>
- {[{value: 'all', label: `All (${PROFILE_CRAFT_ITEMS.length})`}, {value: 'Template', label: `Templates (${craftTypeCounts.template})`}, {value: 'Theme', label: `Themes (${craftTypeCounts.theme})`}, {value: 'Component', label: `Components (${craftTypeCounts.component})`}].map(tab => (
- <XDSButton key={tab.value} label={tab.label} variant={craftTypeFilter === tab.value ? 'primary' : 'secondary'} size="sm" onClick={() => setCraftTypeFilter(tab.value)} />
- ))}
- <XDSDivider orientation="vertical" />
- {[{value: 'all', label: 'All statuses'}, {value: 'Published', label: `Published (${craftStatusCounts.published})`}, {value: 'Draft', label: `Draft (${craftStatusCounts.draft})`}, {value: 'In Review', label: `In Review (${craftStatusCounts.review})`}].map(tab => (
- <XDSButton key={tab.value} label={tab.label} variant={craftStatusFilter === tab.value ? 'primary' : 'secondary'} size="sm" onClick={() => setCraftStatusFilter(tab.value)} />
- ))}
- </div>
- <div style={{marginBottom: 16}}><XDSText type="supporting" color="secondary">{filteredCraftItems.length} of {PROFILE_CRAFT_ITEMS.length} items</XDSText></div>
- <div style={{display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16}}>
- {filteredCraftItems.map((item, i) => (
- <XDSCard key={item.name} padding={0} style={{overflow: 'hidden', animation: `craftCardFadeIn 400ms ${i * 50}ms cubic-bezier(0.16, 1, 0.3, 1) both`}}>
- <div style={{aspectRatio: '16 / 9', overflow: 'hidden', backgroundColor: 'var(--color-background-muted, #f0f0f0)'}}>
- <img src={item.img} alt={item.name} style={{width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'top', display: 'block'}} />
- </div>
- <div style={{padding: 16}}>
- <div style={{display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8}}>
- <XDSText type="body" weight="bold">{item.name}</XDSText>
- <span style={{fontSize: 11, fontWeight: 600, padding: '2px 8px', borderRadius: 9999, whiteSpace: 'nowrap' as const, flexShrink: 0,
- backgroundColor: item.status === 'Published' ? '#ECFDF3' : item.status === 'In Review' ? '#FFFAEB' : '#F2F4F7',
- color: item.status === 'Published' ? '#027A48' : item.status === 'In Review' ? '#B54708' : '#667085'}}>
- {item.status}
- </span>
- </div>
- <div style={{marginTop: 4}}><XDSText type="supporting" color="secondary">{item.description}</XDSText></div>
- <div style={{display: 'flex', alignItems: 'center', gap: 8, marginTop: 12}}>
- <span style={{fontSize: 11, fontWeight: 500, padding: '1px 6px', borderRadius: 4, backgroundColor: 'var(--color-background-muted, #f0f0f0)', color: 'var(--color-text-secondary, #666)'}}>{item.type}</span>
- <XDSText type="supporting" color="secondary">{item.used} uses</XDSText>
- <XDSText type="supporting" color="secondary">{item.views} views</XDSText>
- <div style={{marginLeft: 'auto'}}><XDSText type="supporting" color="secondary">{new Date(item.lastUpdated).toLocaleDateString('en-US', {month: 'short', day: 'numeric'})}</XDSText></div>
- </div>
- </div>
- </XDSCard>
+ </div>
+
+ {/* Tab bar + settings — full-width divider with tabs resting on the line */}
+ <div style={{
+ borderBottom: '1px solid var(--color-divider, #e0e0e0)',
+ }}>
+ <div style={{maxWidth: 1400, margin: '0 auto', marginBottom: -1}}>
+ <XDSHStack vAlign="end">
+ <XDSTabList
+ value={activeTab}
+ onChange={v => {
+ setActiveTab(v as (typeof PROFILE_TABS)[number]);
+ setSelectedCollection(null);
+ }}
+ size="lg"
+ hasDivider={false}>
+ {PROFILE_TABS.map(tab => (
+ <XDSTab key={tab} value={tab} label={tab} />
))}
- {filteredCraftItems.length === 0 && <div style={{gridColumn: '1 / -1', padding: 32, textAlign: 'center' as const}}><XDSText type="body" color="secondary">No items match this filter.</XDSText></div>}
+ </XDSTabList>
+ <XDSStackItem size="fill" />
+ <div style={{paddingBottom: 8}}>
+ <XDSButton
+ label="Settings"
+ variant="ghost"
+ size="lg"
+ isIconOnly
+ icon={
+ <Cog6ToothIcon style={{width: 24, height: 24}} />
+ }
+ onClick={() => setIsSettingsOpen(true)}
+ />
</div>
- </div>
+ </XDSHStack>
+ </div>
+ </div>
+
+ <div style={{maxWidth: 1400, margin: '0 auto'}}>
+ {/* ===== CRAFTED TAB ===== */}
+ {activeTab === 'Crafted' && (
+ <>
+ {/* Filter + sort + actions row */}
+ <XDSHStack
+ gap={2}
+ vAlign="center"
+ style={{marginTop: 32, marginBottom: 20}}>
+ <XDSSelector
+ label="Type"
+ isLabelHidden
+ options={CRAFT_TYPE_OPTIONS}
+ value={craftTypeFilter}
+ onChange={setCraftTypeFilter}
+ size="md"
+ />
+ <XDSSelector
+ label="Status"
+ isLabelHidden
+ options={CRAFT_STATUS_OPTIONS}
+ value={craftStatusFilter}
+ onChange={setCraftStatusFilter}
+ size="md"
+ />
+ <XDSSelector
+ label="Sort"
+ isLabelHidden
+ options={CRAFT_SORT_OPTIONS}
+ value={craftSort}
+ onChange={setCraftSort}
+ size="md"
+ />
+ <XDSStackItem size="fill" />
+ <XDSButton
+ label="Start crafting"
+ variant="primary"
+ size="md"
+ onClick={onStartCrafting}
+ />
+ </XDSHStack>
+
+ <XDSTable
+ data={filteredCrafts as CraftItem[]}
+ columns={craftColumns}
+ idKey="name"
+ hasHover
+ plugins={{sort: craftSortPlugin}}
+ emptyState={
+ <XDSEmptyState
+ title="No crafts yet"
+ description="Create your first template, theme, or component and publish it to the community."
+ actions={
+ <XDSButton
+ label="Start crafting"
+ variant="primary"
+ onClick={onStartCrafting}
+ />
+ }
+ />
+ }
+ />
+ </>
)}
- {(GRID_NAVS as readonly string[]).includes(activeNav) && (
- <div style={{maxWidth: 2000, margin: '0 auto'}}>
- <div style={{animation: 'craftTitleSlideIn 400ms cubic-bezier(0.16, 1, 0.3, 1)', marginBottom: 16}}><XDSText type="display-1">{activeNav}</XDSText></div>
- <div style={{display: 'flex', flexDirection: 'column' as const, gap: 4, marginBottom: 20, animation: 'craftTitleSlideIn 400ms 100ms cubic-bezier(0.16, 1, 0.3, 1) both'}}>
- <div style={{display: 'flex', alignItems: 'center', gap: 4, marginLeft: -8, marginRight: -8}}>
- {FILTER_COLUMNS.map(col => <SearchableFilterDropdown key={col.heading} label={col.heading} items={col.items} selectedFilters={resultFilters} onToggle={handleToggleResultFilter} />)}
- <SearchableFilterDropdown label="Author" items={templateAuthors} selectedFilters={resultFilters} onToggle={handleToggleResultFilter} verifiedItems={new Set(['XDS Design'])} />
- <div style={{marginLeft: 'auto', display: 'flex', alignItems: 'center', gap: 16}}>
- <XDSText type="supporting" color="secondary" style={{whiteSpace: 'nowrap'}}>Showing {filteredTemplates.length} screens</XDSText>
- <XDSToolbar label="View controls" density="compact" startContent={<>
- <XDSButton label={previewMode === 'dark' ? 'Light mode' : 'Dark mode'} variant="ghost" size="sm" isIconOnly icon={previewMode === 'dark' ? <ContrastIcon /> : <MoonIcon />} onClick={() => setPreviewMode(previewMode === 'dark' ? 'light' : 'dark')} />
- <XDSDropdownMenu button={{label: 'Theme', variant: 'ghost', size: 'sm', isIconOnly: true, icon: <PaletteIcon />}} hasChevron={false} menuWidth={160}
- items={[{label: 'Default', onClick: () => setPreviewTheme('default')}, {label: 'Neutral', onClick: () => setPreviewTheme('neutral')}, {label: 'Brutalist', onClick: () => setPreviewTheme('brutalist')}, {label: 'Meta', onClick: () => setPreviewTheme('meta')}, {label: 'WhatsApp', onClick: () => setPreviewTheme('whatsapp')}]} />
- </>} />
- <XDSDropdownMenu button={{label: sortOption === 'trending' ? 'Trending' : sortOption === 'newest' ? 'Newest first' : 'Oldest first', variant: 'ghost', size: 'sm'}}
- items={[{label: 'Trending', onClick: () => setSortOption('trending')}, {label: 'Newest first', onClick: () => setSortOption('newest')}, {label: 'Oldest first', onClick: () => setSortOption('oldest')}]} />
- </div>
+ {/* ===== USED TAB ===== */}
+ {activeTab === 'Used' && (
+ <>
+ <XDSHStack
+ gap={2}
+ vAlign="center"
+ style={{marginTop: 32, marginBottom: 20}}>
+ <div style={{width: 280}}>
+ <XDSTextInput
+ label="Search"
+ isLabelHidden
+ placeholder="Search used items..."
+ value={usedSearch}
+ onChange={setUsedSearch}
+ size="md"
+ startIcon={SearchIcon}
+ />
</div>
- {resultFilters.size > 0 && (
- <div style={{display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap'}}>
- {Array.from(resultFilters).map(f => <XDSToken key={f} label={f} size="sm" onRemove={() => handleToggleResultFilter(f)} />)}
- <XDSText type="supporting"><XDSLink label="Clear all" color="secondary" onClick={() => setResultFilters(new Set())}>Clear all</XDSLink></XDSText>
- </div>
- )}
- </div>
- <div style={{display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16, gridAutoRows: '1fr'}}>
- {filteredTemplates.map((template, i) => (
- <div key={`${template.name}-${template.originalIndex}`} style={{animation: `craftCardFadeIn 400ms ${i * 50}ms cubic-bezier(0.16, 1, 0.3, 1) both`, filter: previewImageFilter, transition: 'filter 300ms ease'}}>
- <TemplateCard src={template.src} name={template.name} isGenerating={false} cardSize={template.size} onUse={() => {}} onPreview={() => {}} />
- </div>
- ))}
- </div>
- </div>
+ <XDSSelector
+ label="Type"
+ isLabelHidden
+ options={CRAFT_TYPE_OPTIONS}
+ value={usedTypeFilter}
+ onChange={setUsedTypeFilter}
+ size="md"
+ />
+ <XDSSelector
+ label="Sort"
+ isLabelHidden
+ options={USED_SORT_OPTIONS}
+ value={usedSort}
+ onChange={setUsedSort}
+ size="md"
+ />
+ <XDSStackItem size="fill" />
+ </XDSHStack>
+
+ {filteredUsed.length === 0 ? (
+ <div style={{marginTop: 48}}>
+ <XDSEmptyState
+ title={
+ usedSearch
+ ? 'No results found'
+ : "You haven't used anything yet"
+ }
+ description={
+ usedSearch
+ ? 'Try a different search term.'
+ : 'Browse the community and start using templates, themes, and components in your projects.'
+ }
+ actions={
+ !usedSearch ? (
+ <XDSButton
+ label="Explore"
+ variant="primary"
+ onClick={() => setActiveView('explore')}
+ />
+ ) : undefined
+ }
+ />
+ </div>
+ ) : (
+ <XDSTable
+ data={filteredUsed as Array<(typeof filteredUsed)[number] & Record<string, unknown>>}
+ columns={usedColumns}
+ idKey="name"
+ hasHover
+ plugins={{sort: usedSortPlugin}}
+ />
+ )}
+ </>
)}
- {activeNav === 'Settings' && (
- <div style={{maxWidth: 700, margin: '0 auto', display: 'flex', flexDirection: 'column' as const, gap: 24}}>
- <XDSHeading level={2}>Settings</XDSHeading>
- <div>
- <XDSHeading level={3} style={{marginBottom: 16}}>Theme preference</XDSHeading>
- {(['official', 'community'] as const).map(category => {
- const entries = THEME_PICKER_ENTRIES.filter(e => e.category === category);
- if (entries.length === 0) return null;
- return (
- <div key={category} style={{marginBottom: 20}}>
- <div style={{marginBottom: 8}}><XDSText type="supporting" color="secondary">{category.charAt(0).toUpperCase() + category.slice(1)}</XDSText></div>
- <div style={{display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 12}}>
- {entries.map(entry => {
- const isSelected = selectedTheme === entry.key;
- const p = entry.preview;
- return (
- <div key={entry.key} onClick={() => setSelectedTheme(entry.key)} style={{borderRadius: 12, overflow: 'hidden', cursor: 'pointer', border: isSelected ? '2px solid var(--color-accent, #0066FF)' : '1px solid var(--color-border-emphasized, #e0e0e0)', transition: 'border-color 0.15s ease'}}>
- <div style={{height: 80, backgroundColor: p.bg, display: 'flex', flexDirection: 'column' as const, overflow: 'hidden'}}>
- <div style={{height: 14, backgroundColor: p.surface, borderBottom: `1px solid ${p.text}1A`, display: 'flex', alignItems: 'center', paddingInline: 8, gap: 4}}>
- <div style={{width: 5, height: 5, borderRadius: '50%', backgroundColor: p.accent}} />
- <div style={{width: 16, height: 2, borderRadius: 1, backgroundColor: p.text, opacity: 0.3}} />
+ {/* ===== BOOKMARKS TAB ===== */}
+ {activeTab === 'Bookmarks' && (
+ <>
+ {selectedCollection ? (
+ <>
+ {/* Collection detail view */}
+ <div style={{marginTop: 32, marginBottom: 32}}>
+ <XDSHStack gap={2} vAlign="center" style={{marginBottom: 4}}>
+ <XDSButton
+ label="Back to bookmarks"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<ArrowLeftIcon style={{width: 18, height: 18}} />}
+ onClick={() => {
+ setSelectedCollection(null);
+ setIsNewCollection(false);
+ setEditingCollectionName(false);
+ setEditingCollectionItems(false);
+ }}
+ />
+ <div
+ style={{
+ width: 32,
+ height: 32,
+ borderRadius: 8,
+ backgroundColor: 'var(--color-background-muted, #f0f0f0)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ }}>
+ <FolderIcon
+ style={{
+ width: 16,
+ height: 16,
+ color: 'var(--color-text-secondary, #6b7280)',
+ }}
+ />
+ </div>
+ <XDSVStack gap={0}>
+ {editingCollectionName ? (
+ <input
+ autoFocus
+ value={collectionNameDraft}
+ onChange={e => setCollectionNameDraft(e.target.value)}
+ onBlur={() => setEditingCollectionName(false)}
+ onKeyDown={e => {
+ if (e.key === 'Enter' || e.key === 'Escape') {
+ setEditingCollectionName(false);
+ }
+ }}
+ style={{
+ font: 'inherit',
+ fontSize: 20,
+ fontWeight: 600,
+ border: 'none',
+ outline: 'none',
+ padding: '2px 0',
+ background: 'transparent',
+ borderBottom: '2px solid var(--color-accent, #0066FF)',
+ width: Math.max(120, collectionNameDraft.length * 11),
+ }}
+ />
+ ) : (
+ <div
+ role="button"
+ tabIndex={0}
+ style={{cursor: 'pointer'}}
+ onClick={() => {
+ setCollectionNameDraft(selectedCollection.name);
+ setEditingCollectionName(true);
+ }}
+ onKeyDown={e => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ setCollectionNameDraft(selectedCollection.name);
+ setEditingCollectionName(true);
+ }
+ }}>
+ <XDSHeading level={3}>
+ {selectedCollection.name}
+ </XDSHeading>
+ </div>
+ )}
+ <XDSText type="supporting" color="secondary">
+ {collectionItems.length}{' '}
+ {collectionItems.length === 1 ? 'item' : 'items'}
+ </XDSText>
+ </XDSVStack>
+ <XDSStackItem size="fill" />
+ {editingCollectionItems ? (
+ <XDSHStack gap={2}>
+ <XDSButton
+ label="Cancel"
+ variant="ghost"
+ size="sm"
+ onClick={() => setEditingCollectionItems(false)}
+ />
+ <XDSButton
+ label="Save"
+ variant="primary"
+ size="sm"
+ onClick={() => setEditingCollectionItems(false)}
+ />
+ </XDSHStack>
+ ) : (
+ <XDSButton
+ label="Add item"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<PlusIcon style={{width: 20, height: 20}} />}
+ onClick={() => {
+ setCollectionItemsDraft(new Set(selectedCollection.items));
+ setEditingCollectionItems(true);
+ }}
+ />
+ )}
+ </XDSHStack>
+ </div>
+
+ {editingCollectionItems ? (
+ <div
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'repeat(3, 1fr)',
+ gap: 16,
+ }}>
+ {PROFILE_LIKED_ITEMS.filter(
+ item => !removedBookmarks.has(item.name),
+ ).map((item, i) => {
+ const isInCollection = collectionItemsDraft.has(item.name);
+ return (
+ <div
+ key={item.name}
+ onClick={() => {
+ setCollectionItemsDraft(prev => {
+ const next = new Set(prev);
+ if (next.has(item.name)) next.delete(item.name);
+ else next.add(item.name);
+ return next;
+ });
+ }}
+ style={{
+ animation: `craftCardFadeIn 400ms ${i * 60}ms cubic-bezier(0.16, 1, 0.3, 1) both`,
+ cursor: 'pointer',
+ }}>
+ <XDSCard padding={0}>
+ <div style={{position: 'relative', overflow: 'hidden'}}>
+ <img
+ src={item.img}
+ alt={item.name}
+ style={{
+ display: 'block',
+ width: '100%',
+ aspectRatio: '1920 / 1205',
+ objectFit: 'cover',
+ objectPosition: 'top',
+ opacity: isInCollection ? 1 : 0.5,
+ transition: 'opacity 200ms ease',
+ }}
+ />
+ <div
+ style={{
+ position: 'absolute',
+ top: 12,
+ left: 12,
+ }}>
+ <XDSCheckboxInput
+ label={item.name}
+ isLabelHidden
+ value={isInCollection}
+ onChange={() => {
+ setCollectionItemsDraft(prev => {
+ const next = new Set(prev);
+ if (next.has(item.name)) next.delete(item.name);
+ else next.add(item.name);
+ return next;
+ });
+ }}
+ />
</div>
- <div style={{flex: 1, padding: 8, display: 'flex', flexDirection: 'column' as const, gap: 5}}>
- <div style={{width: '65%', height: 4, borderRadius: 2, backgroundColor: p.text, opacity: 0.6}} />
- <div style={{width: '45%', height: 3, borderRadius: 1.5, backgroundColor: p.text, opacity: 0.25}} />
- <div style={{width: 28, height: 10, borderRadius: 4, backgroundColor: p.accent, marginTop: 'auto'}} />
+ <div
+ style={{
+ position: 'absolute',
+ bottom: 0,
+ left: 0,
+ right: 0,
+ padding: '24px 12px 12px',
+ background: 'linear-gradient(to top, rgba(0,0,0,0.6), transparent)',
+ }}>
+ <div style={{display: 'flex', flexDirection: 'column', gap: 8}}>
+ <XDSText type="body" style={{color: '#fff', fontWeight: 600}}>
+ {item.name}
+ </XDSText>
+ <XDSText type="supporting" style={{color: 'rgba(255,255,255,0.7)'}}>
+ {item.type}
+ </XDSText>
+ </div>
</div>
</div>
- <div style={{padding: '8px 10px'}}>
- <XDSText type="supporting" style={{fontWeight: isSelected ? 600 : 400}}>{entry.name}</XDSText>
- {entry.description && <div style={{marginTop: 2}}><XDSText type="supporting" color="secondary">{entry.description}</XDSText></div>}
+ </XDSCard>
+ </div>
+ );
+ })}
+ </div>
+ ) : collectionItems.length === 0 ? (
+ <div style={{marginTop: 48}}>
+ <XDSEmptyState
+ title="This collection is empty"
+ description="Bookmark items and add them to this collection."
+ actions={
+ <XDSButton
+ label="Add items"
+ variant="primary"
+ onClick={() => {
+ setCollectionItemsDraft(new Set(selectedCollection.items));
+ setEditingCollectionItems(true);
+ }}
+ />
+ }
+ />
+ </div>
+ ) : (
+ <div
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'repeat(3, 1fr)',
+ gap: 16,
+ }}>
+ {collectionItems.map((item, i) => (
+ <BookmarkCard
+ key={item.name}
+ item={item}
+ index={i}
+ onClick={() => handleBookmarkClick(item)}
+ onRemove={() =>
+ setRemovedBookmarks(prev => {
+ const next = new Set(prev);
+ next.add(item.name);
+ return next;
+ })
+ }
+ />
+ ))}
+ </div>
+ )}
+ </>
+ ) : (
+ <>
+ {/* Collections */}
+ <div style={{marginTop: 32, marginBottom: 32}}>
+ <XDSHStack vAlign="center" style={{marginBottom: 12}}>
+ <XDSHeading level={2}>
+ Collections
+ </XDSHeading>
+ <XDSStackItem size="fill" />
+ <XDSButton
+ label="Add collection"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<PlusIcon style={{width: 20, height: 20}} />}
+ onClick={() => {
+ setIsNewCollection(true);
+ setCollectionNameDraft('Untitled');
+ setEditingCollectionName(true);
+ setEditingCollectionItems(false);
+ setCollectionItemsDraft(new Set());
+ }}
+ />
+ </XDSHStack>
+ <XDSGrid minChildWidth={180} gap={3}>
+ {PROFILE_COLLECTIONS.map((col, i) => (
+ <div
+ key={col.name}
+ onClick={() => setSelectedCollection(col)}
+ style={{
+ cursor: 'pointer',
+ animation: `craftCardFadeIn 300ms ${i * 50}ms cubic-bezier(0.16, 1, 0.3, 1) both`,
+ }}>
+ <XDSCard padding={3}>
+ <XDSHStack gap={3} vAlign="center">
+ <div
+ style={{
+ width: 36,
+ height: 36,
+ borderRadius: 10,
+ backgroundColor: 'var(--color-background-muted, #f0f0f0)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ }}>
+ <FolderIcon
+ style={{
+ width: 18,
+ height: 18,
+ color: 'var(--color-text-secondary, #6b7280)',
+ }}
+ />
</div>
- </div>
- );
- })}
- </div>
+ <XDSVStack gap={0}>
+ <XDSText
+ type="body"
+ style={{fontWeight: 600}}>
+ {col.name}
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ {col.count}{' '}
+ {col.count === 1 ? 'item' : 'items'}
+ </XDSText>
+ </XDSVStack>
+ </XDSHStack>
+ </XDSCard>
+ </div>
+ ))}
+ </XDSGrid>
+ </div>
+
+ {/* Bookmark items */}
+ <XDSHStack vAlign="center" style={{marginBottom: 16}}>
+ <XDSHeading level={2}>
+ All bookmarks
+ </XDSHeading>
+ <XDSStackItem size="fill" />
+ <div style={{width: 280}}>
+ <XDSTextInput
+ label="Search bookmarks"
+ isLabelHidden
+ placeholder="Search bookmarks..."
+ value={bookmarkSearch}
+ onChange={setBookmarkSearch}
+ size="md"
+ startIcon={SearchIcon}
+ />
+ </div>
+ </XDSHStack>
+
+ {filteredBookmarks.length === 0 ? (
+ <div style={{marginTop: 32}}>
+ <XDSEmptyState
+ title={
+ bookmarkSearch
+ ? 'No bookmarks match'
+ : 'No bookmarks yet'
+ }
+ description={
+ bookmarkSearch
+ ? 'Try a different search term.'
+ : 'Bookmark templates, themes, and components to save them for later.'
+ }
+ actions={
+ !bookmarkSearch ? (
+ <XDSButton
+ label="Explore"
+ variant="primary"
+ onClick={() => setActiveView('explore')}
+ />
+ ) : undefined
+ }
+ />
</div>
- );
- })}
+ ) : (
+ <div
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'repeat(3, 1fr)',
+ gap: 16,
+ }}>
+ {filteredBookmarks.map((item, i) => (
+ <BookmarkCard
+ key={item.name}
+ item={item}
+ index={i}
+ onClick={() => handleBookmarkClick(item)}
+ onRemove={() =>
+ setRemovedBookmarks(prev => {
+ const next = new Set(prev);
+ next.add(item.name);
+ return next;
+ })
+ }
+ />
+ ))}
+ </div>
+ )}
+ </>
+ )}
+ </>
+ )}
+ </div>
+ </div>
+
+ {/* Craft preview dialog */}
+ <PreviewDialogShell
+ isOpen={previewItem !== null}
+ onClose={() => setPreviewItem(null)}
+ imgSrc={previewItem?.img ?? ''}
+ imgAlt={previewItem?.name ?? ''}>
+ {previewItem && (
+ <>
+ <XDSText type="display-2">{previewItem.name}</XDSText>
+
+ <div style={{marginTop: 8}}>
+ <XDSText type="body" color="secondary">
+ {previewItem.description}
+ </XDSText>
+ </div>
+
+ <XDSHStack gap={2} vAlign="center" style={{marginTop: 16}}>
+ <XDSBadge
+ label={previewItem.status}
+ variant={STATUS_VARIANT[previewItem.status]}
+ />
+ <XDSText type="supporting" color="secondary">
+ {previewItem.type} · Updated {timeAgo(previewItem.lastUpdated)}
+ </XDSText>
+ </XDSHStack>
+
+ {(previewItem.status === 'In Review' || previewItem.status === 'Needs Fixes') && (
+ <div style={{marginTop: 16}}>
+ <XDSBanner
+ status={previewItem.status === 'Needs Fixes' ? 'warning' : 'info'}
+ title={previewItem.status === 'Needs Fixes' ? 'Changes requested' : 'In review'}
+ description={
+ <>
+ {previewItem.status === 'Needs Fixes'
+ ? 'Reviewers have left comments on your craft. Open the diffs tool to resolve them.'
+ : 'Your craft is being reviewed by the XDS team. This usually takes 2–3 business days.'}{' '}
+ <XDSText type="supporting">
+ <XDSLink
+ label="Learn more"
+ href="#"
+ color="secondary"
+ hasUnderline
+ onClick={(e) => {
+ e.preventDefault();
+ setPreviewItem(null);
+ setActiveView('docs');
+ }}>
+ Learn more
+ </XDSLink>
+ </XDSText>
+ </>
+ }
+ />
</div>
- <div>
- <XDSHeading level={3} style={{marginBottom: 16}}>Send to</XDSHeading>
- <XDSText type="supporting" color="secondary" display="block" style={{marginBottom: 12}}>Choose where templates and code are sent when you use them.</XDSText>
- <div style={{display: 'flex', flexDirection: 'column' as const, gap: 0}}>
- {([
- {key: 'clipboard', label: 'Clipboard', description: 'Copy code to your clipboard'},
- {key: 'vscode', label: 'VS Code', description: 'Open directly in VS Code'},
- {key: 'github', label: 'GitHub', description: 'Create a new repo or gist'},
- {key: 'download', label: 'Download', description: 'Save as a file to your device'},
- ] as const).map((option, i, arr) => (
- <React.Fragment key={option.key}>
- <div onClick={() => setSendTo(option.key)} style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '14px 0', cursor: 'pointer'}}>
- <div>
- <XDSText type="body" weight={sendTo === option.key ? 'semibold' : 'normal'} display="block">{option.label}</XDSText>
- <XDSText type="supporting" color="secondary" display="block">{option.description}</XDSText>
- </div>
- <div style={{width: 20, height: 20, borderRadius: '50%', border: sendTo === option.key ? '6px solid var(--color-accent, #0066FF)' : '2px solid var(--color-border-emphasized, #ccc)', transition: 'border 0.15s ease', flexShrink: 0}} />
+ )}
+
+ {previewItem.status === 'Published' && (
+ <div style={{marginTop: 12}}>
+ <XDSList hasDividers density="balanced">
+ <XDSListItem
+ label="Views"
+ startContent={<EyeIcon style={{width: 18, height: 18, color: 'var(--color-secondary)'}} />}
+ endContent={<XDSText type="label">{previewItem.views.toLocaleString()}</XDSText>}
+ />
+ <XDSListItem
+ label="Uses"
+ startContent={<CursorArrowRaysIcon style={{width: 18, height: 18, color: 'var(--color-secondary)'}} />}
+ endContent={<XDSText type="label">{previewItem.used.toLocaleString()}</XDSText>}
+ />
+ <XDSListItem
+ label="Bookmarked"
+ startContent={<BookmarkIcon style={{width: 18, height: 18, color: 'var(--color-secondary)'}} />}
+ endContent={<XDSText type="label">{previewItem.bookmarks.toLocaleString()}</XDSText>}
+ />
+ </XDSList>
+ </div>
+ )}
+
+ <XDSVStack gap={2} style={{marginTop: 'auto', paddingTop: 32}}>
+ {(previewItem.status === 'In Review' || previewItem.status === 'Needs Fixes') ? (
+ <XDSButton
+ variant="secondary"
+ label="Edit"
+ size="lg"
+ style={{width: '100%'}}
+ onClick={() => setPreviewItem(null)}
+ />
+ ) : (
+ <>
+ <XDSButton
+ variant={previewItem.status === 'Published' ? 'primary' : 'secondary'}
+ label="Edit"
+ size="lg"
+ style={{width: '100%'}}
+ onClick={() => setPreviewItem(null)}
+ />
+ <XDSButton
+ variant={previewItem.status === 'Published' ? 'secondary' : 'primary'}
+ label={previewItem.status === 'Published' ? 'Unpublish' : 'Submit for review'}
+ size="lg"
+ style={{width: '100%'}}
+ onClick={() => setPreviewItem(null)}
+ />
+ </>
+ )}
+ </XDSVStack>
+
+ </>
+ )}
+ </PreviewDialogShell>
+
+ {/* Used item preview dialog */}
+ <PreviewDialogShell
+ isOpen={previewUsedItem !== null}
+ onClose={() => setPreviewUsedItem(null)}
+ imgSrc={previewUsedItem?.img ?? ''}
+ imgAlt={previewUsedItem?.name ?? ''}>
+ {previewUsedItem && (
+ <>
+ <XDSText type="display-2">{previewUsedItem.name}</XDSText>
+
+ <div style={{marginTop: 8}}>
+ <XDSText type="body" color="secondary">
+ {previewUsedItem.description}
+ </XDSText>
+ </div>
+
+ <XDSHStack gap={2} vAlign="center" style={{marginTop: 16}}>
+ <XDSBadge
+ label={previewUsedItem.type}
+ variant={TYPE_VARIANT[previewUsedItem.type]}
+ />
+ </XDSHStack>
+
+ <div style={{marginTop: 12}}>
+ <XDSList hasDividers density="balanced">
+ <XDSListItem
+ label="Times used"
+ startContent={<CursorArrowRaysIcon style={{width: 18, height: 18, color: 'var(--color-secondary)'}} />}
+ endContent={<XDSText type="label">{previewUsedItem.usageCount}</XDSText>}
+ />
+ <XDSListItem
+ label="Last used"
+ startContent={<ClockIcon style={{width: 18, height: 18, color: 'var(--color-secondary)'}} />}
+ endContent={<XDSText type="label">{timeAgo(previewUsedItem.lastUsed)}</XDSText>}
+ />
+ </XDSList>
+ </div>
+
+ <XDSVStack gap={2} style={{marginTop: 'auto', paddingTop: 32}}>
+ <XDSButton
+ variant="primary"
+ label="Use again"
+ size="lg"
+ style={{width: '100%'}}
+ onClick={() => setPreviewUsedItem(null)}
+ />
+ <XDSButton
+ variant="secondary"
+ label="Start crafting"
+ size="lg"
+ style={{width: '100%'}}
+ onClick={() => setPreviewUsedItem(null)}
+ />
+ </XDSVStack>
+ </>
+ )}
+ </PreviewDialogShell>
+
+ {/* Component docs drawer */}
+ <XDSDialog
+ isOpen={componentDrawerKey !== null}
+ onOpenChange={(open) => { if (!open) setComponentDrawerKey(null); }}
+ width="90vw"
+ maxHeight="90vh"
+ purpose="info"
+ style={{padding: 0, overflow: 'visible', maxWidth: 1200, '--xds-dialog-padding': '0px'} as React.CSSProperties}>
+ {componentDrawerKey && (() => {
+ const docs = getComponentDocs(componentDrawerKey);
+ const name = getComponentName(componentDrawerKey);
+ return (
+ <>
+ <div style={{position: 'absolute', top: 0, right: -40, zIndex: 1}}>
+ <XDSCard padding={0} style={{borderRadius: '50%'}}>
+ <XDSButton
+ label="Close"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<span style={{fontSize: 16, lineHeight: 1}}>✕</span>}
+ onClick={() => setComponentDrawerKey(null)}
+ />
+ </XDSCard>
+ </div>
+ <div style={{overflowY: 'auto', maxHeight: '85vh'}}>
+ <div style={{maxWidth: 840, margin: '0 auto', padding: '32px 40px'}}>
+ <XDSText type="display-1">{name}</XDSText>
+ <div style={{marginTop: 4, marginBottom: 32}}>
+ <XDSText type="supporting" color="secondary">
+ Component
+ </XDSText>
+ </div>
+
+ {/* Live preview */}
+ <div
+ style={{
+ border: '1px solid var(--color-divider, rgba(0,0,0,0.1))',
+ borderRadius: 12,
+ overflow: 'hidden',
+ marginBottom: 48,
+ }}>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ padding: '8px 12px',
+ borderBottom: '1px solid var(--color-divider, rgba(0,0,0,0.08))',
+ backgroundColor: 'var(--color-background-surface, #ffffff)',
+ }}>
+ <XDSText type="supporting" weight="semibold" color="secondary">
+ Live preview
+ </XDSText>
+ <XDSButton
+ label="Open full docs"
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ setComponentDrawerKey(null);
+ setActiveView('docs');
+ }}
+ />
+ </div>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ minHeight: 240,
+ padding: 24,
+ backgroundColor: 'var(--color-background-muted, #f5f5f5)',
+ }}>
+ {COMPONENT_PREVIEWS[componentDrawerKey] ?? (
+ <XDSText type="supporting" color="secondary">
+ Preview coming soon
+ </XDSText>
+ )}
+ </div>
+ </div>
+
+ {/* Description */}
+ <div style={{marginBottom: 48}}>
+ <XDSHeading level={3}>{docs.tagline}</XDSHeading>
+ <div style={{marginTop: 12}}>
+ <XDSText type="body">{docs.description}</XDSText>
+ </div>
+ <div style={{marginTop: 24}}>
+ <XDSHeading level={4}>When to use</XDSHeading>
+ <div style={{marginTop: 8}}>
+ <XDSList density="compact" listStyle="disc">
+ {docs.whenToUse.map((item, i) => (
+ <XDSListItem key={i} label={item} />
+ ))}
+ </XDSList>
</div>
- {i < arr.length - 1 && <XDSDivider />}
- </React.Fragment>
- ))}
+ </div>
+ <div style={{marginTop: 24}}>
+ <XDSHeading level={4}>When NOT to use</XDSHeading>
+ <div style={{marginTop: 8}}>
+ <XDSList density="compact" listStyle="disc">
+ {docs.whenNotToUse.map((item, i) => (
+ <XDSListItem key={i} label={item} />
+ ))}
+ </XDSList>
+ </div>
+ </div>
+ </div>
+
+ {/* Anatomy */}
+ <div style={{marginBottom: 48}}>
+ <XDSHeading level={2}>Anatomy</XDSHeading>
+ <div style={{marginTop: 16}}>
+ <XDSText type="body">
+ The {name} is composed of the following elements.
+ Required elements must always be present, while optional
+ elements can be included as needed.
+ </XDSText>
+ </div>
+ <div style={{marginTop: 16}}>
+ <XDSTable
+ data={docs.anatomy as {[key: string]: unknown}[]}
+ columns={[
+ {key: 'element', header: 'Element'},
+ {key: 'required', header: 'Required'},
+ {key: 'description', header: 'Description'},
+ ]}
+ />
+ </div>
+ </div>
</div>
</div>
+ </>
+ );
+ })()}
+ </XDSDialog>
+
+ {/* Bookmark preview dialog — reuses the exact same modal as the home page */}
+ <TemplatePreviewModal
+ isOpen={previewBookmarkItem !== null}
+ onClose={() => setPreviewBookmarkItem(null)}
+ item={previewBookmarkItem ? {
+ name: previewBookmarkItem.name,
+ img: previewBookmarkItem.img,
+ author: previewBookmarkItem.author,
+ description: previewBookmarkItem.description,
+ } : null}
+ onStartCrafting={() => {
+ setPreviewBookmarkItem(null);
+ onStartCrafting();
+ }}
+ isBookmarked={true}
+ onBookmarkToggle={() => {
+ if (previewBookmarkItem) {
+ setRemovedBookmarks(prev => {
+ const next = new Set(prev);
+ next.add(previewBookmarkItem.name);
+ return next;
+ });
+ setPreviewBookmarkItem(null);
+ }
+ }}
+ moreLikeThis={
+ previewBookmarkItem
+ ? PROFILE_LIKED_ITEMS
+ .filter(i => i.name !== previewBookmarkItem.name && !removedBookmarks.has(i.name))
+ .slice(0, 4)
+ .map(i => ({name: i.name, img: i.img, key: i.name}))
+ : []
+ }
+ onMoreLikeThisClick={(mlItem) => {
+ const found = PROFILE_LIKED_ITEMS.find(i => i.name === mlItem.name);
+ if (found) setPreviewBookmarkItem(found);
+ }}
+ exploreTags={['website', 'dashboard', 'admin panel', 'settings', 'form layout', 'data table', 'sidebar nav', 'landing page', 'e-commerce', 'documentation', 'profile page']}
+ componentTags={['XDSAppShell', 'XDSTopNav', 'XDSVStack', 'XDSHStack', 'XDSHeading', 'XDSText', 'XDSButton', 'XDSCard', 'XDSBadge', 'XDSAvatar']}
+ />
+
+ {/* Settings dialog */}
+ <XDSDialog isOpen={isSettingsOpen} onOpenChange={setIsSettingsOpen} width={720}>
+ <XDSDialogHeader
+ title="Settings"
+ onOpenChange={setIsSettingsOpen}
+ />
+ <div
+ style={{
+ padding: 24,
+ maxHeight: '70vh',
+ overflowY: 'auto' as const,
+ }}>
+ <XDSVStack gap={6}>
+ <XDSRadioList
+ label="Send to"
+ value={sendTo}
+ onChange={setSendTo}
+ description="Choose where templates and code are sent when you use them.">
+ <XDSRadioListItem
+ value="clipboard"
+ label="Clipboard"
+ description="Copy code to your clipboard"
+ />
+ <XDSRadioListItem
+ value="vscode"
+ label="VS Code"
+ description="Open directly in VS Code"
+ />
+ <XDSRadioListItem
+ value="github"
+ label="GitHub"
+ description="Create a new repo or gist"
+ />
+ <XDSRadioListItem
+ value="download"
+ label="Download"
+ description="Save as a file to your device"
+ />
+ </XDSRadioList>
+ <div>
+ <XDSHeading level={3} style={{marginBottom: 16}}>
+ Theme preference
+ </XDSHeading>
+ {(['official', 'community'] as const).map(category => {
+ const entries = THEME_PICKER_ENTRIES.filter(
+ e => e.category === category,
+ );
+ if (entries.length === 0) return null;
+ return (
+ <div key={category} style={{marginBottom: 20}}>
+ <div style={{marginBottom: 8}}>
+ <XDSText type="supporting" color="secondary">
+ {category.charAt(0).toUpperCase() +
+ category.slice(1)}
+ </XDSText>
+ </div>
+ <XDSGrid columns={4} gap={3}>
+ {entries.map(entry => {
+ const isSelected =
+ selectedTheme === entry.key;
+ const p = entry.preview;
+ return (
+ <div
+ key={entry.key}
+ onClick={() =>
+ setSelectedTheme(entry.key)
+ }
+ style={{
+ borderRadius: 12,
+ overflow: 'hidden',
+ cursor: 'pointer',
+ border: isSelected
+ ? '2px solid var(--color-accent, #0066FF)'
+ : '1px solid var(--color-border-emphasized, #e0e0e0)',
+ transition:
+ 'border-color 0.15s ease',
+ }}>
+ <XDSVStack>
+ <div
+ style={{
+ height: 80,
+ backgroundColor: p.bg,
+ display: 'flex',
+ flexDirection:
+ 'column' as const,
+ overflow: 'hidden',
+ }}>
+ <XDSHStack
+ gap={1}
+ vAlign="center"
+ style={{
+ height: 14,
+ backgroundColor: p.surface,
+ borderBottom: `1px solid ${p.text}1A`,
+ paddingInline: 8,
+ }}>
+ <div
+ style={{
+ width: 5,
+ height: 5,
+ borderRadius: '50%',
+ backgroundColor: p.accent,
+ }}
+ />
+ <div
+ style={{
+ width: 16,
+ height: 2,
+ borderRadius: 1,
+ backgroundColor: p.text,
+ opacity: 0.3,
+ }}
+ />
+ </XDSHStack>
+ <XDSVStack
+ gap={1}
+ style={{
+ flex: 1,
+ padding: 8,
+ }}>
+ <div
+ style={{
+ width: '65%',
+ height: 4,
+ borderRadius: 2,
+ backgroundColor: p.text,
+ opacity: 0.6,
+ }}
+ />
+ <div
+ style={{
+ width: '45%',
+ height: 3,
+ borderRadius: 1.5,
+ backgroundColor: p.text,
+ opacity: 0.25,
+ }}
+ />
+ <div
+ style={{
+ width: 28,
+ height: 10,
+ borderRadius: 4,
+ backgroundColor: p.accent,
+ marginTop: 'auto',
+ }}
+ />
+ </XDSVStack>
+ </div>
+ <div
+ style={{
+ padding: '8px 10px',
+ }}>
+ <XDSText
+ type="supporting"
+ style={{
+ fontWeight: isSelected
+ ? 600
+ : 400,
+ }}>
+ {entry.name}
+ </XDSText>
+ {entry.description && (
+ <div
+ style={{
+ marginTop: 2,
+ }}>
+ <XDSText
+ type="supporting"
+ color="secondary">
+ {entry.description}
+ </XDSText>
+ </div>
+ )}
+ </div>
+ </XDSVStack>
+ </div>
+ );
+ })}
+ </XDSGrid>
+ </div>
+ );
+ })}
</div>
- )}
+ </XDSVStack>
</div>
- </div>
+ </XDSDialog>
</div>
);
}
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreview.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreview.tsx
index 9c7bb1bc8c..08a4e90a90 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreview.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreview.tsx
@@ -398,18 +398,33 @@ export function TemplatePreview({
margin: isFullPreview ? 0 : 'auto 0',
transition: 'width 300ms ease, border-radius 300ms ease',
}}>
- <img
- src={imageSrc}
- alt="Template preview"
- style={{
- display: 'block',
- width: '100%',
- aspectRatio: undefined,
- objectFit: undefined,
- opacity: isGenerating ? 0 : 1,
- transition: 'opacity 600ms ease',
- }}
- />
+ {imageSrc ? (
+ <img
+ src={imageSrc}
+ alt="Template preview"
+ style={{
+ display: 'block',
+ width: '100%',
+ aspectRatio: undefined,
+ objectFit: undefined,
+ opacity: isGenerating ? 0 : 1,
+ transition: 'opacity 600ms ease',
+ }}
+ />
+ ) : (
+ <div
+ style={{
+ width: '100%',
+ aspectRatio: '1920 / 1205',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ backgroundColor: '#fff',
+ opacity: isGenerating ? 0 : 1,
+ transition: 'opacity 600ms ease',
+ }}
+ />
+ )}
{showCanvas && (
<div
style={{
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreviewModal.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreviewModal.tsx
new file mode 100644
index 0000000000..07e854c5af
--- /dev/null
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/TemplatePreviewModal.tsx
@@ -0,0 +1,730 @@
+'use client';
+
+import React, {useState, useRef, useCallback} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {XDSAvatar} from '@xds/core/Avatar';
+import {XDSButton} from '@xds/core/Button';
+import {XDSCard} from '@xds/core/Card';
+import {XDSDialog} from '@xds/core/Dialog';
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSPopover} from '@xds/core/Popover';
+import {XDSTextInput} from '@xds/core/TextInput';
+import {XDSToken} from '@xds/core/Token';
+import {XDSTooltip} from '@xds/core/Tooltip';
+import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {
+ AVATAR_IMAGE,
+ XDS_DESIGN_AVATAR,
+ THEME_PICKER_ENTRIES,
+} from './constants';
+import {SharePopoverContent} from './SharePopover';
+import {
+ BookmarkIcon,
+ BookmarkFilledIcon,
+ StarIcon,
+ StarFilledIcon,
+ SearchIcon,
+ MetaLogo,
+ WhatsAppLogo,
+ ThreadsLogo,
+ FacebookLogo,
+ DefaultThemeIcon,
+ ForestThemeIcon,
+ SunsetThemeIcon,
+ MidnightThemeIcon,
+} from './docsite-icons';
+
+const BRAND_LOGOS: Record<
+ string,
+ React.ComponentType<React.SVGProps<SVGSVGElement>>
+> = {
+ default: DefaultThemeIcon,
+ meta: MetaLogo,
+ whatsapp: WhatsAppLogo,
+ threads: ThreadsLogo,
+ facebook: FacebookLogo,
+ forest: ForestThemeIcon,
+ sunset: SunsetThemeIcon,
+ midnight: MidnightThemeIcon,
+};
+
+const popoverStyles = stylex.create({
+ themeBrowse: {
+ zIndex: 100,
+ },
+});
+
+const tokenStyles = stylex.create({
+ outline: {
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized)',
+ },
+ pill: {
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized)',
+ borderRadius: 9999,
+ },
+});
+
+export type TemplatePreviewItem = {
+ name: string;
+ img: string;
+ author: string;
+ description?: string;
+};
+
+export type MoreLikeThisItem = {
+ name: string;
+ img: string;
+ key: string | number;
+};
+
+export function TemplatePreviewModal({
+ isOpen,
+ onClose,
+ item,
+ onStartCrafting,
+ isBookmarked,
+ onBookmarkToggle,
+ moreLikeThis,
+ onMoreLikeThisClick,
+ exploreTags,
+ onExploreTagClick,
+ componentTags,
+ onComponentTagClick,
+}: {
+ isOpen: boolean;
+ onClose: () => void;
+ item: TemplatePreviewItem | null;
+ onStartCrafting?: () => void;
+ isBookmarked?: boolean;
+ onBookmarkToggle?: () => void;
+ moreLikeThis?: MoreLikeThisItem[];
+ onMoreLikeThisClick?: (item: MoreLikeThisItem) => void;
+ exploreTags?: string[];
+ onExploreTagClick?: (tag: string) => void;
+ componentTags?: string[];
+ onComponentTagClick?: (tag: string) => void;
+}) {
+ const scrollRef = useRef<HTMLDivElement>(null);
+ const [selectedTheme, setSelectedTheme] = useState('default');
+ const [themeBrowseOpen, setThemeBrowseOpen] = useState(false);
+ const [themeSearch, setThemeSearch] = useState('');
+ const [showAddPopover, setShowAddPopover] = useState(false);
+ const [pinnedThemes, setPinnedThemes] = useState(
+ () =>
+ new Set(
+ THEME_PICKER_ENTRIES.filter(t => t.isPinnedByDefault).map(t => t.key),
+ ),
+ );
+ const [transitioning, setTransitioning] = useState(false);
+
+ const togglePin = useCallback((key: string) => {
+ setPinnedThemes(prev => {
+ const next = new Set(prev);
+ if (next.has(key)) next.delete(key);
+ else next.add(key);
+ return next;
+ });
+ }, []);
+
+ if (!item) return null;
+
+ const description =
+ item.description ??
+ `A ready-to-use ${item.name.toLowerCase()} template built with XDS components. Customize it with your own content and theme to match your brand.`;
+
+ return (
+ <XDSDialog
+ isOpen={isOpen}
+ onOpenChange={open => {
+ if (!open) onClose();
+ }}
+ width="90vw"
+ maxHeight="90vh"
+ purpose="info"
+ style={{
+ padding: 0,
+ overflow: 'visible',
+ maxWidth: 1600,
+ '--xds-dialog-padding': '0px',
+ } as React.CSSProperties}>
+ <div style={{position: 'absolute', top: 0, right: -40, zIndex: 1}}>
+ <XDSCard padding={0} style={{borderRadius: '50%'}}>
+ <XDSButton
+ label="Close"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<span style={{fontSize: 16, lineHeight: 1}}>✕</span>}
+ onClick={onClose}
+ />
+ </XDSCard>
+ </div>
+ <div ref={scrollRef} style={{overflowY: 'auto'}}>
+ <div style={{display: 'flex', minHeight: 0, padding: '0 32px'}}>
+ {/* Left — Preview image */}
+ <XDSVStack
+ gap={3}
+ style={{flex: 1, minWidth: 0, padding: '32px 32px 32px 0'}}>
+ <div
+ style={{
+ flex: 1,
+ aspectRatio: '16 / 10',
+ backgroundColor: 'var(--color-background-muted, #f9f9f9)',
+ borderRadius: 12,
+ overflowY: 'auto',
+ overflowX: 'hidden',
+ border: '1px solid var(--color-border, #e0e0e0)',
+ }}>
+ <img
+ src={item.img}
+ alt={item.name}
+ style={{
+ width: '100%',
+ display: 'block',
+ opacity: transitioning ? 0 : 1,
+ transition: 'opacity 250ms ease',
+ animation: transitioning
+ ? 'none'
+ : 'previewFadeIn 300ms ease',
+ }}
+ />
+ </div>
+ </XDSVStack>
+
+ {/* Right — Details panel */}
+ <XDSVStack style={{width: 360, flexShrink: 0, padding: '32px 0'}}>
+ <div
+ style={{
+ opacity: transitioning ? 0 : 1,
+ transition: 'opacity 250ms ease',
+ animation: transitioning
+ ? 'none'
+ : 'previewFadeIn 300ms ease',
+ }}>
+ <XDSText type="display-2">{item.name}</XDSText>
+
+ <div style={{marginTop: 8}}>
+ <XDSText type="body" color="secondary">
+ {description}
+ </XDSText>
+ </div>
+
+ {/* Author */}
+ <XDSHStack gap={3} vAlign="center" style={{marginTop: 16}}>
+ <XDSAvatar
+ name={item.author}
+ size={36}
+ src={
+ item.author === 'XDS Design'
+ ? XDS_DESIGN_AVATAR
+ : AVATAR_IMAGE
+ }
+ />
+ <XDSVStack gap={0}>
+ <XDSText type="supporting" color="secondary">
+ Crafted by
+ </XDSText>
+ <XDSText
+ type="body"
+ style={{fontWeight: 600, fontSize: 16}}>
+ {item.author}
+ </XDSText>
+ </XDSVStack>
+ </XDSHStack>
+ </div>
+
+ {/* CTA buttons */}
+ <XDSVStack
+ gap={2}
+ style={{marginTop: 32, position: 'relative'}}>
+ <XDSButton
+ variant="primary"
+ label="Start crafting"
+ size="lg"
+ style={{width: '100%'}}
+ onClick={() => {
+ onStartCrafting?.();
+ onClose();
+ }}
+ />
+ <div style={{display: 'flex', gap: 8, width: '100%'}}>
+ <XDSButton
+ variant="secondary"
+ label="Use in your product"
+ size="lg"
+ style={{flex: 1}}
+ onClick={() => setShowAddPopover(!showAddPopover)}
+ />
+ <XDSTooltip content="Bookmark">
+ <XDSButton
+ label={isBookmarked ? '893' : '892'}
+ variant="secondary"
+ size="lg"
+ isIconOnly
+ icon={
+ isBookmarked ? (
+ <BookmarkFilledIcon />
+ ) : (
+ <BookmarkIcon />
+ )
+ }
+ onClick={onBookmarkToggle}
+ />
+ </XDSTooltip>
+ </div>
+ {showAddPopover && (
+ <XDSCard
+ style={{
+ position: 'absolute',
+ top: '100%',
+ left: 0,
+ right: 0,
+ marginTop: 8,
+ zIndex: 10,
+ }}>
+ <SharePopoverContent
+ cliCommand={`npx xds template ${item.name.toLowerCase().replace(/\s+/g, '-')} ./my-project`}
+ onClose={() => setShowAddPopover(false)}
+ />
+ </XDSCard>
+ )}
+ </XDSVStack>
+
+ {/* Themes — pinned grid */}
+ <div style={{marginTop: 24}}>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ }}>
+ <XDSText type="body" style={{fontWeight: 600}}>
+ Apply your themes
+ </XDSText>
+ <XDSPopover
+ label="Browse themes"
+ placement="below"
+ alignment="end"
+ width={480}
+ isOpen={themeBrowseOpen}
+ onOpenChange={open => {
+ setThemeBrowseOpen(open);
+ if (!open) setThemeSearch('');
+ }}
+ xstyle={popoverStyles.themeBrowse}
+ content={
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 16,
+ }}>
+ <div
+ tabIndex={0}
+ style={{
+ position: 'absolute',
+ opacity: 0,
+ width: 0,
+ height: 0,
+ overflow: 'hidden',
+ }}
+ />
+ <XDSTextInput
+ label="Search"
+ isLabelHidden
+ placeholder="Search themes..."
+ value={themeSearch}
+ onChange={setThemeSearch}
+ size="lg"
+ startIcon={SearchIcon}
+ />
+ <div
+ style={{
+ maxHeight: 560,
+ overflowY: 'auto',
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 16,
+ }}>
+ {(['official', 'community'] as const).map(
+ category => {
+ const entries = THEME_PICKER_ENTRIES.filter(
+ e =>
+ e.category === category &&
+ e.name
+ .toLowerCase()
+ .includes(themeSearch.toLowerCase()),
+ );
+ if (entries.length === 0) return null;
+ return (
+ <div key={category}>
+ <div style={{marginBottom: 8}}>
+ <XDSText
+ type="supporting"
+ color="secondary">
+ {category.charAt(0).toUpperCase() +
+ category.slice(1)}
+ </XDSText>
+ </div>
+ <div
+ style={{
+ display: 'grid',
+ gridTemplateColumns: '1fr 1fr 1fr',
+ gap: 8,
+ }}>
+ {entries.map(entry => {
+ const isSelected =
+ selectedTheme === entry.key;
+ const isPinned = pinnedThemes.has(
+ entry.key,
+ );
+ const p = entry.preview;
+ return (
+ <div
+ key={entry.key}
+ style={{
+ borderRadius: 12,
+ overflow: 'hidden',
+ cursor: 'pointer',
+ border: isSelected
+ ? '1.5px solid var(--color-accent)'
+ : '1px solid var(--color-border-emphasized)',
+ transition:
+ 'border-color 0.15s ease',
+ }}>
+ <div
+ onClick={() => {
+ setSelectedTheme(entry.key);
+ setThemeBrowseOpen(false);
+ setThemeSearch('');
+ }}
+ style={{
+ height: 100,
+ backgroundColor: p.bg,
+ display: 'flex',
+ flexDirection: 'column',
+ overflow: 'hidden',
+ }}>
+ <div
+ style={{
+ height: 14,
+ backgroundColor: p.surface,
+ borderBottom: `1px solid ${p.text}1A`,
+ display: 'flex',
+ alignItems: 'center',
+ paddingInline: 8,
+ gap: 4,
+ }}>
+ <div
+ style={{
+ width: 5,
+ height: 5,
+ borderRadius: '50%',
+ backgroundColor: p.accent,
+ }}
+ />
+ <div
+ style={{
+ width: 16,
+ height: 2,
+ borderRadius: 1,
+ backgroundColor: p.text,
+ opacity: 0.3,
+ }}
+ />
+ </div>
+ <div
+ style={{
+ flex: 1,
+ padding: 8,
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 5,
+ }}>
+ <div
+ style={{
+ width: '65%',
+ height: 4,
+ borderRadius: 2,
+ backgroundColor: p.text,
+ opacity: 0.6,
+ }}
+ />
+ <div
+ style={{
+ width: '45%',
+ height: 3,
+ borderRadius: 1.5,
+ backgroundColor: p.text,
+ opacity: 0.25,
+ }}
+ />
+ <div
+ style={{
+ width: 28,
+ height: 10,
+ borderRadius: 4,
+ backgroundColor: p.accent,
+ marginTop: 'auto',
+ }}
+ />
+ </div>
+ </div>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ padding: '6px 8px',
+ backgroundColor:
+ 'var(--color-surface, #f5f5f5)',
+ }}>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: 6,
+ }}>
+ {(() => {
+ const Logo =
+ BRAND_LOGOS[entry.key];
+ return Logo ? (
+ <Logo
+ width={14}
+ height={14}
+ />
+ ) : (
+ <div
+ style={{
+ width: 14,
+ height: 14,
+ borderRadius: '50%',
+ backgroundColor:
+ entry.accent,
+ }}
+ />
+ );
+ })()}
+ <XDSText
+ type="supporting"
+ style={{
+ fontWeight: isSelected
+ ? 600
+ : 400,
+ }}>
+ {entry.name}
+ </XDSText>
+ </div>
+ <div
+ onClick={e => {
+ e.stopPropagation();
+ togglePin(entry.key);
+ }}
+ style={{
+ cursor: 'pointer',
+ display: 'flex',
+ padding: 2,
+ }}>
+ {isPinned ? (
+ <StarFilledIcon
+ width={14}
+ height={14}
+ style={{
+ color:
+ 'var(--color-text-primary, #111)',
+ }}
+ />
+ ) : (
+ <StarIcon
+ width={14}
+ height={14}
+ style={{
+ color:
+ 'var(--color-secondary, #999)',
+ }}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+ },
+ )}
+ </div>
+ </div>
+ }>
+ <XDSButton label="Browse" variant="ghost" size="sm" />
+ </XDSPopover>
+ </div>
+ <div
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'repeat(auto-fill, 44px)',
+ gap: 8,
+ marginTop: 16,
+ }}>
+ {THEME_PICKER_ENTRIES.filter(e => pinnedThemes.has(e.key)).map(
+ entry => {
+ const isSelected = selectedTheme === entry.key;
+ const BrandLogo = BRAND_LOGOS[entry.key];
+ return (
+ <XDSTooltip key={entry.key} content={entry.name}>
+ <div
+ onClick={() => setSelectedTheme(entry.key)}
+ style={{
+ width: 44,
+ height: 44,
+ borderRadius: 10,
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ cursor: 'pointer',
+ border: isSelected
+ ? '1.5px solid var(--color-accent)'
+ : '1px solid var(--color-border-emphasized)',
+ backgroundColor: '#fff',
+ transition: 'border-color 0.15s ease',
+ }}>
+ {BrandLogo ? (
+ <BrandLogo width={28} height={28} />
+ ) : (
+ <div
+ style={{
+ width: 24,
+ height: 24,
+ borderRadius: '50%',
+ backgroundColor: entry.accent,
+ }}
+ />
+ )}
+ </div>
+ </XDSTooltip>
+ );
+ },
+ )}
+ </div>
+ </div>
+ </XDSVStack>
+ </div>
+
+ {/* More like this */}
+ {moreLikeThis && moreLikeThis.length > 0 && (
+ <div style={{padding: '0 32px'}}>
+ <XDSHeading level={3}>More like this</XDSHeading>
+ <div
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'repeat(4, 1fr)',
+ gap: 12,
+ marginTop: 16,
+ }}>
+ {moreLikeThis.map(mlItem => (
+ <XDSCard
+ key={mlItem.key}
+ padding={0}
+ onClick={() => {
+ if (onMoreLikeThisClick) {
+ setTransitioning(true);
+ setTimeout(() => {
+ onMoreLikeThisClick(mlItem);
+ scrollRef.current?.scrollTo({top: 0});
+ setTimeout(() => setTransitioning(false), 50);
+ }, 250);
+ }
+ }}
+ style={{
+ cursor: 'pointer',
+ aspectRatio: '16/10',
+ overflow: 'hidden',
+ }}>
+ <img
+ src={mlItem.img}
+ alt={mlItem.name}
+ style={{
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ objectPosition: 'top',
+ display: 'block',
+ opacity: transitioning ? 0 : 1,
+ transition: 'opacity 250ms ease',
+ animation: transitioning
+ ? 'none'
+ : 'previewFadeIn 300ms ease',
+ }}
+ />
+ </XDSCard>
+ ))}
+ </div>
+ </div>
+ )}
+
+ {/* Explore more */}
+ {exploreTags && exploreTags.length > 0 && (
+ <div style={{padding: '32px 32px 0'}}>
+ <XDSHeading level={3}>Explore more</XDSHeading>
+ <div
+ style={{
+ display: 'flex',
+ flexWrap: 'wrap',
+ gap: 8,
+ marginTop: 16,
+ opacity: transitioning ? 0 : 1,
+ transition: 'opacity 250ms ease',
+ animation: transitioning
+ ? 'none'
+ : 'previewFadeIn 300ms ease',
+ }}>
+ {exploreTags.map(tag => (
+ <XDSToken
+ key={tag}
+ label={tag}
+ xstyle={tokenStyles.pill}
+ style={{backgroundColor: 'transparent', cursor: 'pointer'}}
+ onClick={() => onExploreTagClick?.(tag)}
+ />
+ ))}
+ </div>
+ </div>
+ )}
+
+ {/* Component used */}
+ {componentTags && componentTags.length > 0 && (
+ <div style={{padding: '32px 32px 32px'}}>
+ <XDSHeading level={3}>Component used</XDSHeading>
+ <div
+ style={{
+ display: 'flex',
+ flexWrap: 'wrap',
+ gap: 8,
+ marginTop: 16,
+ opacity: transitioning ? 0 : 1,
+ transition: 'opacity 250ms ease',
+ animation: transitioning
+ ? 'none'
+ : 'previewFadeIn 300ms ease',
+ }}>
+ {componentTags.map(c => (
+ <XDSToken
+ key={c}
+ label={c}
+ xstyle={tokenStyles.outline}
+ style={{backgroundColor: 'transparent', cursor: 'pointer'}}
+ onClick={() => onComponentTagClick?.(c)}
+ />
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ </XDSDialog>
+ );
+}
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/constants.ts b/apps/sandbox/src/app/(fullscreen)/pages/docsite/constants.ts
index e9663997ee..d1daa97d8a 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/constants.ts
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/constants.ts
@@ -226,61 +226,80 @@ export const FILTER_COLUMNS: {heading: string; items: string[]}[] = [
export const PROFILE_USED_ITEMS: {
name: string;
+ type: 'Template' | 'Theme' | 'Component';
description: string;
lastUsed: string;
usageCount: number;
+ img: string;
}[] = [
- {name: 'AppShell', description: 'Foundational page layout with header, sidebar, and content regions.', lastUsed: '2026-04-14T10:30:00Z', usageCount: 12},
- {name: 'Avatar', description: 'Represents a person or entity with an image, initials, or icon.', lastUsed: '2026-04-13T15:45:00Z', usageCount: 8},
- {name: 'Badge', description: 'Displays small counts or status labels on icons, buttons, or list items.', lastUsed: '2026-04-12T09:20:00Z', usageCount: 15},
- {name: 'Banner', description: 'Shows important, non-modal messages at the top of a page or section.', lastUsed: '2026-04-10T14:00:00Z', usageCount: 3},
- {name: 'Button', description: 'Primary action element for forms, dialogs, and toolbars.', lastUsed: '2026-04-14T16:00:00Z', usageCount: 24},
- {name: 'Calendar', description: 'Date-picking grid for selecting single dates or date ranges.', lastUsed: '2026-04-08T11:30:00Z', usageCount: 2},
- {name: 'Dialog', description: 'Modal overlays that require user attention or action.', lastUsed: '2026-04-11T13:15:00Z', usageCount: 6},
- {name: 'DropdownMenu', description: 'Presents actions or options in a floating overlay.', lastUsed: '2026-04-09T16:45:00Z', usageCount: 5},
+ {name: 'Admin Dashboard', type: 'Template', description: 'Full admin panel with sidebar nav, KPI cards, and data tables.', lastUsed: '2026-04-15T09:00:00Z', usageCount: 7, img: SCREENSHOT_3_IMAGE},
+ {name: 'AppShell', type: 'Component', description: 'Foundational page layout with header, sidebar, and content regions.', lastUsed: '2026-04-14T10:30:00Z', usageCount: 12, img: FIRST_CARD_IMAGE},
+ {name: 'Meta Theme', type: 'Theme', description: 'Meta brand colors with Figtree typography and blue accents.', lastUsed: '2026-04-14T08:00:00Z', usageCount: 9, img: SHOPPING_DETAILS_IMAGE},
+ {name: 'Button', type: 'Component', description: 'Primary action element for forms, dialogs, and toolbars.', lastUsed: '2026-04-14T16:00:00Z', usageCount: 24, img: FIRST_CARD_IMAGE},
+ {name: 'Contact Form', type: 'Template', description: 'Responsive contact form with validation, file upload, and success state.', lastUsed: '2026-04-13T11:00:00Z', usageCount: 4, img: `${basePath}/templates/card4-preview.png`},
+ {name: 'Badge', type: 'Component', description: 'Displays small counts or status labels on icons, buttons, or list items.', lastUsed: '2026-04-12T09:20:00Z', usageCount: 15, img: SCREENSHOT_3_IMAGE},
+ {name: 'Dark Mode Palette', type: 'Theme', description: 'High-contrast dark theme with WCAG AA compliant color ratios.', lastUsed: '2026-04-11T18:30:00Z', usageCount: 3, img: DUMMY_IMAGE},
+ {name: 'Avatar', type: 'Component', description: 'Represents a person or entity with an image, initials, or icon.', lastUsed: '2026-04-13T15:45:00Z', usageCount: 8, img: SHOPPING_DETAILS_IMAGE},
+ {name: 'Settings Page', type: 'Template', description: 'Sidebar settings layout with inline editing and expandable rows.', lastUsed: '2026-04-10T14:00:00Z', usageCount: 5, img: `${basePath}/templates/card4-preview.png`},
+ {name: 'Dialog', type: 'Component', description: 'Modal overlays that require user attention or action.', lastUsed: '2026-04-11T13:15:00Z', usageCount: 6, img: DUMMY_IMAGE},
+ {name: 'WhatsApp Theme', type: 'Theme', description: 'WhatsApp brand greens and warm grays with rounded components.', lastUsed: '2026-04-09T10:00:00Z', usageCount: 2, img: DUMMY_IMAGE},
+ {name: 'DropdownMenu', type: 'Component', description: 'Presents actions or options in a floating overlay.', lastUsed: '2026-04-09T16:45:00Z', usageCount: 5, img: DUMMY_IMAGE},
];
export const PROFILE_LIKED_ITEMS: {
name: string;
- type: string;
- lastUsed: string;
+ type: 'Template' | 'Theme' | 'Component';
+ bookmarkedAt: string;
+ description: string;
+ img: string;
+ author: string;
}[] = [
- {name: 'Meta Theme', type: 'Theme', lastUsed: '2026-04-13T08:00:00Z'},
- {name: 'Brutalist Theme', type: 'Theme', lastUsed: '2026-04-11T10:30:00Z'},
- {name: 'Admin Dashboard', type: 'Template', lastUsed: '2026-04-10T14:20:00Z'},
- {name: 'Product Detail', type: 'Template', lastUsed: '2026-04-07T09:00:00Z'},
+ {name: 'Meta Theme', type: 'Theme', bookmarkedAt: '2026-04-13T08:00:00Z', description: 'Meta brand colors with Figtree typography.', img: FIRST_CARD_IMAGE, author: 'XDS Design'},
+ {name: 'Brutalist Theme', type: 'Theme', bookmarkedAt: '2026-04-11T10:30:00Z', description: 'Bold, raw aesthetic with heavy borders and sharp angles.', img: SHOPPING_DETAILS_IMAGE, author: 'Andrea Anderson'},
+ {name: 'Admin Dashboard', type: 'Template', bookmarkedAt: '2026-04-10T14:20:00Z', description: 'Full admin panel with sidebar nav, KPI cards, and data tables.', img: SCREENSHOT_3_IMAGE, author: 'Andrea Anderson'},
+ {name: 'Product Detail', type: 'Template', bookmarkedAt: '2026-04-07T09:00:00Z', description: 'E-commerce product page with image gallery and reviews.', img: `${basePath}/templates/card4-preview.png`, author: 'XDS Design'},
+ {name: 'Toast Notification', type: 'Component', bookmarkedAt: '2026-04-05T11:00:00Z', description: 'Stackable toast with auto-dismiss and action support.', img: DUMMY_IMAGE, author: 'Andrea Anderson'},
+ {name: 'Kanban Board', type: 'Template', bookmarkedAt: '2026-04-02T16:30:00Z', description: 'Drag-and-drop board with swimlanes and card detail drawers.', img: DUMMY_IMAGE, author: 'XDS Design'},
];
-export const PROFILE_COLLECTIONS = [
- {name: 'Work Projects', count: 4},
- {name: 'Design Inspiration', count: 6},
- {name: 'Client Templates', count: 3},
- {name: 'Dashboard Ideas', count: 5},
- {name: 'Landing Pages', count: 8},
+export const PROFILE_COLLECTIONS: {
+ name: string;
+ count: number;
+ color: string;
+ items: string[];
+}[] = [
+ {name: 'Work Projects', count: 4, color: '#3B82F6', items: ['Admin Dashboard', 'Meta Theme', 'Toast Notification', 'Kanban Board']},
+ {name: 'Design Inspiration', count: 6, color: '#8B5CF6', items: ['Meta Theme', 'Brutalist Theme', 'Admin Dashboard', 'Product Detail', 'Toast Notification', 'Kanban Board']},
+ {name: 'Client Templates', count: 3, color: '#F59E0B', items: ['Admin Dashboard', 'Product Detail', 'Kanban Board']},
+ {name: 'Dashboard Ideas', count: 5, color: '#10B981', items: ['Admin Dashboard', 'Meta Theme', 'Brutalist Theme', 'Product Detail', 'Kanban Board']},
+ {name: 'Landing Pages', count: 8, color: '#EF4444', items: ['Meta Theme', 'Brutalist Theme', 'Admin Dashboard', 'Product Detail', 'Toast Notification', 'Kanban Board', 'Meta Theme', 'Brutalist Theme']},
];
export const PROFILE_CRAFT_ITEMS: {
name: string;
type: 'Template' | 'Theme' | 'Component';
- status: 'Published' | 'Draft' | 'In Review';
+ status: 'Published' | 'Draft' | 'In Review' | 'Needs Fixes';
used: number;
views: number;
+ bookmarks: number;
img: string;
lastUpdated: string;
description: string;
+ tags: string[];
}[] = [
- {name: 'My Dashboard Theme', type: 'Theme', status: 'Published', used: 342, views: 1205, img: FIRST_CARD_IMAGE, lastUpdated: '2026-03-01T10:00:00Z', description: 'Dark-mode friendly theme with custom color tokens and typography overrides.'},
- {name: 'Custom Login Template', type: 'Template', status: 'Published', used: 128, views: 580, img: SHOPPING_DETAILS_IMAGE, lastUpdated: '2026-03-15T14:30:00Z', description: 'Branded login page with social auth buttons and form validation.'},
- {name: 'Data Visualization Kit', type: 'Template', status: 'Published', used: 89, views: 312, img: SCREENSHOT_3_IMAGE, lastUpdated: '2026-04-02T11:00:00Z', description: 'Charts, graphs, and data table layouts for analytics dashboards.'},
- {name: 'Settings Page', type: 'Template', status: 'Published', used: 67, views: 248, img: `${basePath}/templates/card4-preview.png`, lastUpdated: '2026-02-20T08:00:00Z', description: 'Sidebar settings layout with inline editing and expandable rows.'},
- {name: 'Product Detail Page', type: 'Template', status: 'Published', used: 54, views: 190, img: DUMMY_IMAGE, lastUpdated: '2026-03-28T12:00:00Z', description: 'E-commerce product page with image gallery, reviews, and add-to-cart.'},
- {name: 'Custom Notification Card', type: 'Component', status: 'Published', used: 203, views: 870, img: DUMMY_IMAGE, lastUpdated: '2026-01-15T09:00:00Z', description: 'Toast-style notification card with dismiss, action buttons, and auto-hide.'},
- {name: 'Metric Summary Card', type: 'Component', status: 'Published', used: 156, views: 620, img: DUMMY_IMAGE, lastUpdated: '2026-02-10T14:00:00Z', description: 'KPI card with sparkline, trend indicator, and comparison period.'},
- {name: 'Analytics Dashboard', type: 'Template', status: 'In Review', used: 0, views: 45, img: DUMMY_IMAGE, lastUpdated: '2026-04-12T09:00:00Z', description: 'Full-page analytics dashboard with filters, charts, and data tables.'},
- {name: 'Team Directory', type: 'Template', status: 'In Review', used: 0, views: 32, img: DUMMY_IMAGE, lastUpdated: '2026-04-10T16:30:00Z', description: 'Searchable team roster with profile cards, org chart, and role filters.'},
- {name: 'Onboarding Flow', type: 'Template', status: 'Draft', used: 0, views: 12, img: DUMMY_IMAGE, lastUpdated: '2026-04-14T16:00:00Z', description: 'Multi-step onboarding wizard with progress bar and skip logic.'},
- {name: 'Dark Mode Palette', type: 'Theme', status: 'Draft', used: 0, views: 8, img: DUMMY_IMAGE, lastUpdated: '2026-04-13T11:30:00Z', description: 'High-contrast dark theme with WCAG AA compliant color ratios.'},
- {name: 'File Upload Dropzone', type: 'Component', status: 'Draft', used: 0, views: 5, img: DUMMY_IMAGE, lastUpdated: '2026-04-15T10:00:00Z', description: 'Drag-and-drop file uploader with preview thumbnails and progress bars.'},
+ {name: 'My Dashboard Theme', type: 'Theme', status: 'Published', used: 342, views: 1205, bookmarks: 89, img: FIRST_CARD_IMAGE, lastUpdated: '2026-03-01T10:00:00Z', description: 'Dark-mode friendly theme with custom color tokens and typography overrides.', tags: ['Dashboard', 'Dark Mode', 'SaaS']},
+ {name: 'Custom Login Template', type: 'Template', status: 'Published', used: 128, views: 580, bookmarks: 34, img: SHOPPING_DETAILS_IMAGE, lastUpdated: '2026-03-15T14:30:00Z', description: 'Branded login page with social auth buttons and form validation.', tags: ['Login', 'Authentication', 'Form']},
+ {name: 'Data Visualization Kit', type: 'Template', status: 'Published', used: 89, views: 312, bookmarks: 27, img: SCREENSHOT_3_IMAGE, lastUpdated: '2026-04-02T11:00:00Z', description: 'Charts, graphs, and data table layouts for analytics dashboards.', tags: ['Dashboard', 'Charts', 'Analytics']},
+ {name: 'Settings Page', type: 'Template', status: 'Published', used: 67, views: 248, bookmarks: 18, img: `${basePath}/templates/card4-preview.png`, lastUpdated: '2026-02-20T08:00:00Z', description: 'Sidebar settings layout with inline editing and expandable rows.', tags: ['Settings', 'SaaS', 'Admin']},
+ {name: 'Product Detail Page', type: 'Template', status: 'Published', used: 54, views: 190, bookmarks: 15, img: DUMMY_IMAGE, lastUpdated: '2026-03-28T12:00:00Z', description: 'E-commerce product page with image gallery, reviews, and add-to-cart.', tags: ['E-commerce', 'Shopping', 'Product']},
+ {name: 'Custom Notification Card', type: 'Component', status: 'Published', used: 203, views: 870, bookmarks: 62, img: DUMMY_IMAGE, lastUpdated: '2026-01-15T09:00:00Z', description: 'Toast-style notification card with dismiss, action buttons, and auto-hide.', tags: ['Notification', 'Toast', 'Feedback']},
+ {name: 'Metric Summary Card', type: 'Component', status: 'Published', used: 156, views: 620, bookmarks: 41, img: DUMMY_IMAGE, lastUpdated: '2026-02-10T14:00:00Z', description: 'KPI card with sparkline, trend indicator, and comparison period.', tags: ['Dashboard', 'KPI', 'Analytics']},
+ {name: 'Analytics Dashboard', type: 'Template', status: 'In Review', used: 0, views: 45, bookmarks: 0, img: DUMMY_IMAGE, lastUpdated: '2026-04-12T09:00:00Z', description: 'Full-page analytics dashboard with filters, charts, and data tables.', tags: ['Dashboard', 'Analytics', 'Data Table']},
+ {name: 'Team Directory', type: 'Template', status: 'In Review', used: 0, views: 32, bookmarks: 0, img: DUMMY_IMAGE, lastUpdated: '2026-04-10T16:30:00Z', description: 'Searchable team roster with profile cards, org chart, and role filters.', tags: ['Directory', 'Team', 'Admin']},
+ {name: 'Checkout Flow', type: 'Template', status: 'Needs Fixes', used: 0, views: 18, bookmarks: 0, img: DUMMY_IMAGE, lastUpdated: '2026-04-11T14:00:00Z', description: 'Multi-step checkout with cart summary, address form, and payment integration.', tags: ['E-commerce', 'Checkout', 'Form']},
+ {name: 'Onboarding Flow', type: 'Template', status: 'Draft', used: 0, views: 12, bookmarks: 0, img: DUMMY_IMAGE, lastUpdated: '2026-04-14T16:00:00Z', description: 'Multi-step onboarding wizard with progress bar and skip logic.', tags: ['Onboarding', 'Wizard', 'Form']},
+ {name: 'Dark Mode Palette', type: 'Theme', status: 'Draft', used: 0, views: 8, bookmarks: 0, img: DUMMY_IMAGE, lastUpdated: '2026-04-13T11:30:00Z', description: 'High-contrast dark theme with WCAG AA compliant color ratios.', tags: ['Dark Mode', 'Accessibility', 'Theme']},
+ {name: 'File Upload Dropzone', type: 'Component', status: 'Draft', used: 0, views: 5, bookmarks: 0, img: DUMMY_IMAGE, lastUpdated: '2026-04-15T10:00:00Z', description: 'Drag-and-drop file uploader with preview thumbnails and progress bars.', tags: ['Upload', 'Form', 'File']},
];
// ---------------------------------------------------------------------------
diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx
index e482a6ffee..28e42c2e1e 100644
--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx
+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx
@@ -15,7 +15,6 @@ import {
TEMPLATES,
AVATAR_IMAGE,
XDS_DESIGN_AVATAR,
- THEME_PICKER_ENTRIES,
FILTER_COLUMNS,
PROFILE_CRAFT_ITEMS,
basePath,
@@ -27,6 +26,7 @@ import type {PanelTab, PointedElement} from './ChatPanel';
import {InlinePublishPanel} from './InlinePublishPanel';
import {TemplatePreview} from './TemplatePreview';
import {SharePopoverContent} from './SharePopover';
+import {TemplatePreviewModal} from './TemplatePreviewModal';
import {AppTopNav} from './AppTopNav';
import {DocsView} from './DocsView';
import {ProfileView} from './ProfileView';
@@ -46,62 +46,19 @@ import {XDSList, XDSListItem} from '@xds/core/List';
import {XDSPopover} from '@xds/core/Popover';
import {XDSTextInput} from '@xds/core/TextInput';
import {XDSToolbar} from '@xds/core/Toolbar';
-import {XDSTooltip} from '@xds/core/Tooltip';
+
import {XDSDropdownMenu} from '@xds/core/DropdownMenu';
import {
ArrowLeftIcon,
- BookmarkIcon,
- BookmarkFilledIcon,
- StarIcon,
- StarFilledIcon,
SearchIcon,
PaletteIcon,
ContrastIcon,
MoonIcon,
VerifiedIcon,
- MetaLogo,
- WhatsAppLogo,
- ThreadsLogo,
- FacebookLogo,
- DefaultThemeIcon,
- ForestThemeIcon,
- SunsetThemeIcon,
FilterIcon,
- MidnightThemeIcon,
} from './docsite-icons';
-const BRAND_LOGOS: Record<
- string,
- React.ComponentType<React.SVGProps<SVGSVGElement>>
-> = {
- default: DefaultThemeIcon,
- meta: MetaLogo,
- whatsapp: WhatsAppLogo,
- threads: ThreadsLogo,
- facebook: FacebookLogo,
- forest: ForestThemeIcon,
- sunset: SunsetThemeIcon,
- midnight: MidnightThemeIcon,
-};
-
-const tokenStyles = stylex.create({
- outline: {
- borderWidth: 1,
- borderStyle: 'solid',
- borderColor: 'var(--color-border-emphasized)',
- },
- pill: {
- borderWidth: 1,
- borderStyle: 'solid',
- borderColor: 'var(--color-border-emphasized)',
- borderRadius: 9999,
- },
-});
-
const popoverStyles = stylex.create({
- themeBrowse: {
- padding: 16,
- },
filterDropdown: {
padding: 8,
},
@@ -235,17 +192,47 @@ function DocsiteLandingTemplate() {
const v = searchParams.get('view');
const t = searchParams.get('template');
const q = searchParams.get('q');
+ const page = searchParams.get('page');
+ const tab = searchParams.get('tab');
+ const craft = searchParams.get('craft');
+ const used = searchParams.get('used');
+ const settings = searchParams.get('settings');
+ const collection = searchParams.get('collection');
const templateIdx = t !== null ? parseInt(t, 10) : null;
return {
view: v,
templateIdx: isNaN(templateIdx as number) ? null : templateIdx,
query: q,
+ page: page as 'craft' | 'explore' | 'docs' | 'profile' | null,
+ tab:
+ tab && ['Crafted', 'Used', 'Bookmarks'].includes(tab)
+ ? (tab as 'Crafted' | 'Used' | 'Bookmarks')
+ : null,
+ craft,
+ used,
+ settings: settings === '1',
+ collection,
};
}, [searchParams]);
const [activeView, setActiveView] = useState(
- 'craft' as 'craft' | 'explore' | 'docs' | 'profile',
+ (initialView.page ?? 'craft') as 'craft' | 'explore' | 'docs' | 'profile',
+ );
+ const [profileTab, setProfileTab] = useState<
+ 'Crafted' | 'Used' | 'Bookmarks'
+ >(initialView.tab ?? 'Crafted');
+ const [profileCraftName, setProfileCraftName] = useState<string | null>(
+ initialView.craft,
+ );
+ const [profileUsedName, setProfileUsedName] = useState<string | null>(
+ initialView.used,
);
+ const [profileSettingsOpen, setProfileSettingsOpen] = useState(
+ initialView.settings,
+ );
+ const [profileCollectionName, setProfileCollectionName] = useState<
+ string | null
+ >(initialView.collection);
const [craftTitle, setCraftTitle] = useState<string | null>(
initialView.query,
);
@@ -316,7 +303,6 @@ function DocsiteLandingTemplate() {
initialView.view === 'editor' ? initialView.templateIdx : null,
);
const [previewGenerating, setPreviewGenerating] = useState(false);
- const [previewTransitioning, setPreviewTransitioning] = useState(false);
const [showPublishCard1, setShowPublishCard1] = useState(false);
const [panelTab, setPanelTab] = useState<PanelTab>('configure');
const [isPointing, setIsPointing] = useState(false);
@@ -328,26 +314,7 @@ function DocsiteLandingTemplate() {
const scrollContainerRef = useRef<HTMLDivElement>(null);
const [isHeaderCollapsed, setIsHeaderCollapsed] = useState(false);
- const [card4SelectedOption, setCard4SelectedOption] = useState('default');
- const [card4ThemeBrowse, setCard4ThemeBrowse] = useState(false);
const [card4Bookmarked, setCard4Bookmarked] = useState(false);
- const [card4ShowAddPopover, setCard4ShowAddPopover] = useState(false);
- const card4ScrollRef = useRef<HTMLDivElement>(null);
- const [card4ThemeSearch, setCard4ThemeSearch] = useState('');
- const [card4PinnedThemes, setCard4PinnedThemes] = useState(
- () =>
- new Set(
- THEME_PICKER_ENTRIES.filter(t => t.isPinnedByDefault).map(t => t.key),
- ),
- );
- const toggleCard4Pin = useCallback((key: string) => {
- setCard4PinnedThemes(prev => {
- const next = new Set(prev);
- if (next.has(key)) next.delete(key);
- else next.add(key);
- return next;
- });
- }, []);
const handleEditorResizeStart = useCallback(
(e: React.MouseEvent) => {
@@ -382,21 +349,64 @@ function DocsiteLandingTemplate() {
// Sync URL when view state changes
useEffect(() => {
- let path = '/pages/docsite/';
+ const params = new URLSearchParams();
+
if (previewTarget !== null) {
- path += '?view=preview&template=' + previewTarget;
+ params.set('view', 'preview');
+ params.set('template', String(previewTarget));
} else if (useTarget !== null) {
- path += '?view=editor&template=' + useTarget;
+ params.set('view', 'editor');
+ params.set('template', String(useTarget));
} else if (craftTitle) {
- path += '?q=' + encodeURIComponent(craftTitle);
+ params.set('q', craftTitle);
+ } else if (activeView !== 'craft') {
+ params.set('page', activeView);
+ if (activeView === 'profile') {
+ if (profileCraftName) {
+ params.set('tab', 'Crafted');
+ params.set('craft', profileCraftName);
+ } else if (profileUsedName) {
+ params.set('tab', 'Used');
+ params.set('used', profileUsedName);
+ } else if (profileCollectionName) {
+ params.set('tab', 'Bookmarks');
+ params.set('collection', profileCollectionName);
+ } else if (profileTab !== 'Crafted') {
+ params.set('tab', profileTab);
+ }
+ if (profileSettingsOpen) {
+ params.set('settings', '1');
+ }
+ }
}
- router.replace(path, {scroll: false});
- }, [previewTarget, useTarget, craftTitle, router]);
+
+ const qs = params.toString();
+ router.replace(
+ `${basePath}/pages/docsite/${qs ? '?' + qs : ''}`,
+ {scroll: false},
+ );
+ }, [
+ previewTarget,
+ useTarget,
+ craftTitle,
+ activeView,
+ profileTab,
+ profileCraftName,
+ profileUsedName,
+ profileSettingsOpen,
+ profileCollectionName,
+ router,
+ ]);
const prevViewRef = useRef(activeView);
+ const skipViewResetRef = useRef(false);
useEffect(() => {
if (prevViewRef.current === activeView) return;
prevViewRef.current = activeView;
+ if (skipViewResetRef.current) {
+ skipViewResetRef.current = false;
+ return;
+ }
setPreviewTarget(null);
setUseTarget(null);
setChatOpen(false);
@@ -447,16 +457,23 @@ function DocsiteLandingTemplate() {
);
const handleUse = useCallback((index: number) => {
+ viewBeforeEditorRef.current = activeView;
setPreviewTarget(null);
setUseTarget(index);
setPanelTab('configure');
setChatOpen(true);
- }, []);
+ }, [activeView]);
+ const viewBeforeEditorRef = useRef<'craft' | 'explore' | 'docs' | 'profile'>('craft');
const handleBackFromUse = useCallback(() => {
setUseTarget(null);
setChatOpen(false);
setShowPublishCard1(false);
+ const returnTo = viewBeforeEditorRef.current;
+ if (returnTo !== 'craft') {
+ skipViewResetRef.current = true;
+ setActiveView(returnTo);
+ }
}, []);
const handlePreview = useCallback((index: number) => {
@@ -504,38 +521,35 @@ function DocsiteLandingTemplate() {
setActiveFilters(new Set());
}, []);
- const handleProfileAction = useCallback(
- (action: 'craft' | 'bookmarked' | 'used' | 'settings') => {
- if (action === 'settings') {
- setIsSettingsOpen(true);
- } else if (action === 'craft') {
- setPreviewTarget(null);
- setCraftTitle('My Craft');
- setIsCraftResults(true);
- setIsProfileResults(true);
- setCraftStatusFilter('all');
- setCraftLoading(true);
- if (craftLoadingTimer.current) clearTimeout(craftLoadingTimer.current);
- craftLoadingTimer.current = setTimeout(() => {
- setCraftLoading(false);
- craftLoadingTimer.current = null;
- }, 900);
- } else {
- const label = action === 'bookmarked' ? 'Bookmarked' : 'Used';
- setPreviewTarget(null);
- setCraftTitle(label);
- setIsProfileResults(true);
- setIsCraftResults(false);
- setCraftLoading(true);
- if (craftLoadingTimer.current) clearTimeout(craftLoadingTimer.current);
- craftLoadingTimer.current = setTimeout(() => {
- setCraftLoading(false);
- craftLoadingTimer.current = null;
- }, 900);
- }
- },
- [],
- );
+ const handleProfileAction = useCallback((action: 'craft' | 'bookmarked' | 'used' | 'settings') => {
+ if (action === 'settings') {
+ setIsSettingsOpen(true);
+ } else if (action === 'craft') {
+ setPreviewTarget(null);
+ setCraftTitle('My Craft');
+ setIsCraftResults(true);
+ setIsProfileResults(true);
+ setCraftStatusFilter('all');
+ setCraftLoading(true);
+ if (craftLoadingTimer.current) clearTimeout(craftLoadingTimer.current);
+ craftLoadingTimer.current = setTimeout(() => {
+ setCraftLoading(false);
+ craftLoadingTimer.current = null;
+ }, 900);
+ } else {
+ const label = action === 'bookmarked' ? 'Bookmarked' : 'Used';
+ setPreviewTarget(null);
+ setCraftTitle(label);
+ setIsProfileResults(true);
+ setIsCraftResults(false);
+ setCraftLoading(true);
+ if (craftLoadingTimer.current) clearTimeout(craftLoadingTimer.current);
+ craftLoadingTimer.current = setTimeout(() => {
+ setCraftLoading(false);
+ craftLoadingTimer.current = null;
+ }, 900);
+ }
+ }, []);
const filteredTemplates = useMemo(() => {
return TEMPLATES.map((t, i) => ({...t, originalIndex: i})).filter(t => {
@@ -545,26 +559,23 @@ function DocsiteLandingTemplate() {
});
}, [templateFilter]);
- const craftStatusCounts = useMemo(
- () => ({
- published: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'Published')
- .length,
- draft: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'Draft').length,
- review: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'In Review').length,
- }),
- [],
- );
+ const craftStatusCounts = useMemo(() => ({
+ published: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'Published').length,
+ draft: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'Draft').length,
+ review: PROFILE_CRAFT_ITEMS.filter(i => i.status === 'In Review').length,
+ }), []);
const filteredCraftItems = useMemo(() => {
if (craftStatusFilter === 'all') return PROFILE_CRAFT_ITEMS;
- return PROFILE_CRAFT_ITEMS.filter(
- item => item.status === craftStatusFilter,
- );
+ return PROFILE_CRAFT_ITEMS.filter(item => item.status === craftStatusFilter);
}, [craftStatusFilter]);
// Editor flow — same layout for all cards
if (useTarget !== null && activeView === 'craft') {
- const t = TEMPLATES[useTarget % TEMPLATES.length];
+ const isBlankCanvas = useTarget === -1;
+ const t = isBlankCanvas
+ ? {name: 'Untitled', src: '', size: 'medium' as const, author: '', isOfficial: false}
+ : TEMPLATES[useTarget % TEMPLATES.length];
return (
<div
style={{
@@ -731,7 +742,28 @@ function DocsiteLandingTemplate() {
if (activeView === 'profile') {
return (
- <ProfileView activeView={activeView} setActiveView={setActiveView} />
+ <ProfileView
+ activeView={activeView}
+ setActiveView={setActiveView}
+ onStartCrafting={() => {
+ viewBeforeEditorRef.current = 'profile';
+ skipViewResetRef.current = true;
+ setActiveView('craft');
+ setUseTarget(-1);
+ setPanelTab('configure');
+ setChatOpen(true);
+ }}
+ profileTab={profileTab}
+ onTabChange={setProfileTab}
+ profileCraftName={profileCraftName}
+ onCraftPreviewChange={setProfileCraftName}
+ profileUsedName={profileUsedName}
+ onUsedPreviewChange={setProfileUsedName}
+ profileSettingsOpen={profileSettingsOpen}
+ onSettingsChange={setProfileSettingsOpen}
+ profileCollectionName={profileCollectionName}
+ onCollectionChange={setProfileCollectionName}
+ />
);
}
@@ -868,31 +900,15 @@ function DocsiteLandingTemplate() {
'craftTitleSlideIn 400ms 100ms cubic-bezier(0.16, 1, 0.3, 1) both',
}}>
{[
- {
- value: 'all',
- label: `All (${PROFILE_CRAFT_ITEMS.length})`,
- },
- {
- value: 'Published',
- label: `Published (${craftStatusCounts.published})`,
- },
- {
- value: 'Draft',
- label: `Draft (${craftStatusCounts.draft})`,
- },
- {
- value: 'In Review',
- label: `In Review (${craftStatusCounts.review})`,
- },
+ {value: 'all', label: `All (${PROFILE_CRAFT_ITEMS.length})`},
+ {value: 'Published', label: `Published (${craftStatusCounts.published})`},
+ {value: 'Draft', label: `Draft (${craftStatusCounts.draft})`},
+ {value: 'In Review', label: `In Review (${craftStatusCounts.review})`},
].map(tab => (
<XDSButton
key={tab.value}
label={tab.label}
- variant={
- craftStatusFilter === tab.value
- ? 'primary'
- : 'secondary'
- }
+ variant={craftStatusFilter === tab.value ? 'primary' : 'secondary'}
size="sm"
onClick={() => setCraftStatusFilter(tab.value)}
/>
@@ -1270,7 +1286,8 @@ function DocsiteLandingTemplate() {
background:
'linear-gradient(90deg, var(--color-background-muted, #f0f0f0) 0%, var(--color-background-surface, #fafafa) 50%, var(--color-background-muted, #f0f0f0) 100%)',
backgroundSize: '800px 100%',
- animation: 'craftShimmer 1.6s ease-in-out infinite',
+ animation:
+ 'craftShimmer 1.6s ease-in-out infinite',
borderRadius: '16px 16px 0 0',
}}
/>
@@ -1289,7 +1306,8 @@ function DocsiteLandingTemplate() {
background:
'linear-gradient(90deg, var(--color-background-muted, #f0f0f0) 0%, var(--color-background-surface, #fafafa) 50%, var(--color-background-muted, #f0f0f0) 100%)',
backgroundSize: '800px 100%',
- animation: 'craftShimmer 1.6s ease-in-out infinite',
+ animation:
+ 'craftShimmer 1.6s ease-in-out infinite',
}}
/>
<div
@@ -1300,7 +1318,8 @@ function DocsiteLandingTemplate() {
background:
'linear-gradient(90deg, var(--color-background-muted, #f0f0f0) 0%, var(--color-background-surface, #fafafa) 50%, var(--color-background-muted, #f0f0f0) 100%)',
backgroundSize: '800px 100%',
- animation: 'craftShimmer 1.6s ease-in-out infinite',
+ animation:
+ 'craftShimmer 1.6s ease-in-out infinite',
}}
/>
</div>
@@ -1332,8 +1351,7 @@ function DocsiteLandingTemplate() {
style={{
aspectRatio: '16 / 9',
overflow: 'hidden',
- backgroundColor:
- 'var(--color-background-muted, #f0f0f0)',
+ backgroundColor: 'var(--color-background-muted, #f0f0f0)',
}}>
<img
src={item.img}
@@ -1406,10 +1424,7 @@ function DocsiteLandingTemplate() {
</div>
<div style={{marginLeft: 'auto'}}>
<XDSText type="supporting" color="secondary">
- {new Date(item.lastUpdated).toLocaleDateString(
- 'en-US',
- {month: 'short', day: 'numeric'},
- )}
+ {new Date(item.lastUpdated).toLocaleDateString('en-US', {month: 'short', day: 'numeric'})}
</XDSText>
</div>
</div>
@@ -1417,12 +1432,7 @@ function DocsiteLandingTemplate() {
</XDSCard>
))}
{filteredCraftItems.length === 0 && (
- <div
- style={{
- gridColumn: '1 / -1',
- padding: 32,
- textAlign: 'center' as const,
- }}>
+ <div style={{gridColumn: '1 / -1', padding: 32, textAlign: 'center' as const}}>
<XDSText type="body" color="secondary">
No items match this filter.
</XDSText>
@@ -1430,59 +1440,59 @@ function DocsiteLandingTemplate() {
)}
</div>
) : (
- <div
- style={{
- maxWidth: 2000,
- margin: '0 auto',
- display: 'grid',
- gridTemplateColumns: isMobile
- ? '1fr'
- : isTablet
- ? 'repeat(2, 1fr)'
- : 'repeat(3, 1fr)',
- gap: 16,
- }}>
- {filteredTemplates.map((template, i) => (
- <div
- key={`${template.name}-${template.originalIndex}`}
- style={{
- ...(craftTitle
- ? {
- animation: `craftCardFadeIn 400ms ${i * 50}ms cubic-bezier(0.16, 1, 0.3, 1) both`,
- }
- : undefined),
- filter: previewImageFilter,
- transition: 'filter 300ms ease',
- }}>
- <TemplateCard
- src={template.src}
- name={template.name}
- isSelected={selected.has(template.originalIndex)}
- isGenerating={
- isGenerating &&
- generatingSource !== template.originalIndex
- }
- cardSize={template.size}
- onSelect={() =>
- setSelected(prev => {
- const next = new Set(prev);
- if (next.has(template.originalIndex)) {
- next.delete(template.originalIndex);
- } else {
- next.add(template.originalIndex);
- }
- return next;
- })
- }
- onMoreLikeThis={() =>
- handleMoreLikeThis(template.originalIndex)
- }
- onUse={() => handleUse(template.originalIndex)}
- onPreview={() => handlePreview(template.originalIndex)}
- />
- </div>
- ))}
- </div>
+ <div
+ style={{
+ maxWidth: 2000,
+ margin: '0 auto',
+ display: 'grid',
+ gridTemplateColumns: isMobile
+ ? '1fr'
+ : isTablet
+ ? 'repeat(2, 1fr)'
+ : 'repeat(3, 1fr)',
+ gap: 16,
+ }}>
+ {filteredTemplates.map((template, i) => (
+ <div
+ key={`${template.name}-${template.originalIndex}`}
+ style={{
+ ...(craftTitle
+ ? {
+ animation: `craftCardFadeIn 400ms ${i * 50}ms cubic-bezier(0.16, 1, 0.3, 1) both`,
+ }
+ : undefined),
+ filter: previewImageFilter,
+ transition: 'filter 300ms ease',
+ }}>
+ <TemplateCard
+ src={template.src}
+ name={template.name}
+ isSelected={selected.has(template.originalIndex)}
+ isGenerating={
+ isGenerating &&
+ generatingSource !== template.originalIndex
+ }
+ cardSize={template.size}
+ onSelect={() =>
+ setSelected(prev => {
+ const next = new Set(prev);
+ if (next.has(template.originalIndex)) {
+ next.delete(template.originalIndex);
+ } else {
+ next.add(template.originalIndex);
+ }
+ return next;
+ })
+ }
+ onMoreLikeThis={() =>
+ handleMoreLikeThis(template.originalIndex)
+ }
+ onUse={() => handleUse(template.originalIndex)}
+ onPreview={() => handlePreview(template.originalIndex)}
+ />
+ </div>
+ ))}
+ </div>
)}
</div>
</div>
@@ -1495,668 +1505,45 @@ function DocsiteLandingTemplate() {
{previewTarget !== null &&
(() => {
const t = TEMPLATES[previewTarget % TEMPLATES.length];
- const isMeta = previewTarget === 3 && card4SelectedOption === 'meta';
const moreLikeThisImages = TEMPLATES.map((tmpl, i) => ({
- src: tmpl.src,
+ img: tmpl.src,
name: tmpl.name,
- description: `${tmpl.name} template`,
- originalIndex: i,
+ key: i,
}))
- .filter(item => item.originalIndex !== previewTarget)
+ .filter(item => item.key !== previewTarget)
.slice(0, 4);
return (
- <XDSDialog
+ <TemplatePreviewModal
isOpen={true}
- onOpenChange={open => {
- if (!open) setPreviewTarget(null);
+ onClose={() => setPreviewTarget(null)}
+ item={{
+ name: t.name,
+ img: t.src,
+ author: t.author,
}}
- width="90vw"
- maxHeight="90vh"
- purpose="info"
- style={
- {
- padding: 0,
- overflow: 'visible',
- maxWidth: 1600,
- '--xds-dialog-padding': '0px',
- } as React.CSSProperties
- }>
- <div
- style={{position: 'absolute', top: 0, right: -40, zIndex: 1}}>
- <XDSCard padding={0} style={{borderRadius: '50%'}}>
- <XDSButton
- label="Close"
- variant="ghost"
- size="sm"
- isIconOnly
- icon={<span style={{fontSize: 16, lineHeight: 1}}>✕</span>}
- onClick={() => setPreviewTarget(null)}
- />
- </XDSCard>
- </div>
- <div ref={card4ScrollRef} style={{overflowY: 'auto'}}>
- {/* Main content: image left + details right */}
- <div style={{display: 'flex', minHeight: 0, padding: '0 32px'}}>
- {/* Left — Preview image + thumbnails */}
- <XDSStack
- direction="vertical"
- gap={3}
- style={{flex: 1, minWidth: 0, padding: '32px 32px 32px 0'}}>
- <div
- style={{
- flex: 1,
- aspectRatio: '16 / 10',
- backgroundColor:
- 'var(--color-background-muted, #f9f9f9)',
- borderRadius: 12,
- overflowY: 'auto',
- overflowX: 'hidden',
- border: '1px solid var(--color-border, #e0e0e0)',
- }}>
- <img
- src={
- isMeta
- ? `${basePath}/templates/card4-preview-meta.png`
- : t.src
- }
- alt={t.name}
- style={{
- width: '100%',
- display: 'block',
- opacity: previewTransitioning ? 0 : 1,
- transition: 'opacity 250ms ease',
- animation: previewTransitioning
- ? 'none'
- : 'previewFadeIn 300ms ease',
- }}
- />
- </div>
- </XDSStack>
-
- {/* Right — Details panel */}
- <XDSStack
- direction="vertical"
- style={{width: 360, flexShrink: 0, padding: '32px 0'}}>
- <div
- style={{
- opacity: previewTransitioning ? 0 : 1,
- transition: 'opacity 250ms ease',
- animation: previewTransitioning
- ? 'none'
- : 'previewFadeIn 300ms ease',
- }}>
- {/* Title */}
- <XDSText type="display-2">{t.name}</XDSText>
-
- {/* Description */}
- <div style={{marginTop: 8}}>
- <XDSText type="body" color="secondary">
- A ready-to-use {t.name.toLowerCase()} template built
- with XDS components. Customize it with your own
- content and theme to match your brand.
- </XDSText>
- </div>
-
- {/* Author */}
- <XDSStack
- direction="horizontal"
- gap={3}
- vAlign="center"
- style={{marginTop: 16}}>
- <XDSAvatar
- name={t.author}
- size={36}
- src={
- t.author === 'XDS Design'
- ? XDS_DESIGN_AVATAR
- : AVATAR_IMAGE
- }
- />
- <XDSStack direction="vertical">
- <XDSText type="supporting" color="secondary">
- Crafted by
- </XDSText>
- <XDSText
- type="body"
- style={{fontWeight: 600, fontSize: 16}}>
- {t.author}
- </XDSText>
- </XDSStack>
- </XDSStack>
- </div>
-
- {/* CTA buttons */}
- <XDSStack
- direction="vertical"
- gap={2}
- style={{marginTop: 32, position: 'relative'}}>
- <XDSButton
- variant="primary"
- label="Start crafting"
- size="lg"
- style={{width: '100%'}}
- onClick={() => {
- setUseTarget(previewTarget);
- setPreviewTarget(null);
- setPanelTab('configure');
- setChatOpen(true);
- }}
- />
- <div
- style={{
- display: 'flex',
- gap: 8,
- width: '100%',
- }}>
- <XDSButton
- variant="secondary"
- label="Use in your product"
- size="lg"
- style={{flex: 1}}
- onClick={() =>
- setCard4ShowAddPopover(!card4ShowAddPopover)
- }
- />
- <XDSTooltip content="Bookmark">
- <XDSButton
- label={card4Bookmarked ? '893' : '892'}
- variant="secondary"
- size="lg"
- isIconOnly
- icon={
- card4Bookmarked ? (
- <BookmarkFilledIcon />
- ) : (
- <BookmarkIcon />
- )
- }
- onClick={() => setCard4Bookmarked(prev => !prev)}
- />
- </XDSTooltip>
- </div>
- {card4ShowAddPopover && (
- <XDSCard
- style={{
- position: 'absolute',
- top: '100%',
- left: 0,
- right: 0,
- marginTop: 8,
- zIndex: 10,
- }}>
- <SharePopoverContent
- cliCommand={`npx xds template ${t.name.toLowerCase().replace(/\s+/g, '-')} ./my-project`}
- onClose={() => setCard4ShowAddPopover(false)}
- />
- </XDSCard>
- )}
- </XDSStack>
-
- {/* Themes — pinned grid */}
- <div style={{marginTop: 24}}>
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- }}>
- <XDSText type="body" style={{fontWeight: 600}}>
- Apply your themes
- </XDSText>
- <XDSPopover
- label="Browse themes"
- placement="below"
- alignment="end"
- width={480}
- isOpen={card4ThemeBrowse}
- onOpenChange={open => {
- setCard4ThemeBrowse(open);
- if (!open) setCard4ThemeSearch('');
- }}
- xstyle={popoverStyles.themeBrowse}
- content={
- <div
- style={{
- display: 'flex',
- flexDirection: 'column',
- gap: 16,
- }}>
- <div
- tabIndex={0}
- style={{
- position: 'absolute',
- opacity: 0,
- width: 0,
- height: 0,
- overflow: 'hidden',
- }}
- />
- <XDSTextInput
- label="Search"
- isLabelHidden
- placeholder="Search themes..."
- value={card4ThemeSearch}
- onChange={setCard4ThemeSearch}
- size="lg"
- startIcon={SearchIcon}
- />
- <div
- style={{
- maxHeight: 560,
- overflowY: 'auto',
- display: 'flex',
- flexDirection: 'column',
- gap: 16,
- }}>
- {(['official', 'community'] as const).map(
- category => {
- const entries = THEME_PICKER_ENTRIES.filter(
- e =>
- e.category === category &&
- e.name
- .toLowerCase()
- .includes(
- card4ThemeSearch.toLowerCase(),
- ),
- );
- if (entries.length === 0) return null;
- return (
- <div key={category}>
- <div style={{marginBottom: 8}}>
- <XDSText
- type="supporting"
- color="secondary">
- {category.charAt(0).toUpperCase() +
- category.slice(1)}
- </XDSText>
- </div>
- <div
- style={{
- display: 'grid',
- gridTemplateColumns: '1fr 1fr 1fr',
- gap: 8,
- }}>
- {entries.map(entry => {
- const isSelected =
- card4SelectedOption === entry.key;
- const isPinned =
- card4PinnedThemes.has(entry.key);
- const p = entry.preview;
- return (
- <div
- key={entry.key}
- style={{
- borderRadius: 12,
- overflow: 'hidden',
- cursor: 'pointer',
- border: isSelected
- ? '1.5px solid var(--color-accent)'
- : '1px solid var(--color-border-emphasized)',
- transition:
- 'border-color 0.15s ease',
- }}>
- <div
- onClick={() => {
- setCard4SelectedOption(
- entry.key,
- );
- setCard4ThemeBrowse(false);
- setCard4ThemeSearch('');
- }}
- style={{
- height: 100,
- backgroundColor: p.bg,
- display: 'flex',
- flexDirection: 'column',
- overflow: 'hidden',
- }}>
- <div
- style={{
- height: 14,
- backgroundColor:
- p.surface,
- borderBottom: `1px solid ${p.text}1A`,
- display: 'flex',
- alignItems: 'center',
- paddingInline: 8,
- gap: 4,
- }}>
- <div
- style={{
- width: 5,
- height: 5,
- borderRadius: '50%',
- backgroundColor:
- p.accent,
- }}
- />
- <div
- style={{
- width: 16,
- height: 2,
- borderRadius: 1,
- backgroundColor: p.text,
- opacity: 0.3,
- }}
- />
- </div>
- <div
- style={{
- flex: 1,
- padding: 8,
- display: 'flex',
- flexDirection: 'column',
- gap: 5,
- }}>
- <div
- style={{
- width: '65%',
- height: 4,
- borderRadius: 2,
- backgroundColor: p.text,
- opacity: 0.6,
- }}
- />
- <div
- style={{
- width: '45%',
- height: 3,
- borderRadius: 1.5,
- backgroundColor: p.text,
- opacity: 0.25,
- }}
- />
- <div
- style={{
- width: 28,
- height: 10,
- borderRadius: 4,
- backgroundColor:
- p.accent,
- marginTop: 'auto',
- }}
- />
- </div>
- </div>
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent:
- 'space-between',
- padding: '6px 8px',
- backgroundColor:
- 'var(--color-surface, #f5f5f5)',
- }}>
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- gap: 6,
- }}>
- {(() => {
- const Logo =
- BRAND_LOGOS[entry.key];
- return Logo ? (
- <Logo
- width={14}
- height={14}
- />
- ) : (
- <div
- style={{
- width: 14,
- height: 14,
- borderRadius: '50%',
- backgroundColor:
- entry.accent,
- }}
- />
- );
- })()}
- <XDSText
- type="supporting"
- style={{
- fontWeight: isSelected
- ? 600
- : 400,
- }}>
- {entry.name}
- </XDSText>
- </div>
- <div
- onClick={e => {
- e.stopPropagation();
- toggleCard4Pin(entry.key);
- }}
- style={{
- cursor: 'pointer',
- display: 'flex',
- padding: 2,
- }}>
- {isPinned ? (
- <StarFilledIcon
- width={14}
- height={14}
- style={{
- color:
- 'var(--color-text-primary, #111)',
- }}
- />
- ) : (
- <StarIcon
- width={14}
- height={14}
- style={{
- color:
- 'var(--color-secondary, #999)',
- }}
- />
- )}
- </div>
- </div>
- </div>
- );
- })}
- </div>
- </div>
- );
- },
- )}
- </div>
- </div>
- }>
- <XDSButton label="Browse" variant="ghost" size="sm" />
- </XDSPopover>
- </div>
- <div
- style={{
- display: 'grid',
- gridTemplateColumns: 'repeat(auto-fill, 44px)',
- gap: 8,
- marginTop: 16,
- }}>
- {THEME_PICKER_ENTRIES.filter(e =>
- card4PinnedThemes.has(e.key),
- ).map(entry => {
- const isSelected = card4SelectedOption === entry.key;
- const BrandLogo = BRAND_LOGOS[entry.key];
- return (
- <XDSTooltip key={entry.key} content={entry.name}>
- <div
- onClick={() =>
- setCard4SelectedOption(entry.key)
- }
- style={{
- width: 44,
- height: 44,
- borderRadius: 10,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- cursor: 'pointer',
- border: isSelected
- ? '1.5px solid var(--color-accent)'
- : '1px solid var(--color-border-emphasized)',
- backgroundColor: '#fff',
- transition: 'border-color 0.15s ease',
- }}>
- {BrandLogo ? (
- <BrandLogo width={28} height={28} />
- ) : (
- <div
- style={{
- width: 24,
- height: 24,
- borderRadius: '50%',
- backgroundColor: entry.accent,
- }}
- />
- )}
- </div>
- </XDSTooltip>
- );
- })}
- </div>
- </div>
- </XDSStack>
- </div>
-
- {/* More like this */}
- <div style={{padding: '0 32px'}}>
- <XDSHeading level={3}>More like this</XDSHeading>
- <div
- style={{
- display: 'grid',
- gridTemplateColumns: 'repeat(4, 1fr)',
- gap: 12,
- marginTop: 16,
- }}>
- {moreLikeThisImages.map(img => (
- <XDSCard
- key={img.originalIndex}
- padding={0}
- onClick={() => {
- setPreviewTransitioning(true);
- setTimeout(() => {
- setPreviewTarget(img.originalIndex);
- card4ScrollRef.current?.scrollTo({top: 0});
- setTimeout(
- () => setPreviewTransitioning(false),
- 50,
- );
- }, 250);
- }}
- style={{
- cursor: 'pointer',
- aspectRatio: '16/10',
- overflow: 'hidden',
- }}>
- <img
- src={img.src}
- alt={img.name}
- style={{
- width: '100%',
- height: '100%',
- objectFit: 'cover',
- objectPosition: 'top',
- display: 'block',
- opacity: previewTransitioning ? 0 : 1,
- transition: 'opacity 250ms ease',
- animation: previewTransitioning
- ? 'none'
- : 'previewFadeIn 300ms ease',
- }}
- />
- </XDSCard>
- ))}
- </div>
- </div>
-
- {/* Explore more */}
- <div style={{padding: '32px 32px 0'}}>
- <XDSHeading level={3}>Explore more</XDSHeading>
- <div
- style={{
- display: 'flex',
- flexWrap: 'wrap',
- gap: 8,
- marginTop: 16,
- opacity: previewTransitioning ? 0 : 1,
- transition: 'opacity 250ms ease',
- animation: previewTransitioning
- ? 'none'
- : 'previewFadeIn 300ms ease',
- }}>
- {[
- 'website',
- 'dashboard',
- 'admin panel',
- 'settings',
- 'form layout',
- 'data table',
- 'sidebar nav',
- 'landing page',
- 'e-commerce',
- 'documentation',
- 'profile page',
- ].map(tag => (
- <XDSToken
- key={tag}
- label={tag}
- xstyle={tokenStyles.pill}
- style={{
- backgroundColor: 'transparent',
- cursor: 'pointer',
- }}
- onClick={() => handleTokenClick(tag)}
- />
- ))}
- </div>
- </div>
-
- {/* Component used */}
- <div style={{padding: '32px 32px 32px'}}>
- <XDSHeading level={3}>Component used</XDSHeading>
- <div
- style={{
- display: 'flex',
- flexWrap: 'wrap',
- gap: 8,
- marginTop: 16,
- opacity: previewTransitioning ? 0 : 1,
- transition: 'opacity 250ms ease',
- animation: previewTransitioning
- ? 'none'
- : 'previewFadeIn 300ms ease',
- }}>
- {[
- 'XDSAppShell',
- 'XDSTopNav',
- 'XDSVStack',
- 'XDSHStack',
- 'XDSHeading',
- 'XDSText',
- 'XDSButton',
- 'XDSCard',
- 'XDSBadge',
- 'XDSAvatar',
- ].map(c => (
- <XDSToken
- key={c}
- label={c}
- xstyle={tokenStyles.outline}
- style={{
- backgroundColor: 'transparent',
- cursor: 'pointer',
- }}
- onClick={() => handleTokenClick(c)}
- />
- ))}
- </div>
- </div>
- </div>
- </XDSDialog>
+ onStartCrafting={() => {
+ viewBeforeEditorRef.current = activeView;
+ setUseTarget(previewTarget);
+ setPanelTab('configure');
+ setChatOpen(true);
+ }}
+ isBookmarked={card4Bookmarked}
+ onBookmarkToggle={() => setCard4Bookmarked(prev => !prev)}
+ moreLikeThis={moreLikeThisImages}
+ onMoreLikeThisClick={(mlItem) => setPreviewTarget(mlItem.key as number)}
+ exploreTags={[
+ 'website', 'dashboard', 'admin panel', 'settings',
+ 'form layout', 'data table', 'sidebar nav', 'landing page',
+ 'e-commerce', 'documentation', 'profile page',
+ ]}
+ onExploreTagClick={handleTokenClick}
+ componentTags={[
+ 'XDSAppShell', 'XDSTopNav', 'XDSVStack', 'XDSHStack',
+ 'XDSHeading', 'XDSText', 'XDSButton', 'XDSCard',
+ 'XDSBadge', 'XDSAvatar',
+ ]}
+ onComponentTagClick={handleTokenClick}
+ />
);
})()}
@@ -2170,46 +1557,28 @@ function DocsiteLandingTemplate() {
<XDSStack direction="vertical" gap={4} style={{padding: '8px 0'}}>
<XDSStack direction="horizontal" hAlign="between" vAlign="center">
<XDSStack direction="vertical" gap={1}>
- <XDSText type="body" style={{fontWeight: 600}}>
- Dark mode
- </XDSText>
- <XDSText type="supporting" color="secondary">
- Switch between light and dark appearance
- </XDSText>
+ <XDSText type="body" style={{fontWeight: 600}}>Dark mode</XDSText>
+ <XDSText type="supporting" color="secondary">Switch between light and dark appearance</XDSText>
</XDSStack>
<XDSButton
label={previewMode === 'dark' ? 'On' : 'Off'}
variant="secondary"
size="sm"
- onClick={() =>
- setPreviewMode(previewMode === 'dark' ? 'light' : 'dark')
- }
+ onClick={() => setPreviewMode(previewMode === 'dark' ? 'light' : 'dark')}
/>
</XDSStack>
<XDSDivider />
<XDSStack direction="horizontal" hAlign="between" vAlign="center">
<XDSStack direction="vertical" gap={1}>
- <XDSText type="body" style={{fontWeight: 600}}>
- Theme
- </XDSText>
- <XDSText type="supporting" color="secondary">
- Choose a visual theme for previews
- </XDSText>
+ <XDSText type="body" style={{fontWeight: 600}}>Theme</XDSText>
+ <XDSText type="supporting" color="secondary">Choose a visual theme for previews</XDSText>
</XDSStack>
<XDSDropdownMenu
- button={{
- label:
- previewTheme.charAt(0).toUpperCase() + previewTheme.slice(1),
- variant: 'secondary',
- size: 'sm',
- }}
+ button={{label: previewTheme.charAt(0).toUpperCase() + previewTheme.slice(1), variant: 'secondary', size: 'sm'}}
items={[
{label: 'Default', onClick: () => setPreviewTheme('default')},
{label: 'Neutral', onClick: () => setPreviewTheme('neutral')},
- {
- label: 'Brutalist',
- onClick: () => setPreviewTheme('brutalist'),
- },
+ {label: 'Brutalist', onClick: () => setPreviewTheme('brutalist')},
{label: 'Meta', onClick: () => setPreviewTheme('meta')},
{label: 'WhatsApp', onClick: () => setPreviewTheme('whatsapp')},
]}
@@ -2218,21 +1587,12 @@ function DocsiteLandingTemplate() {
<XDSDivider />
<XDSStack direction="horizontal" hAlign="between" vAlign="center">
<XDSStack direction="vertical" gap={1}>
- <XDSText type="body" style={{fontWeight: 600}}>
- Default sort
- </XDSText>
- <XDSText type="supporting" color="secondary">
- How templates are ordered by default
- </XDSText>
+ <XDSText type="body" style={{fontWeight: 600}}>Default sort</XDSText>
+ <XDSText type="supporting" color="secondary">How templates are ordered by default</XDSText>
</XDSStack>
<XDSDropdownMenu
button={{
- label:
- sortOption === 'trending'
- ? 'Trending'
- : sortOption === 'newest'
- ? 'Newest first'
- : 'Oldest first',
+ label: sortOption === 'trending' ? 'Trending' : sortOption === 'newest' ? 'Newest first' : 'Oldest first',
variant: 'secondary',
size: 'sm',
}}