Skip to content

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

TypeScript

feat(sandbox): reorganize pages into categorized card grid (#1040)

rubyycheung735b93b9b75b
diff --git a/apps/sandbox/public/previews/README.md b/apps/sandbox/public/previews/README.md
deleted file mode 100644
index 208d1c6817..0000000000
--- a/apps/sandbox/public/previews/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Preview screenshots go here. Capture with the sandbox running and save as <page-slug>.png.
diff --git a/apps/sandbox/scripts/capture-previews.mjs b/apps/sandbox/scripts/capture-previews.mjs
deleted file mode 100644
index 3ebfef16c5..0000000000
--- a/apps/sandbox/scripts/capture-previews.mjs
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env node
-/**
- * Capture preview screenshots for all sandbox pages.
- *
- * Usage:
- * # Start the sandbox dev server first:
- * yarn workspace @xds/sandbox dev
- *
- * # Then run this script:
- * node apps/sandbox/scripts/capture-previews.mjs [--base-url http://localhost:3000]
- *
- * The script navigates to each page registered in sandboxPages.ts,
- * waits for it to load, and saves a 16:10 screenshot to public/previews/.
- *
- * Requirements: npx playwright install chromium
- */
-
-import {chromium} from 'playwright';
-import {mkdir} from 'fs/promises';
-import {fileURLToPath} from 'url';
-import path from 'path';
-
-const __dirname = path.dirname(fileURLToPath(import.meta.url));
-const previewDir = path.resolve(__dirname, '../public/previews');
-
-const pages = [
- {slug: 'theme-editor', href: '/pages/theme-editor/'},
- {slug: 'shell-lab', href: '/pages/shell-lab/'},
- {slug: 'table-overview', href: '/pages/table-overview/'},
- {slug: 'navigation', href: '/pages/navigation/'},
- {slug: 'topnav-menu', href: '/pages/topnav-menu/'},
- {slug: 'mega-menu', href: '/pages/mega-menu/'},
- {slug: 'polymorphic-link', href: '/pages/polymorphic-link/'},
- {slug: 'example', href: '/pages/example/'},
-];
-
-const baseUrl = process.argv.includes('--base-url')
- ? process.argv[process.argv.indexOf('--base-url') + 1]
- : 'http://localhost:3000';
-
-async function main() {
- await mkdir(previewDir, {recursive: true});
-
- const browser = await chromium.launch();
- const context = await browser.newContext({
- viewport: {width: 1280, height: 800},
- deviceScaleFactor: 2,
- });
-
- console.log(`Capturing previews from ${baseUrl}...\n`);
-
- for (const page of pages) {
- const url = `${baseUrl}${page.href}`;
- const tab = await context.newPage();
-
- try {
- await tab.goto(url, {waitUntil: 'networkidle'});
- await tab.waitForTimeout(500);
-
- const outPath = path.join(previewDir, `${page.slug}.png`);
- await tab.screenshot({
- path: outPath,
- clip: {x: 0, y: 0, width: 1280, height: 800},
- });
- console.log(` ✓ ${page.slug}.png`);
- } catch (err) {
- console.log(` ✗ ${page.slug} — ${err.message}`);
- }
-
- await tab.close();
- }
-
- await browser.close();
- console.log(`\nDone. Screenshots saved to ${previewDir}`);
-}
-
-main().catch(console.error);
diff --git a/apps/sandbox/src/app/(sandbox)/[category]/CategoryContent.tsx b/apps/sandbox/src/app/(sandbox)/[category]/CategoryContent.tsx
index 77a2e298e8..527b9a0b76 100644
--- a/apps/sandbox/src/app/(sandbox)/[category]/CategoryContent.tsx
+++ b/apps/sandbox/src/app/(sandbox)/[category]/CategoryContent.tsx
@@ -29,7 +29,7 @@ export function CategoryContent({slug}: {slug: string}) {
<div
style={{
display: 'grid',
- gridTemplateColumns: 'repeat(3, 1fr)',
+ gridTemplateColumns: 'repeat(4, 1fr)',
gap: 20,
}}>
{category.pages.map(page => (
diff --git a/apps/sandbox/src/app/(sandbox)/page.tsx b/apps/sandbox/src/app/(sandbox)/page.tsx
index 4b60aee796..e026a94438 100644
--- a/apps/sandbox/src/app/(sandbox)/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/page.tsx
@@ -32,7 +32,7 @@ export default function Home() {
<div
style={{
display: 'grid',
- gridTemplateColumns: 'repeat(3, 1fr)',
+ gridTemplateColumns: 'repeat(4, 1fr)',
gap: 20,
}}>
{category.pages.map(page => (
diff --git a/apps/sandbox/src/app/ProjectCard.tsx b/apps/sandbox/src/app/ProjectCard.tsx
index b518e54e1c..00017138f7 100644
--- a/apps/sandbox/src/app/ProjectCard.tsx
+++ b/apps/sandbox/src/app/ProjectCard.tsx
@@ -33,22 +33,14 @@ export function ProjectCard({page}: {page: SandboxPage}) {
overflow: 'hidden',
flexShrink: 0,
}}>
- {page.preview ? (
- <img
- src={page.preview}
- alt={`Preview of ${page.name}`}
- style={{width: '100%', height: '100%', objectFit: 'cover'}}
- />
- ) : (
- <ImageIcon
- style={{
- width: 48,
- height: 48,
- opacity: 0.3,
- color: 'var(--color-text-disabled)',
- }}
- />
- )}
+ <ImageIcon
+ style={{
+ width: 48,
+ height: 48,
+ opacity: 0.3,
+ color: 'var(--color-text-disabled)',
+ }}
+ />
</div>
<div
style={{
diff --git a/apps/sandbox/src/app/SandboxNav.tsx b/apps/sandbox/src/app/SandboxNav.tsx
index a81d717073..466a399f6b 100644
--- a/apps/sandbox/src/app/SandboxNav.tsx
+++ b/apps/sandbox/src/app/SandboxNav.tsx
@@ -24,9 +24,9 @@ const categoryIcons: Record<
string,
React.ComponentType<React.SVGProps<SVGSVGElement>>
> = {
- tools: WrenchIcon,
- examples: BoxIcon,
+ 'components-patterns': BoxIcon,
templates: AppWindowIcon,
+ tools: WrenchIcon,
};
const styles = stylex.create({
diff --git a/apps/sandbox/src/app/sandboxPages.ts b/apps/sandbox/src/app/sandboxPages.ts
index b07133fa52..a8dc1c79a7 100644
--- a/apps/sandbox/src/app/sandboxPages.ts
+++ b/apps/sandbox/src/app/sandboxPages.ts
@@ -6,8 +6,7 @@
* 1. Create the page under the appropriate route group:
* - `src/app/(sandbox)/pages/<name>/page.tsx` for standard layout
* - `src/app/(fullscreen)/pages/<name>/page.tsx` for fullscreen
- * 2. Run `node scripts/capture-previews.mjs` to generate a screenshot
- * 3. Add an entry to the appropriate category below
+ * 2. Add an entry to the appropriate category below
*
* Note: hrefs use trailing slashes because the sandbox is a static export
* with `trailingSlash: true` in next.config.mjs.
@@ -20,8 +19,6 @@ export interface SandboxPage {
href: string;
/** Short description shown below the name */
description: string;
- /** Path to preview image in /public (optional — falls back to placeholder) */
- preview?: string;
}
export interface SandboxCategory {
@@ -37,44 +34,27 @@ export interface SandboxCategory {
export const categories: SandboxCategory[] = [
{
- label: 'Tools',
- slug: 'tools',
- description: 'Interactive tools for building and exploring XDS components.',
+ label: 'Components & Patterns',
+ slug: 'components-patterns',
+ description: 'Component demos, composition patterns, and interactive examples.',
pages: [
{
- name: 'Example Cards',
+ name: 'Card Examples',
href: '/pages/example-cards/',
description: 'XDS components showcased in realistic card compositions',
},
- {
- name: 'Theme Editor',
- href: '/pages/theme-editor/',
- description: 'Customize and preview XDS design tokens',
- },
- {
- name: 'Shell Lab',
- href: '/pages/shell-lab/',
- description: 'Experiment with app shell layouts and navigation',
- },
- {
+{
name: 'Table Overview',
href: '/pages/table-overview/',
description: 'Data table patterns and configurations',
},
- ],
- },
- {
- label: 'Examples',
- slug: 'examples',
- description: 'Component demos and composition patterns.',
- pages: [
{
- name: 'Navigation',
+ name: 'Side Navigation',
href: '/pages/navigation/',
description: 'Side navigation layout patterns',
},
{
- name: 'TopNav Menu',
+ name: 'Top Navigation',
href: '/pages/topnav-menu/',
description: 'Top navigation bar with menu integration',
},
@@ -84,12 +64,17 @@ export const categories: SandboxCategory[] = [
description: 'Full-width dropdown navigation menu',
},
{
- name: 'Polymorphic Link',
+ name: 'Link Patterns',
href: '/pages/polymorphic-link/',
description: 'Flexible link component with router integration',
},
{
- name: 'Example',
+ name: 'App Shell',
+ href: '/pages/shell-lab/',
+ description: 'Experiment with app shell layouts and navigation',
+ },
+ {
+ name: 'Component Overview',
href: '/pages/example/',
description: 'General component composition examples',
},
@@ -125,4 +110,16 @@ export const categories: SandboxCategory[] = [
},
],
},
+ {
+ label: 'Tools',
+ slug: 'tools',
+ description: 'Interactive tools for building and exploring XDS components.',
+ pages: [
+ {
+ name: 'Theme Editor',
+ href: '/pages/theme-editor/',
+ description: 'Customize and preview XDS design tokens',
+ },
+ ],
+ },
];