An open source design system that's fully customizable and agent ready
TypeScript
feat(templates): add Table Page (Matcha Store) template (#2149)
Ted McDonaldd536cf819feb
diff --git a/packages/cli/templates/pages/table-page-chart/page.tsx b/packages/cli/templates/pages/table-page-chart/page.tsxnew file mode 100644index 0000000000..671cc0ff02--- /dev/null+++ b/packages/cli/templates/pages/table-page-chart/page.tsx@@ -0,0 +1,572 @@+'use client';++import {XDSAppShell} from '@xds/core/AppShell';+import {XDSVStack, XDSHStack, XDSStackItem} from '@xds/core/Layout';+import {XDSText, XDSHeading} from '@xds/core/Text';+import {XDSButton} from '@xds/core/Button';+import {XDSIconButton} from '@xds/core/IconButton';+import {XDSIcon} from '@xds/core/Icon';+import {XDSBadge} from '@xds/core/Badge';+import {XDSLink} from '@xds/core/Link';+import {XDSThumbnail} from '@xds/core/Thumbnail';+import {XDSTable, proportional, pixel} from '@xds/core/Table';+import type {XDSTableColumn} from '@xds/core/Table';+import {+ XDSChartV2 as XDSChart,+ XDSChartGrid,+ XDSChartAxis,+ area,+ line,+} from '@xds/lab';+import {+ FunnelIcon,+ ArrowDownTrayIcon,+ PlusIcon,+} from '@heroicons/react/24/outline';++// ============= DATA =============++type ProductCategory = 'Matcha' | 'Coffee' | 'Tea' | 'Smoothie' | 'Specialty';++interface OrderRow extends Record<string, unknown> {+ id: string;+ customer: string;+ email: string;+ product: string;+ category: ProductCategory;+ imageIndex: number;+ amount: number;+ status: 'completed' | 'processing' | 'shipped' | 'refunded';+ date: string;+}++// matcha-product-{1..6} from xds_oss asset set+const PRODUCTS = [+ {+ name: 'Ceremonial Matcha Latte',+ category: 'Matcha' as ProductCategory,+ image: 'https://lookaside.facebook.com/assets/xds_oss/matcha-product-1.png',+ price: 6,+ },+ {+ name: 'Oat Milk Cappuccino',+ category: 'Coffee' as ProductCategory,+ image: 'https://lookaside.facebook.com/assets/xds_oss/matcha-product-2.png',+ price: 5,+ },+ {+ name: 'Jasmine Green Tea',+ category: 'Tea' as ProductCategory,+ image: 'https://lookaside.facebook.com/assets/xds_oss/matcha-product-3.png',+ price: 4,+ },+ {+ name: 'Mango Matcha Smoothie',+ category: 'Smoothie' as ProductCategory,+ image: 'https://lookaside.facebook.com/assets/xds_oss/matcha-product-4.png',+ price: 8,+ },+ {+ name: 'Hojicha Latte',+ category: 'Specialty' as ProductCategory,+ image: 'https://lookaside.facebook.com/assets/xds_oss/matcha-product-5.png',+ price: 7,+ },+ {+ name: 'Iced Yuzu Matcha',+ category: 'Matcha' as ProductCategory,+ image: 'https://lookaside.facebook.com/assets/xds_oss/matcha-product-6.png',+ price: 7,+ },+];++const orders: OrderRow[] = [+ {+ id: 'ORD-1001',+ customer: 'Sarah Chen',+ email: '[email protected]',+ product: PRODUCTS[0].name,+ category: PRODUCTS[0].category,+ imageIndex: 0,+ amount: 6,+ status: 'completed',+ date: '2025-01-15',+ },+ {+ id: 'ORD-1002',+ customer: 'Marcus Rivera',+ email: '[email protected]',+ product: PRODUCTS[1].name,+ category: PRODUCTS[1].category,+ imageIndex: 1,+ amount: 5,+ status: 'completed',+ date: '2025-01-15',+ },+ {+ id: 'ORD-1003',+ customer: 'Aisha Patel',+ email: '[email protected]',+ product: PRODUCTS[2].name,+ category: PRODUCTS[2].category,+ imageIndex: 2,+ amount: 4,+ status: 'shipped',+ date: '2025-01-14',+ },+ {+ id: 'ORD-1004',+ customer: "James O'Brien",+ email: '[email protected]',+ product: PRODUCTS[3].name,+ category: PRODUCTS[3].category,+ imageIndex: 3,+ amount: 8,+ status: 'processing',+ date: '2025-01-14',+ },+ {+ id: 'ORD-1005',+ customer: 'Yuki Tanaka',+ email: '[email protected]',+ product: PRODUCTS[4].name,+ category: PRODUCTS[4].category,+ imageIndex: 4,+ amount: 7,+ status: 'completed',+ date: '2025-01-13',+ },+ {+ id: 'ORD-1006',+ customer: 'Elena Volkov',+ email: '[email protected]',+ product: PRODUCTS[5].name,+ category: PRODUCTS[5].category,+ imageIndex: 5,+ amount: 7,+ status: 'refunded',+ date: '2025-01-13',+ },+ {+ id: 'ORD-1007',+ customer: 'David Kim',+ email: '[email protected]',+ product: PRODUCTS[0].name,+ category: PRODUCTS[0].category,+ imageIndex: 0,+ amount: 6,+ status: 'completed',+ date: '2025-01-12',+ },+ {+ id: 'ORD-1008',+ customer: 'Fatima Al-Rashid',+ email: '[email protected]',+ product: PRODUCTS[1].name,+ category: PRODUCTS[1].category,+ imageIndex: 1,+ amount: 5,+ status: 'shipped',+ date: '2025-01-12',+ },+ {+ id: 'ORD-1009',+ customer: 'Lucas Andersson',+ email: '[email protected]',+ product: PRODUCTS[2].name,+ category: PRODUCTS[2].category,+ imageIndex: 2,+ amount: 4,+ status: 'completed',+ date: '2025-01-11',+ },+ {+ id: 'ORD-1010',+ customer: 'Priya Sharma',+ email: '[email protected]',+ product: PRODUCTS[3].name,+ category: PRODUCTS[3].category,+ imageIndex: 3,+ amount: 8,+ status: 'processing',+ date: '2025-01-11',+ },+ {+ id: 'ORD-1011',+ customer: 'Noah Williams',+ email: '[email protected]',+ product: PRODUCTS[4].name,+ category: PRODUCTS[4].category,+ imageIndex: 4,+ amount: 7,+ status: 'completed',+ date: '2025-01-10',+ },+ {+ id: 'ORD-1012',+ customer: 'Sofia Garcia',+ email: '[email protected]',+ product: PRODUCTS[5].name,+ category: PRODUCTS[5].category,+ imageIndex: 5,+ amount: 7,+ status: 'completed',+ date: '2025-01-10',+ },+ {+ id: 'ORD-1013',+ customer: 'Oliver Brown',+ email: '[email protected]',+ product: PRODUCTS[0].name,+ category: PRODUCTS[0].category,+ imageIndex: 0,+ amount: 6,+ status: 'shipped',+ date: '2025-01-09',+ },+ {+ id: 'ORD-1014',+ customer: 'Mei Lin',+ email: '[email protected]',+ product: PRODUCTS[1].name,+ category: PRODUCTS[1].category,+ imageIndex: 1,+ amount: 5,+ status: 'completed',+ date: '2025-01-09',+ },+ {+ id: 'ORD-1015',+ customer: 'Hassan Ahmed',+ email: '[email protected]',+ product: PRODUCTS[2].name,+ category: PRODUCTS[2].category,+ imageIndex: 2,+ amount: 4,+ status: 'refunded',+ date: '2025-01-08',+ },+ {+ id: 'ORD-1016',+ customer: 'Isabella Rossi',+ email: '[email protected]',+ product: PRODUCTS[3].name,+ category: PRODUCTS[3].category,+ imageIndex: 3,+ amount: 8,+ status: 'completed',+ date: '2025-01-08',+ },+ {+ id: 'ORD-1017',+ customer: 'Liam Murphy',+ email: '[email protected]',+ product: PRODUCTS[4].name,+ category: PRODUCTS[4].category,+ imageIndex: 4,+ amount: 7,+ status: 'processing',+ date: '2025-01-07',+ },+ {+ id: 'ORD-1018',+ customer: 'Chloe Dubois',+ email: '[email protected]',+ product: PRODUCTS[5].name,+ category: PRODUCTS[5].category,+ imageIndex: 5,+ amount: 7,+ status: 'completed',+ date: '2025-01-07',+ },+ {+ id: 'ORD-1019',+ customer: 'Andre Santos',+ email: '[email protected]',+ product: PRODUCTS[0].name,+ category: PRODUCTS[0].category,+ imageIndex: 0,+ amount: 6,+ status: 'shipped',+ date: '2025-01-06',+ },+ {+ id: 'ORD-1020',+ customer: 'Nina Johansson',+ email: '[email protected]',+ product: PRODUCTS[1].name,+ category: PRODUCTS[1].category,+ imageIndex: 1,+ amount: 5,+ status: 'completed',+ date: '2025-01-06',+ },+ {+ id: 'ORD-1021',+ customer: 'Raj Kapoor',+ email: '[email protected]',+ product: PRODUCTS[2].name,+ category: PRODUCTS[2].category,+ imageIndex: 2,+ amount: 4,+ status: 'completed',+ date: '2025-01-05',+ },+ {+ id: 'ORD-1022',+ customer: 'Emma Thompson',+ email: '[email protected]',+ product: PRODUCTS[3].name,+ category: PRODUCTS[3].category,+ imageIndex: 3,+ amount: 8,+ status: 'completed',+ date: '2025-01-05',+ },+ {+ id: 'ORD-1023',+ customer: 'Carlos Mendez',+ email: '[email protected]',+ product: PRODUCTS[4].name,+ category: PRODUCTS[4].category,+ imageIndex: 4,+ amount: 7,+ status: 'shipped',+ date: '2025-01-04',+ },+ {+ id: 'ORD-1024',+ customer: 'Zoe Mitchell',+ email: '[email protected]',+ product: PRODUCTS[5].name,+ category: PRODUCTS[5].category,+ imageIndex: 5,+ amount: 7,+ status: 'processing',+ date: '2025-01-04',+ },+ {+ id: 'ORD-1025',+ customer: 'Henrik Larsson',+ email: '[email protected]',+ product: PRODUCTS[0].name,+ category: PRODUCTS[0].category,+ imageIndex: 0,+ amount: 6,+ status: 'completed',+ date: '2025-01-03',+ },+ {+ id: 'ORD-1026',+ customer: 'Amara Okafor',+ email: '[email protected]',+ product: PRODUCTS[1].name,+ category: PRODUCTS[1].category,+ imageIndex: 1,+ amount: 5,+ status: 'completed',+ date: '2025-01-03',+ },+ {+ id: 'ORD-1027',+ customer: 'Leo Fischer',+ email: '[email protected]',+ product: PRODUCTS[2].name,+ category: PRODUCTS[2].category,+ imageIndex: 2,+ amount: 4,+ status: 'completed',+ date: '2025-01-02',+ },+ {+ id: 'ORD-1028',+ customer: 'Maya Petrov',+ email: '[email protected]',+ product: PRODUCTS[3].name,+ category: PRODUCTS[3].category,+ imageIndex: 3,+ amount: 8,+ status: 'shipped',+ date: '2025-01-02',+ },+ {+ id: 'ORD-1029',+ customer: 'Tomás Herrera',+ email: '[email protected]',+ product: PRODUCTS[4].name,+ category: PRODUCTS[4].category,+ imageIndex: 4,+ amount: 7,+ status: 'completed',+ date: '2025-01-01',+ },+ {+ id: 'ORD-1030',+ customer: 'Grace Nakamura',+ email: '[email protected]',+ product: PRODUCTS[5].name,+ category: PRODUCTS[5].category,+ imageIndex: 5,+ amount: 7,+ status: 'completed',+ date: '2025-01-01',+ },+];++const revenueData = [+ {date: 'Jan 1', revenue: 84},+ {date: 'Jan 2', revenue: 72},+ {date: 'Jan 3', revenue: 91},+ {date: 'Jan 4', revenue: 68},+ {date: 'Jan 5', revenue: 105},+ {date: 'Jan 6', revenue: 118},+ {date: 'Jan 7', revenue: 96},+ {date: 'Jan 8', revenue: 132},+ {date: 'Jan 9', revenue: 110},+ {date: 'Jan 10', revenue: 98},+ {date: 'Jan 11', revenue: 125},+ {date: 'Jan 12', revenue: 142},+ {date: 'Jan 13', revenue: 108},+ {date: 'Jan 14', revenue: 156},+ {date: 'Jan 15', revenue: 138},+];++const statusColor: Record<string, 'green' | 'blue' | 'orange' | 'red'> = {+ completed: 'green',+ shipped: 'blue',+ processing: 'orange',+ refunded: 'red',+};++const columns: XDSTableColumn<OrderRow>[] = [+ {+ key: 'id',+ header: 'Order',+ width: pixel(110),+ renderCell: (item: OrderRow) => (+ <XDSLink href="#" isStandalone>+ {item.id}+ </XDSLink>+ ),+ },+ {+ key: 'product',+ header: 'Product',+ width: proportional(3),+ renderCell: (item: OrderRow) => (+ <XDSHStack gap={3} vAlign="center">+ <XDSThumbnail+ src={PRODUCTS[item.imageIndex].image}+ alt={item.product}+ label={item.product}+ style={{width: 36, height: 36, flexShrink: 0}}+ />+ <XDSVStack gap={0}>+ <XDSText type="body">{item.product}</XDSText>+ <XDSText type="supporting" color="secondary">+ {item.category}+ </XDSText>+ </XDSVStack>+ </XDSHStack>+ ),+ },+ {+ key: 'amount',+ header: 'Amount',+ width: pixel(90),+ renderCell: (item: OrderRow) => (+ <XDSText type="body">${item.amount}</XDSText>+ ),+ },+ {+ key: 'customer',+ header: 'Customer',+ width: proportional(2),+ renderCell: (item: OrderRow) => (+ <XDSText type="body">{item.customer}</XDSText>+ ),+ },+ {+ key: 'email',+ header: 'Email',+ width: proportional(2),+ renderCell: (item: OrderRow) => <XDSText type="body">{item.email}</XDSText>,+ },+ {+ key: 'status',+ header: 'Status',+ width: pixel(120),+ renderCell: (item: OrderRow) => (+ <XDSBadge+ label={item.status.charAt(0).toUpperCase() + item.status.slice(1)}+ variant={statusColor[item.status]}+ />+ ),+ },+ {+ key: 'date',+ header: 'Date',+ width: pixel(110),+ renderCell: (item: OrderRow) => <XDSText type="body">{item.date}</XDSText>,+ },+];++// ============= PAGE =============++export default function TablePageChartTemplate() {+ return (+ <XDSAppShell variant="elevated" contentPadding={3} height="auto">+ <XDSVStack gap={4}>+ <XDSHStack gap={2} vAlign="center">+ <XDSStackItem size="fill">+ <XDSHeading level={1}>Sales</XDSHeading>+ </XDSStackItem>+ <XDSIconButton+ label="Filter"+ icon={<XDSIcon icon={FunnelIcon} size="sm" />}+ variant="ghost"+ />+ <XDSIconButton+ label="Export"+ icon={<XDSIcon icon={ArrowDownTrayIcon} size="sm" />}+ variant="ghost"+ />+ <XDSButton+ label="New order"+ icon={<XDSIcon icon={PlusIcon} size="sm" />}+ />+ </XDSHStack>++ <XDSChart+ data={revenueData}+ xKey="date"+ series={[+ area('revenue', {color: '#14b8a6', gradient: true}),+ line('revenue', {color: '#14b8a6'}),+ ]}+ grid={<XDSChartGrid horizontal />}+ axes={+ <>+ <XDSChartAxis position="bottom" />+ <XDSChartAxis+ position="left"+ tickFormat={(v: unknown) => `$${v}`}+ />+ </>+ }+ height={280}+ margin={{left: 40, right: 10, top: 10, bottom: 30}}+ />++ <XDSTable<OrderRow>+ data={orders}+ columns={columns}+ idKey="id"+ density="balanced"+ dividers="rows"+ hasHover+ />+ </XDSVStack>+ </XDSAppShell>+ );+}diff --git a/packages/cli/templates/pages/table-page-chart/template.doc.mjs b/packages/cli/templates/pages/table-page-chart/template.doc.mjsnew file mode 100644index 0000000000..946cb86d22--- /dev/null+++ b/packages/cli/templates/pages/table-page-chart/template.doc.mjs@@ -0,0 +1,8 @@+/** @type {import('../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'page',+ name: 'Table Page (Matcha Store)',+ description:+ 'Matcha store sales data table with a revenue area chart and product thumbnails.',+ isReady: true,+};