Skip to content

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

TypeScript

docsite: rebuild themes gallery with rich per-theme previews (#2409)

rubyycheungb9c399e27ca3
diff --git a/apps/docsite/package.json b/apps/docsite/package.json
index e7710b854b..9ede02104a 100644
--- a/apps/docsite/package.json
+++ b/apps/docsite/package.json
@@ -18,11 +18,13 @@
"@stylexjs/stylex": "^0.18.3",
"@xds/cli": "*",
"@xds/core": "*",
+ "@xds/theme-butter": "*",
"@xds/theme-default": "*",
"@xds/theme-gothic": "*",
"@xds/theme-matcha": "*",
"@xds/theme-neutral": "*",
"@xds/theme-stone": "*",
+ "@xds/theme-y2k": "*",
"lz-string": "^1.5.0",
"monaco-editor": "^0.55.1",
"next": "^15.5.16",
diff --git a/apps/docsite/public/theme-butter-preview.png b/apps/docsite/public/theme-butter-preview.png
new file mode 100644
index 0000000000..eb65a550f7
Binary files /dev/null and b/apps/docsite/public/theme-butter-preview.png differ
diff --git a/apps/docsite/public/theme-gothic-preview.png b/apps/docsite/public/theme-gothic-preview.png
new file mode 100644
index 0000000000..e3e509330a
Binary files /dev/null and b/apps/docsite/public/theme-gothic-preview.png differ
diff --git a/apps/docsite/public/theme-matcha-preview.png b/apps/docsite/public/theme-matcha-preview.png
new file mode 100644
index 0000000000..908798ebef
Binary files /dev/null and b/apps/docsite/public/theme-matcha-preview.png differ
diff --git a/apps/docsite/public/theme-neutral-preview.png b/apps/docsite/public/theme-neutral-preview.png
new file mode 100644
index 0000000000..d4bfb6860d
Binary files /dev/null and b/apps/docsite/public/theme-neutral-preview.png differ
diff --git a/apps/docsite/public/theme-stone-preview.png b/apps/docsite/public/theme-stone-preview.png
new file mode 100644
index 0000000000..60800e84c3
Binary files /dev/null and b/apps/docsite/public/theme-stone-preview.png differ
diff --git a/apps/docsite/public/theme-y2k-preview.png b/apps/docsite/public/theme-y2k-preview.png
new file mode 100644
index 0000000000..635ddcb24b
Binary files /dev/null and b/apps/docsite/public/theme-y2k-preview.png differ
diff --git a/apps/docsite/scripts/generate-data.mjs b/apps/docsite/scripts/generate-data.mjs
index 42f015ed7f..6a3049a3b8 100644
--- a/apps/docsite/scripts/generate-data.mjs
+++ b/apps/docsite/scripts/generate-data.mjs
@@ -909,6 +909,8 @@ function generateThemeRegistry(packages) {
import type {XDSDefinedTheme} from '@xds/core/theme';
export const themeObjects: Record<string, XDSDefinedTheme> = {};
`);
+ // Empty CSS aggregator so the globals.css @import doesn't 404.
+ writeThemesCss('');
return 0;
}
@@ -933,9 +935,31 @@ ${entries}
};
`;
writeRegistry('themeRegistry.ts', content);
+
+ // CSS aggregator — globals.css imports this single file so adding a
+ // new theme package no longer requires hand-editing globals.css.
+ const cssImports = themePackages
+ .map(p => `@import "${p.name}/theme.css";`)
+ .join('\n');
+ writeThemesCss(cssImports);
+
return themePackages.length;
}
+// Writes the aggregated themes.css alongside the TS registries. It's
+// imported once from globals.css and re-generated every time the theme
+// package list changes.
+function writeThemesCss(body) {
+ const outPath = path.join(OUT_DIR, 'themes.css');
+ const content = `/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+/* Auto-generated by scripts/generate-data.mjs — do not edit */
+
+${body}
+`;
+ fs.writeFileSync(outPath, content, 'utf-8');
+ console.log(` wrote ${path.relative(REPO_ROOT, outPath)}`);
+}
+
// ── 7. Showcase Registry ───────────────────────────────────────────────
function generateShowcaseRegistry() {
diff --git a/apps/docsite/src/app/(docs)/components/page.tsx b/apps/docsite/src/app/(docs)/components/page.tsx
index f598af2b01..a8e4785b2e 100644
--- a/apps/docsite/src/app/(docs)/components/page.tsx
+++ b/apps/docsite/src/app/(docs)/components/page.tsx
@@ -79,15 +79,15 @@ export default function ComponentsGalleryPage() {
for (const comp of coreComponents) {
// Skip components explicitly hidden from overview
- if (comp.isHiddenFromOverview) continue;
+ if (comp.isHiddenFromOverview) {continue;}
// Skip hidden components
- if (comp.hidden) continue;
+ if (comp.hidden) {continue;}
// Skip hooks (they appear in the Utilities section)
- if (comp.name.startsWith('use')) continue;
+ if (comp.name.startsWith('use')) {continue;}
// Skip components without a category
- if (!comp.category) continue;
+ if (!comp.category) {continue;}
// Skip utilities group
- if (comp.group === 'Utilities') continue;
+ if (comp.group === 'Utilities') {continue;}
items.push({
name: comp.name,
@@ -105,7 +105,7 @@ export default function ComponentsGalleryPage() {
/** Filtered items based on search query */
const filteredItems = useMemo(() => {
const q = query.trim().toLowerCase();
- if (!q) return categorizedItems;
+ if (!q) {return categorizedItems;}
return categorizedItems.filter(
item =>
item.name.toLowerCase().includes(q) ||
@@ -122,7 +122,7 @@ export default function ComponentsGalleryPage() {
}
for (const item of filteredItems) {
const list = map.get(item.category);
- if (list) list.push(item);
+ if (list) {list.push(item);}
}
return map;
}, [filteredItems]);
@@ -152,7 +152,7 @@ export default function ComponentsGalleryPage() {
{CATEGORIES.map(cat => {
const items = groupedByCategory.get(cat) ?? [];
- if (items.length === 0) return null;
+ if (items.length === 0) {return null;}
return (
<XDSVStack key={cat} gap={4} xstyle={styles.categorySection}>
diff --git a/apps/docsite/src/app/(site)/_landing/ThemingShowcase.tsx b/apps/docsite/src/app/(site)/_landing/ThemingShowcase.tsx
index 3f813611a7..498d26e1aa 100644
--- a/apps/docsite/src/app/(site)/_landing/ThemingShowcase.tsx
+++ b/apps/docsite/src/app/(site)/_landing/ThemingShowcase.tsx
@@ -165,7 +165,7 @@ function ShowcaseHeading() {
<XDSText type="body" color="secondary" xstyle={styles.fillWidth}>
Astryx makes it effortless. Customize color, typography, radius, and
motion at the token level
- <br />— your brand, no fork required.
+ <br />— your brand, no rewrites needed.
</XDSText>
<XDSHStack gap={2} align="center">
<XDSLink type="body" href="/themes" hasUnderline>
diff --git a/apps/docsite/src/app/(site)/themes/page.tsx b/apps/docsite/src/app/(site)/themes/page.tsx
index eda1864054..afe802b89e 100644
--- a/apps/docsite/src/app/(site)/themes/page.tsx
+++ b/apps/docsite/src/app/(site)/themes/page.tsx
@@ -8,114 +8,223 @@
import * as stylex from '@stylexjs/stylex';
import {XDSText} from '@xds/core/Text';
-import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {XDSHStack, XDSVStack} from '@xds/core/Layout';
import {XDSSection} from '@xds/core/Section';
-import {XDSGrid} from '@xds/core/Grid';
import {XDSCard} from '@xds/core/Card';
import {XDSButton} from '@xds/core/Button';
-import {XDSOverlay} from '@xds/core/Overlay';
import {XDSTheme} from '@xds/core/theme';
+import {
+ spacingDefaults,
+ radiusDefaults,
+ textSizeDefaults,
+} from '@xds/core/theme/tokens.stylex';
import {useThemeMode} from '../../providers';
import {packages} from '../../../generated/packageRegistry';
import {themeObjects} from '../../../generated/themeRegistry';
import {ThemeShowcaseTile} from '../../../components/ThemeShowcaseTile';
-const themePackages = packages.filter(p => p.name.includes('theme-'));
+// Re-set XDS's structural tokens (spacing, radii, font sizes) back to
+// the defaults exported from @xds/core. Each <XDSTheme> wrapper sets a
+// full token bundle including these structural slots, which would make
+// gallery cards visually inconsistent (different button heights, badge
+// sizes, banner padding, etc.). Resetting only the structural tokens —
+// while leaving --color-* and --font-family-* alone — keeps the
+// layout uniform but lets each card showcase its true palette and
+// typography. Values flow from tokens.stylex.ts so this stays in sync
+// with the XDS scale automatically.
+const STRUCTURAL_TOKEN_OVERRIDES: React.CSSProperties = {
+ ...spacingDefaults,
+ ...radiusDefaults,
+ ...textSizeDefaults,
+ height: '100%',
+} as React.CSSProperties;
+
+// Gallery order — themes are sorted by visual closeness, starting
+// from the most restrained / brand-neutral and ending at the most
+// expressive / brand-distinct. Any theme not in this list falls to
+// the end (alphabetical) so the gallery never silently drops a
+// newly-added theme.
+const THEME_ORDER: ReadonlyArray<string> = [
+ '@xds/theme-neutral',
+ '@xds/theme-stone',
+ '@xds/theme-gothic',
+ '@xds/theme-matcha',
+ '@xds/theme-y2k',
+ '@xds/theme-butter',
+];
+
+const themePackages = packages
+ .filter(p => p.name.includes('theme-') && p.name !== '@xds/theme-default')
+ .sort((a, b) => {
+ const ai = THEME_ORDER.indexOf(a.name);
+ const bi = THEME_ORDER.indexOf(b.name);
+ // Unknown themes go to the end, sorted alphabetically among themselves.
+ if (ai === -1 && bi === -1) {
+ return a.name.localeCompare(b.name);
+ }
+ if (ai === -1) {
+ return 1;
+ }
+ if (bi === -1) {
+ return -1;
+ }
+ return ai - bi;
+ });
+
+// Max viewport-px the gallery centers in. Sized for the 2-column grid:
+// at full width that gives ~785px per card after the gap, fitting the
+// rich theme preview composition.
+const GALLERY_MAX_WIDTH = 1600;
+
+// Minimum px-width a single card needs to render side-by-side internally
+// (image + heading + type samples + swatches + actions on the left,
+// input + table + controls + banners on the right). Drives the grid's
+// auto-fill breakpoint: below ~2 × this value (viewport) the grid drops
+// from 2 cards to 1. The tile itself stacks to a single column below
+// TILE_STACK_BREAKPOINT (defined in ThemeShowcaseTile.tsx).
+const CARD_MIN_WIDTH = 760;
const styles = stylex.create({
+ // Wraps the gallery so it caps at a sane max width and centers in
+ // the viewport. We do this on a plain wrapper instead of via
+ // XDSSection's maxWidth prop because the section's negative-inline-
+ // margin styles (used to break out of container padding elsewhere)
+ // beat any margin-inline:auto we try to set on the section itself.
+ //
+ // 1600px is sized for the 2-column grid: at full width that gives
+ // ~785px per card after the gap, which fits the rich theme preview
+ // composition (image, type samples, swatches, actions on the left
+ // + input, progress, controls, table, banners on the right).
+ galleryWrap: {
+ maxWidth: GALLERY_MAX_WIDTH,
+ marginInline: 'auto',
+ width: '100%',
+ },
+ // Custom CSS Grid in place of XDSGrid so we control the column
+ // template directly. The minmax() uses min(760px, 100%) for the
+ // minimum so cells shrink to fit the viewport on mobile instead
+ // of forcing horizontal overflow at <760px viewport (which is
+ // what XDSGrid's plain minmax(760px, ...) does).
+ //
+ // Max column count of 2 enforced via the calc() upper bound:
+ // (100% - gap) / 2 prevents tracks from being narrower than half.
+ grid: {
+ display: 'grid',
+ gap: 'var(--spacing-4)',
+ justifyContent: 'center',
+ gridTemplateColumns: `repeat(auto-fill, minmax(min(${CARD_MIN_WIDTH}px, 100%), calc((100% - var(--spacing-4)) / 2)))`,
+ },
heroTitle: {
textAlign: 'center' as const,
},
cardImage: {
display: 'block',
width: '100%',
- aspectRatio: '16/10',
+ aspectRatio: '4/3',
backgroundColor: 'var(--color-background-muted)',
borderRadius: 'var(--radius-container)',
},
- overlayInner: {
- display: 'flex',
- flexDirection: 'column' as const,
- justifyContent: 'flex-end',
- alignItems: 'flex-start',
+ // Fills the gallery card cell at 100% height so the inner tile
+ // (and its two columns) can stretch to match the tallest card
+ // in the row. CSS Grid auto-stretches cells in the same row to
+ // the tallest cell; this rule + the parent chain having
+ // `height: 100%` lets the stretch propagate all the way down.
+ // overflow:hidden protects against any descendant component
+ // (long text, wide table cells) bleeding past the gallery card's
+ // rounded edges at narrow viewports.
+ previewFrame: {
+ height: '100%',
+ overflow: 'hidden',
+ },
+
+ // The outer XDSCard sized to fill its grid cell at full height
+ // so every card in a row matches the tallest. Without this, the
+ // XDSCard sizes to content and the grid stretch doesn't reach
+ // the inner tile.
+ cardFill: {
height: '100%',
- width: '100%',
- padding: 8,
},
});
export default function ThemesPage() {
const {mode} = useThemeMode();
return (
- <XDSSection maxWidth="xl" padding={6}>
- <XDSVStack gap={6}>
- <XDSVStack gap={2} style={{alignItems: 'center'}}>
- <XDSText type="display-2" xstyle={styles.heroTitle}>
- Themes
- </XDSText>
- <XDSText type="body" color="secondary" xstyle={styles.heroTitle}>
- Swap the visual identity of your app with a single theme package.
- </XDSText>
- </XDSVStack>
+ <div {...stylex.props(styles.galleryWrap)}>
+ <XDSSection padding={6}>
+ <XDSVStack gap={10}>
+ <XDSVStack gap={4} hAlign="center">
+ <XDSVStack gap={2} hAlign="center">
+ <XDSText type="display-2" xstyle={styles.heroTitle}>
+ Themes built for different apps
+ </XDSText>
+ <XDSText type="body" color="secondary" xstyle={styles.heroTitle}>
+ Browse pre-built themes — each a complete look spanning colors,
+ typography, motion, and spacing.
+ <br />
+ Install one as-is, or use it as a starting point for your own.
+ </XDSText>
+ </XDSVStack>
+ {/* Hero CTAs — two paths into theming. The primary
+ "Build a custom theme" sends users to the live
+ playground editor where they can fork any theme
+ and tweak tokens with instant visual feedback;
+ the secondary "How theming works" sends users to
+ the docs for the defineTheme + CLI wizard
+ walkthrough. */}
+ <XDSHStack gap={2} hAlign="center" wrap="wrap">
+ <XDSButton
+ variant="primary"
+ size="lg"
+ label="Build a custom theme"
+ href="/playground"
+ />
+ <XDSButton
+ variant="secondary"
+ size="lg"
+ label="How theming works"
+ href="/docs/theme"
+ />
+ </XDSHStack>
+ </XDSVStack>
- <XDSGrid columns={{minWidth: 300, repeat: 'fill'}} gap={4} rowGap={6}>
- {themePackages.map(pkg => {
- const theme = themeObjects[pkg.name];
- const label = pkg.displayName.replace('Theme: ', '');
- return (
- <XDSCard key={pkg.name} padding={0}>
- <XDSOverlay
- showOn="hover"
- scrim="dark"
- content={
- <div {...stylex.props(styles.overlayInner)}>
- <XDSVStack gap={2}>
- <XDSVStack gap={0.5}>
- <XDSText
- type="body"
- weight="bold"
- style={{color: '#fff'}}>
- {pkg.displayName}
- </XDSText>
- <XDSText
- type="supporting"
- style={{color: 'rgba(255,255,255,0.7)'}}>
- {pkg.description.slice(0, 80)}
- {pkg.description.length > 80 ? '\u2026' : ''}
- </XDSText>
- </XDSVStack>
- <XDSHStack gap={2}>
- <XDSButton
- label="View theme"
- variant="secondary"
- size="sm"
- href={`/packages/${pkg.name.replace('@xds/', '')}`}
- />
- <XDSButton
- label="Customize"
- variant="secondary"
- size="sm"
- href="/themes/editor"
- />
- </XDSHStack>
- </XDSVStack>
- </div>
- }>
- <div style={{aspectRatio: '16/10'}} inert>
+ <div {...stylex.props(styles.grid)}>
+ {themePackages.map(pkg => {
+ const theme = themeObjects[pkg.name];
+ const label = pkg.displayName
+ .replace(/^Theme:\s*/, '')
+ .replace(/\s*Theme$/, '');
+ return (
+ <XDSCard
+ key={pkg.name}
+ padding={0}
+ variant="transparent"
+ xstyle={styles.cardFill}>
+ <div {...stylex.props(styles.previewFrame)}>
{theme ? (
<XDSTheme theme={theme} mode={mode}>
- <ThemeShowcaseTile label={label} />
+ {/* Re-set structural tokens to XDS defaults
+ (see STRUCTURAL_TOKEN_OVERRIDES above) so
+ every card has identical layout / control
+ sizes. Colors and font-family slots stay
+ theme-driven. */}
+ <div style={STRUCTURAL_TOKEN_OVERRIDES}>
+ <ThemeShowcaseTile
+ label={label}
+ themeName={pkg.name}
+ description={pkg.description}
+ />
+ </div>
</XDSTheme>
) : (
<div {...stylex.props(styles.cardImage)} />
)}
</div>
- </XDSOverlay>
- </XDSCard>
- );
- })}
- </XDSGrid>
- </XDSVStack>
- </XDSSection>
+ </XDSCard>
+ );
+ })}
+ </div>
+ </XDSVStack>
+ </XDSSection>
+ </div>
);
}
diff --git a/apps/docsite/src/app/globals.css b/apps/docsite/src/app/globals.css
index 983bbcd8c5..ec56700734 100644
--- a/apps/docsite/src/app/globals.css
+++ b/apps/docsite/src/app/globals.css
@@ -2,11 +2,10 @@
@import "@xds/core/reset.css";
@import "@xds/core/xds.css";
-@import "@xds/theme-default/theme.css";
-@import "@xds/theme-neutral/theme.css";
-@import "@xds/theme-gothic/theme.css";
-@import "@xds/theme-matcha/theme.css";
-@import "@xds/theme-stone/theme.css";
+/* Aggregated theme CSS — auto-generated by scripts/generate-data.mjs
+ from every @xds/theme-* package in this app's dependencies. New
+ themes are picked up automatically; no edit here required. */
+@import "../generated/themes.css";
@import "../themes/astryx.css";
/* StyleX app styles injected here. useCSSLayers.before declares
diff --git a/apps/docsite/src/components/DocsShell.tsx b/apps/docsite/src/components/DocsShell.tsx
index 76893f9265..055ffaa81c 100644
--- a/apps/docsite/src/components/DocsShell.tsx
+++ b/apps/docsite/src/components/DocsShell.tsx
@@ -74,7 +74,9 @@ export function DocsShell({
// When searching, flatten groups to individual entries so results are
// all at the same level with no nesting.
const flatSearchResults = useMemo<GroupedEntry[]>(() => {
- if (!q) {return [];}
+ if (!q) {
+ return [];
+ }
return componentItems.flatMap(item => {
if (item.type === 'entry') {
return item.displayName.toLowerCase().includes(q) ? [item] : [];
diff --git a/apps/docsite/src/components/ThemeShowcasePreview.tsx b/apps/docsite/src/components/ThemeShowcasePreview.tsx
index 8ad87c21a5..ed39a835a6 100644
--- a/apps/docsite/src/components/ThemeShowcasePreview.tsx
+++ b/apps/docsite/src/components/ThemeShowcasePreview.tsx
@@ -2,7 +2,6 @@
'use client';
-import {useState} from 'react';
import stylex from '@stylexjs/stylex';
import {
MagnifyingGlassIcon,
@@ -19,13 +18,8 @@ import {XDSGrid} from '@xds/core/Grid';
import {XDSBadge} from '@xds/core/Badge';
import {XDSAspectRatio} from '@xds/core/AspectRatio';
import {XDSTopNav, XDSTopNavHeading, XDSTopNavItem} from '@xds/core/TopNav';
-import {XDSRadioList, XDSRadioListItem} from '@xds/core/RadioList';
-import {XDSTextInput} from '@xds/core/TextInput';
import {XDSNumberInput} from '@xds/core/NumberInput';
import type {ThemeImageSet} from './themeImages';
-import {XDSProgressBar} from '@xds/core/ProgressBar';
-import {XDSSwitch} from '@xds/core/Switch';
-import {XDSBanner} from '@xds/core/Banner';
const styles = stylex.create({
productImage: {
width: '100%',
diff --git a/apps/docsite/src/components/ThemeShowcaseTile.tsx b/apps/docsite/src/components/ThemeShowcaseTile.tsx
index 560f8eee62..9b469f30e2 100644
--- a/apps/docsite/src/components/ThemeShowcaseTile.tsx
+++ b/apps/docsite/src/components/ThemeShowcaseTile.tsx
@@ -2,142 +2,703 @@
'use client';
+import {useEffect, useMemo, useRef, useState} from 'react';
+import {PlusIcon} from '@heroicons/react/24/outline';
import * as stylex from '@stylexjs/stylex';
import {
colorVars,
radiusVars,
+ spacingVars,
typographyVars,
- borderVars,
} from '@xds/core/theme/tokens.stylex';
+import {XDSBanner} from '@xds/core/Banner';
import {XDSButton} from '@xds/core/Button';
+import {XDSCard} from '@xds/core/Card';
+import {XDSCheckboxInput} from '@xds/core/CheckboxInput';
+import {XDSHStack, XDSVStack} from '@xds/core/Layout';
+import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {XDSRadioList, XDSRadioListItem} from '@xds/core/RadioList';
+import {XDSSwitch} from '@xds/core/Switch';
+import {
+ XDSTable,
+ XDSTableBody,
+ XDSTableCell,
+ XDSTableHeader,
+ XDSTableHeaderCell,
+ XDSTableRow,
+} from '@xds/core/Table';
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSTextInput} from '@xds/core/TextInput';
+import {XDSBadge} from '@xds/core/Badge';
+import {XDSClickableCard} from '@xds/core/ClickableCard';
+
+// Below 800px viewport, the tile's left card + right column stack
+// vertically (instead of side-by-side). The 2-column tile layout
+// needs roughly 750px+ of tile width to read well — type samples
+// + swatches + buttons on the left, input + table + controls +
+// banners on the right. Below that, the 50/50 split crushes
+// content. Above ~760px viewport the grid drops to 1 card/row but
+// the tile stays side-by-side because the full viewport gives the
+// card 760-1540px to work with.
+const TILE_STACK_BREAKPOINT = '@media (max-width: 800px)';
+
+// Visual sizing constants for the preview tile. Pulled to module
+// constants so they're easy to find and adjust without hunting
+// through stylex blocks.
+const HERO_IMAGE_HEIGHT = 170; // px — hero image inside the left card
+const SWATCH_SIZE = 24; // px — diameter of each color swatch circle
+const TYPE_SAMPLE_GLYPH_SIZE = 36; // px — font-size for the "Aa" type samples
+
+// Image asset extensions checked in order. The hero image for a
+// theme is discovered at runtime by stepping through these against
+// the conventional path `/theme-<slug>-preview.<ext>`. The first
+// extension that loads wins; if none do, we render the tinted
+// gradient fallback. New themes only need to drop a file matching
+// one of these extensions in /public — no map update required.
+const THEME_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp'] as const;
+
+// Build the candidate URL list for a given theme package name.
+// `@xds/theme-stone` → ['/theme-stone-preview.png', '/theme-stone-preview.jpg', …]
+function themeImageCandidates(themeName: string): ReadonlyArray<string> {
+ const slug = themeName.replace('@xds/theme-', '');
+ return THEME_IMAGE_EXTENSIONS.map(ext => `/theme-${slug}-preview.${ext}`);
+}
+
+// Row 1 — Brand surface set. The 4 tokens that together define the
+// theme's brand backdrop: the accent itself, the muted-accent
+// variant (used for hover/pressed/subtle states), and the two
+// background surfaces (body page bg + elevated card surface).
+const BRAND_SWATCH_TOKENS: ReadonlyArray<string> = [
+ '--color-accent',
+ '--color-accent-muted',
+ '--color-background-body',
+ '--color-background-surface',
+];
+
+// Row 2 — Categorical palette. The 9 non-semantic hues every theme
+// defines for badges, banner tints, and color-coded categorization.
+// We render --color-background-{hue} because that's the variant
+// actually visible to end users in badge/banner surfaces — matching
+// the colors users see in the table badges and banner stack
+// elsewhere in the preview tile.
+const CATEGORICAL_SWATCH_TOKENS: ReadonlyArray<string> = [
+ '--color-background-blue',
+ '--color-background-cyan',
+ '--color-background-green',
+ '--color-background-orange',
+ '--color-background-pink',
+ '--color-background-purple',
+ '--color-background-red',
+ '--color-background-teal',
+ '--color-background-yellow',
+];
const styles = stylex.create({
+ // Outer tile: 2-column flex by default (left card + right column
+ // side-by-side). Below 640px viewport, switches to a vertical
+ // stack so neither column gets cramped on small screens.
+ //
+ // A 16px gap sits between the two columns. Each column carries
+ // its own outer-edge padding (top/bottom + the outer horizontal
+ // edge) so the tile's overall inset matches what each column
+ // contributes — and the middle channel is exactly one 16px gap
+ // rather than the doubled 32px gutter we'd get from symmetric
+ // padding on both columns.
tile: {
display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- gap: 4,
- padding: 20,
- borderRadius: radiusVars['--radius-container'],
+ flexDirection: 'row',
+ gap: spacingVars['--spacing-4'],
+ [TILE_STACK_BREAKPOINT]: {
+ flexDirection: 'column',
+ },
+ // Hover/active/focus chrome (5% ::after on :hover, 10% on
+ // :active, focus-visible outline) is provided by the outer
+ // XDSClickableCard — no need to reimplement here. But we
+ // still override two pieces of its visual treatment:
+ //
+ // 1. backgroundColor: XDSClickableCard's default variant
+ // paints --color-background-card (lifted surface tone).
+ // Theme tiles need to sit on the theme's body color so
+ // the hero image, banners, and form controls inside the
+ // tile read as a continuous themed surface (matches what
+ // a real themed app looks like, where everything sits on
+ // --color-background-body).
+ // 2. overflow: hidden: without this, the hero image and the
+ // right-column banners at the card edges paint past the
+ // rounded corners XDSClickableCard sets via its radius.
backgroundColor: colorVars['--color-background-body'],
overflow: 'hidden',
+ // Drop the XDSCard default variant's --color-border-emphasized
+ // border so the tile reads as a continuous themed surface
+ // rather than a bordered card-on-card. The hover/focus
+ // affordance comes from XDSClickableCard's ::after overlay
+ // and focus-visible outline, not from a static border.
+ borderColor: 'transparent',
width: '100%',
height: '100%',
boxSizing: 'border-box',
},
- topRow: {
+
+ // Left column wraps the theme card. Sized to share the tile width
+ // 50/50 with the right column. The XDSCard inside carries the
+ // actual surface styling (border, background, radius). 16px of
+ // padding on the top / bottom / left (outer tile edges); 0 on
+ // the right so the inside edges of the two columns share a
+ // single gap instead of doubling up (which produced a visible
+ // 32px channel down the middle of every card).
+ //
+ // When the tile stacks (narrow viewport), the bottom padding
+ // collapses since the right column sits flush underneath
+ // (handled by its top padding instead).
+ leftColumn: {
+ flex: '1 1 0',
+ [TILE_STACK_BREAKPOINT]: {
+ flex: '0 0 auto',
+ paddingBottom: 0,
+ paddingRight: spacingVars['--spacing-4'],
+ },
+ minWidth: 0,
display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- gap: 12,
+ paddingBlock: spacingVars['--spacing-4'],
+ paddingInlineStart: spacingVars['--spacing-4'],
+ paddingInlineEnd: 0,
+ },
+
+ // Make XDSCard fill the left column's full width *and* height
+ // so the inner card stretches to match the right column instead
+ // of leaving a band of empty tile background below it.
+ leftCard: {
+ width: '100%',
+ height: '100%',
},
- fontSamples: {
+
+ // Image wrapper at the bottom of the left card. Flex-grows to
+ // fill any vertical space left over after heading + description
+ // + type samples + swatches lay out, while HERO_IMAGE_HEIGHT
+ // acts as a floor so short tiles still get a real hero band.
+ // Combined with `objectFit: cover` on the <img> below, the
+ // image just crops to whatever final height it ends up at.
+ // Lives at the bottom of the card (not the top) so the card
+ // opens with the theme name + description as the dominant
+ // identity element, with the hero image as a closing brand
+ // signature.
+ //
+ // `flex: '1 1 0'` (basis = 0, NOT auto) is load-bearing: with
+ // basis `auto`, the flex algorithm uses the <img>'s natural
+ // pixel size as the wrapper's preferred height — which for
+ // stock-photo assets is 800px+, blowing out the whole left
+ // card to match. Basis `0` makes the wrapper start at zero
+ // and grow by exactly the leftover space, capped by the right
+ // column's natural height.
+ imageWrapper: {
+ position: 'relative',
+ overflow: 'hidden',
+ flex: '1 1 0',
+ minHeight: HERO_IMAGE_HEIGHT,
+ borderRadius: radiusVars['--radius-element'],
+ backgroundColor: colorVars['--color-background-muted'],
+ },
+ image: {
+ display: 'block',
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ },
+ imageFallback: {
+ width: '100%',
+ height: '100%',
+ backgroundImage: `linear-gradient(135deg, ${colorVars['--color-accent']} 0%, ${colorVars['--color-background-muted']} 100%)`,
+ },
+
+ // Typography sample — flex hint so each of the 4 "Aa" columns
+ // gets equal width via flex: 1 (XDSVStack with this xstyle is the
+ // column wrapper for one type role: Display / Heading / Body / Mono).
+ typeSample: {
+ flex: '1 1 0',
display: 'flex',
flexDirection: 'column',
- gap: 2,
+ gap: spacingVars['--spacing-0-5'],
+ minWidth: 0,
},
- headingFont: {
- fontFamily: typographyVars['--font-family-heading'],
- fontSize: 36,
- fontWeight: 300,
+ // Each typography sample sizes itself uniformly via a wrapper
+ // class. The actual font family + weight comes from the underlying
+ // XDSText / span using the theme's own typography tokens (or, for
+ // Display, the theme-scoped .xds-text.display-3 rule which themes
+ // like Gothic use to swap in a signature display family).
+ typeAa: {
+ display: 'inline-block',
+ fontSize: TYPE_SAMPLE_GLYPH_SIZE,
lineHeight: 1,
color: colorVars['--color-text-primary'],
- letterSpacing: '-0.02em',
},
- bodyFont: {
+ typeAaHeading: {
+ fontFamily: typographyVars['--font-family-heading'],
+ },
+ typeAaBody: {
fontFamily: typographyVars['--font-family-body'],
- fontSize: 13,
- fontWeight: 400,
- lineHeight: 1.3,
- color: colorVars['--color-text-secondary'],
},
- codeFont: {
+ typeAaMono: {
fontFamily: typographyVars['--font-family-code'],
- fontSize: 11,
- fontWeight: 400,
- lineHeight: 1.3,
- color: colorVars['--color-text-disabled'],
},
- rightGroup: {
+
+ // Color swatch — one of two rows (brand surface set + categorical
+ // palette). Width/height keep all circles uniformly sized
+ // regardless of theme.
+ swatch: {
+ width: SWATCH_SIZE,
+ height: SWATCH_SIZE,
+ borderRadius: radiusVars['--radius-full'],
+ flexShrink: 0,
+ },
+
+ // Action row sits between the form-controls (switch/radio/
+ // checkbox) row and the banner stack in the right column.
+ // Holds the Primary / Secondary / Ghost button samples — demos
+ // the theme's button chrome. Buttons are passive samples (the
+ // right column carries `inert`), not interactive CTAs: the
+ // entire tile is itself a single link to the theme page.
+ actionRow: {
display: 'flex',
alignItems: 'center',
- gap: 12,
+ gap: spacingVars['--spacing-2'],
},
- colorStack: {
+
+ // Right column: stacked groups of components. Uses a larger
+ // 24px gap *between* component groups (form-inputs / table /
+ // controls / banners) so the visual hierarchy reads cleanly.
+ // Each group inside uses XDSVStack/XDSHStack with a tighter gap.
+ // flex-basis flips to auto when stacked (see leftColumn note above).
+ //
+ // Padding mirrors leftColumn — 16px on top / bottom / right
+ // (outer tile edges); 0 on the left so the inside edge between
+ // the two columns has a single 16px gap rather than 32px.
+ rightColumn: {
+ flex: '1 1 0',
+ [TILE_STACK_BREAKPOINT]: {
+ flex: '0 0 auto',
+ paddingLeft: spacingVars['--spacing-4'],
+ },
display: 'flex',
flexDirection: 'column',
- gap: 3,
- },
- colorDot: {
- width: 16,
- height: 16,
- borderRadius: radiusVars['--radius-full'],
- },
- dotAccent: {
- backgroundColor: colorVars['--color-accent'],
- },
- dotPrimary: {
- backgroundColor: colorVars['--color-text-primary'],
- },
- dotSecondary: {
- backgroundColor: colorVars['--color-text-secondary'],
- },
- dotDisabled: {
- backgroundColor: colorVars['--color-text-disabled'],
- },
- shapeRow: {
- display: 'flex',
- gap: 6,
- },
- shape: {
- width: 36,
- height: 36,
- backgroundColor: colorVars['--color-background-card'],
- borderWidth: borderVars['--border-width'],
- borderStyle: 'solid',
- borderColor: colorVars['--color-border-emphasized'],
- boxSizing: 'border-box',
- },
- shapeInner: {
- borderRadius: radiusVars['--radius-inner'],
- },
- shapeElement: {
- borderRadius: radiusVars['--radius-element'],
- },
- shapeContainer: {
- borderRadius: radiusVars['--radius-container'],
- },
- shapeFull: {
- borderRadius: radiusVars['--radius-full'],
+ gap: spacingVars['--spacing-6'],
+ paddingBlock: spacingVars['--spacing-4'],
+ paddingInlineEnd: spacingVars['--spacing-4'],
+ paddingInlineStart: 0,
+ minWidth: 0,
},
});
-export function ThemeShowcaseTile({label}: {label: string}) {
+// =============================================================================
+// ContrastSwatch — auto-bordered color swatch
+// =============================================================================
+//
+// Renders a circle filled with the CSS variable `token`. After mount,
+// reads the resolved background-color via getComputedStyle and the
+// theme's surface background, computes the WCAG contrast ratio
+// between them, and conditionally adds a 1px subtle border when the
+// swatch would otherwise blend into the card background.
+//
+// Why: themes like Butter set --color-background-body to a creamy
+// off-white and define light surface/border tokens that visually
+// disappear against the inner left card's --color-background-surface.
+// Stone's --color-background-body is white-on-white. The auto-border
+// keeps the swatch's edge visible without forcing a hardcoded border
+// on every theme (which would be visually noisy on themes with
+// already-high-contrast palettes like Gothic on dark surfaces).
+
+// Parse any CSS color string into [r, g, b] 0-255 via the canvas
+// 2D context's built-in color parser. Canvas accepts every standard
+// CSS color format (rgb, rgba, hex, hsl, hsla, oklch, oklab, color(),
+// named colors, currentColor) and normalizes them to the rendered
+// pixel value, which we read back via getImageData.
+//
+// This is more robust than regex-matching `rgb(...)` because modern
+// themes can produce colors in formats like `oklch(...)` or
+// `light-dark(...)` via getComputedStyle resolution.
+function parseRgb(color: string): [number, number, number] | null {
+ if (typeof document === 'undefined') {
+ return null;
+ }
+ const canvas = document.createElement('canvas');
+ canvas.width = 1;
+ canvas.height = 1;
+ const ctx = canvas.getContext('2d');
+ if (!ctx) {
+ return null;
+ }
+ ctx.fillStyle = '#000'; // baseline so invalid `color` doesn't carry over
+ ctx.fillStyle = color;
+ // If the canvas couldn't parse the color, fillStyle stays at the
+ // baseline. Check by re-reading fillStyle; canvas normalizes to a
+ // valid CSS color string, so an unparseable input will read back as
+ // the baseline ('#000000').
+ ctx.fillRect(0, 0, 1, 1);
+ const data = ctx.getImageData(0, 0, 1, 1).data;
+ return [data[0], data[1], data[2]];
+}
+
+// WCAG relative luminance per https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
+function relativeLuminance([r, g, b]: [number, number, number]): number {
+ const channel = (c: number) => {
+ const s = c / 255;
+ return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
+ };
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
+}
+
+// WCAG contrast ratio: 1 = identical, 21 = max (white vs black).
+function contrastRatio(
+ a: [number, number, number],
+ b: [number, number, number],
+) {
+ const la = relativeLuminance(a);
+ const lb = relativeLuminance(b);
+ const [lighter, darker] = la > lb ? [la, lb] : [lb, la];
+ return (lighter + 0.05) / (darker + 0.05);
+}
+
+// Threshold below which we add a border. 1.5:1 is well below WCAG text
+// thresholds (3:1 for large text) but above visual-noise level —
+// chosen empirically as "the swatch's edge is no longer obvious".
+const CONTRAST_THRESHOLD = 1.5;
+
+function ContrastSwatch({
+ token,
+ swatchStyle,
+}: {
+ token: string;
+ swatchStyle: ReturnType<typeof stylex.props>;
+}) {
+ const ref = useRef<HTMLDivElement | null>(null);
+ const [needsBorder, setNeedsBorder] = useState(false);
+
+ useEffect(() => {
+ const el = ref.current;
+ if (!el) {
+ return;
+ }
+ const swatchRgb = parseRgb(getComputedStyle(el).backgroundColor);
+ // Walk up to find the nearest styled ancestor to read the
+ // resolved surface color from. Reading the CSS custom property
+ // directly off `el` returns the unresolved expression (e.g.
+ // "light-dark(...)") which parseRgb can handle via canvas, but
+ // reading the COMPUTED background-color of an ancestor is more
+ // reliable since the cascade is already applied.
+ const surfaceColor = getComputedStyle(el)
+ .getPropertyValue('--color-background-surface')
+ .trim();
+ const surfaceRgb = surfaceColor ? parseRgb(surfaceColor) : null;
+ if (!swatchRgb || !surfaceRgb) {
+ setNeedsBorder(false);
+ return;
+ }
+ const ratio = contrastRatio(swatchRgb, surfaceRgb);
+ setNeedsBorder(ratio < CONTRAST_THRESHOLD);
+ }, [token]);
+
return (
- <div {...stylex.props(styles.tile)} inert>
- <div {...stylex.props(styles.topRow)}>
- <div {...stylex.props(styles.fontSamples)}>
- <span {...stylex.props(styles.headingFont)}>Aa</span>
- <span {...stylex.props(styles.bodyFont)}>Body text</span>
- <span {...stylex.props(styles.codeFont)}>{'<Code />'}</span>
- </div>
- <div {...stylex.props(styles.rightGroup)}>
- <XDSButton variant="primary" label={label} size="sm" />
- <div {...stylex.props(styles.colorStack)}>
- <div {...stylex.props(styles.colorDot, styles.dotAccent)} />
- <div {...stylex.props(styles.colorDot, styles.dotPrimary)} />
- <div {...stylex.props(styles.colorDot, styles.dotSecondary)} />
- <div {...stylex.props(styles.colorDot, styles.dotDisabled)} />
- </div>
- </div>
+ <div
+ ref={ref}
+ className={swatchStyle.className}
+ style={{
+ ...swatchStyle.style,
+ backgroundColor: `var(${token})`,
+ border: needsBorder ? '1px solid var(--color-border)' : undefined,
+ }}
+ />
+ );
+}
+
+export function ThemeShowcaseTile({
+ label,
+ themeName,
+ description,
+}: {
+ label: string;
+ themeName?: string;
+ description?: string;
+}) {
+ // Step through candidate image URLs on each <img onError>. Each
+ // error advances candidateIndex by one; when we run out of
+ // candidates, we fall through to the gradient fallback. Memoized
+ // so it doesn't recompute on every render.
+ const candidates = useMemo(
+ () => (themeName ? themeImageCandidates(themeName) : []),
+ [themeName],
+ );
+ const [candidateIndex, setCandidateIndex] = useState(0);
+ // Reset to the first candidate whenever the theme changes (e.g. in
+ // a parent that swaps themes without unmounting the tile).
+ useEffect(() => {
+ setCandidateIndex(0);
+ }, [themeName]);
+ const imageSrc = candidates[candidateIndex];
+ const showImage = imageSrc !== undefined;
+ // Theme detail page URL. Strip the @xds/ scope from the package
+ // name to match the [name] segment of /packages/[name].
+ const themeHref = themeName
+ ? `/packages/${themeName.replace('@xds/', '')}`
+ : undefined;
+
+ return (
+ <XDSClickableCard
+ label={`Open ${label} theme`}
+ href={themeHref}
+ padding={0}
+ xstyle={styles.tile}>
+ {/* Left column: theme card wrapped in XDSCard for a self-
+ contained surface (border, background, radius). */}
+ <div {...stylex.props(styles.leftColumn)}>
+ <XDSCard padding={4} xstyle={styles.leftCard}>
+ <XDSVStack gap={6} width="100%" height="100%">
+ {/* Group 1 — identity: name + description. The hero
+ image used to live in this group at the top of the
+ card; it now sits at the bottom of the card (after
+ Group 2) as a closing brand signature so the card
+ opens with the most identifying information rather
+ than a decorative photo. Inert so the tile reads
+ as a passive demo. */}
+ <XDSVStack gap={1} inert>
+ <XDSHeading level={2} color="primary">
+ {label}
+ </XDSHeading>
+ {description && (
+ <XDSText as="span" type="body" color="secondary">
+ {description}
+ </XDSText>
+ )}
+ </XDSVStack>
+
+ {/* Group 2 — design tokens: typography samples + color
+ swatches. Both visualize the theme's underlying
+ token system so they cluster together. Inert so
+ the tile reads as a passive demo.
+ gap={6} (not gap={4}) between the Aa row and the
+ swatches: the small-glyph supporting labels under
+ each Aa (Display / Heading / Body / Mono) eat some
+ of the visual gap, so a larger spacing value reads
+ as optically even with the rest of the card's
+ inter-group rhythm. */}
+ <XDSVStack gap={6} inert>
+ {/* Typography samples — each "Aa" rendered in the theme's
+ display / heading / body / mono font with the role as
+ label. The Display sample uses XDSText type="display-3"
+ so themes that scope a custom display family to the
+ .xds-text.display-3 selector (e.g. Gothic →
+ Manufacturing Consent) flow through cleanly. */}
+ <XDSHStack gap={3}>
+ <XDSVStack gap={0.5} xstyle={styles.typeSample}>
+ <XDSText
+ as="span"
+ type="display-3"
+ color="primary"
+ xstyle={styles.typeAa}>
+ Aa
+ </XDSText>
+ <XDSText as="span" type="supporting" color="secondary">
+ Display
+ </XDSText>
+ </XDSVStack>
+ <XDSVStack gap={0.5} xstyle={styles.typeSample}>
+ <span {...stylex.props(styles.typeAa, styles.typeAaHeading)}>
+ Aa
+ </span>
+ <XDSText as="span" type="supporting" color="secondary">
+ Heading
+ </XDSText>
+ </XDSVStack>
+ <XDSVStack gap={0.5} xstyle={styles.typeSample}>
+ <span {...stylex.props(styles.typeAa, styles.typeAaBody)}>
+ Aa
+ </span>
+ <XDSText as="span" type="supporting" color="secondary">
+ Body
+ </XDSText>
+ </XDSVStack>
+ <XDSVStack gap={0.5} xstyle={styles.typeSample}>
+ <span {...stylex.props(styles.typeAa, styles.typeAaMono)}>
+ Aa
+ </span>
+ <XDSText as="span" type="supporting" color="secondary">
+ Mono
+ </XDSText>
+ </XDSVStack>
+ </XDSHStack>
+
+ {/* Color swatch palette — two rows tell two stories.
+ Row 1 (brand surface set): accent, accent-muted,
+ background-body, background-surface. Together these
+ define the theme's brand backdrop and primary
+ action color.
+ Row 2 (categorical palette): the 9 non-semantic
+ hues every theme defines (Blue → Yellow), shown
+ via the --color-icon-{hue} variant for max
+ saturation.
+ Each swatch auto-adds a 1px border when its color
+ blends into the card surface (low WCAG contrast)
+ so light-on-light tokens stay visible. */}
+ <XDSVStack gap={2}>
+ <XDSHStack gap={2} wrap="wrap">
+ {BRAND_SWATCH_TOKENS.map(token => (
+ <ContrastSwatch
+ key={token}
+ token={token}
+ swatchStyle={stylex.props(styles.swatch)}
+ />
+ ))}
+ </XDSHStack>
+ <XDSHStack gap={2} wrap="wrap">
+ {CATEGORICAL_SWATCH_TOKENS.map(token => (
+ <ContrastSwatch
+ key={token}
+ token={token}
+ swatchStyle={stylex.props(styles.swatch)}
+ />
+ ))}
+ </XDSHStack>
+ </XDSVStack>
+ </XDSVStack>
+ {/* end Group 2 */}
+
+ {/* Hero image — closing brand signature at the bottom
+ of the left card. Flex-grows to fill any leftover
+ vertical space so tall tiles (Butter, Y2K) don't
+ leave an empty band at the bottom; falls back to a
+ 170px floor on short tiles. Raw <img> intentionally:
+ XDS provides XDSThumbnail but it's purpose-built
+ for file-attachment UX (square 64px default,
+ remove/click affordances, upload-style skeleton).
+ Tinted gradient fallback covers themes whose
+ preview asset isn't ready yet. Inert so the tile
+ reads as a passive demo. */}
+ <div {...stylex.props(styles.imageWrapper)} inert>
+ {showImage ? (
+ <img
+ src={imageSrc}
+ alt=""
+ {...stylex.props(styles.image)}
+ onError={() => setCandidateIndex(i => i + 1)}
+ />
+ ) : (
+ <div {...stylex.props(styles.imageFallback)} />
+ )}
+ </div>
+ </XDSVStack>
+ </XDSCard>
</div>
- <div {...stylex.props(styles.shapeRow)}>
- <div {...stylex.props(styles.shape, styles.shapeFull)} />
- <div {...stylex.props(styles.shape, styles.shapeFull)} />
- <div {...stylex.props(styles.shape, styles.shapeContainer)} />
- <div {...stylex.props(styles.shape, styles.shapeElement)} />
- <div {...stylex.props(styles.shape, styles.shapeInner)} />
+
+ {/* Right column — open content, no card chrome. Each group
+ of related components is wrapped in an XDSVStack at the
+ tighter intra-group gap; the column itself uses a larger
+ gap between groups for clear visual hierarchy. Inert so
+ every showcase component (input, progress, table, form
+ controls, banners, Primary/Secondary button samples)
+ reads as a passive demo — the whole tile is itself a
+ link to the theme page, which is the only interactive
+ surface. */}
+ <div {...stylex.props(styles.rightColumn)} inert>
+ {/* Group 1 — form-input components (text input + progress
+ bar). Both are data-input/feedback elements so they
+ cluster together at the tighter gap. */}
+ <XDSVStack gap={3}>
+ <XDSTextInput
+ label="Input"
+ isLabelHidden
+ size="sm"
+ placeholder="Type something..."
+ value=""
+ onChange={() => {}}
+ />
+ <XDSProgressBar label="Progress" value={75} isLabelHidden />
+ </XDSVStack>
+
+ {/* Compact 3-column table with two example rows — demos the
+ theme's table chrome (header, row dividers, cell typography),
+ a Badge in the Status column, and a ghost icon button in
+ the Action column for the icon-button chrome. */}
+ <XDSTable density="compact" dividers="rows">
+ <XDSTableHeader>
+ <XDSTableRow>
+ <XDSTableHeaderCell>Table</XDSTableHeaderCell>
+ <XDSTableHeaderCell>Status</XDSTableHeaderCell>
+ <XDSTableHeaderCell>Action</XDSTableHeaderCell>
+ </XDSTableRow>
+ </XDSTableHeader>
+ <XDSTableBody>
+ <XDSTableRow>
+ <XDSTableCell>Example 1</XDSTableCell>
+ <XDSTableCell>
+ <XDSBadge label="Badge" variant="info" />
+ </XDSTableCell>
+ <XDSTableCell>
+ <XDSButton
+ variant="ghost"
+ size="sm"
+ label="Add"
+ isIconOnly
+ icon={<PlusIcon />}
+ />
+ </XDSTableCell>
+ </XDSTableRow>
+ <XDSTableRow>
+ <XDSTableCell>Example 2</XDSTableCell>
+ <XDSTableCell>
+ <XDSBadge label="Badge" variant="success" />
+ </XDSTableCell>
+ <XDSTableCell>
+ <XDSButton
+ variant="ghost"
+ size="sm"
+ label="Add"
+ isIconOnly
+ icon={<PlusIcon />}
+ />
+ </XDSTableCell>
+ </XDSTableRow>
+ </XDSTableBody>
+ </XDSTable>
+
+ {/* Three form controls in one horizontal row — demos the
+ theme's switch, radio, and checkbox styling side-by-
+ side. All three render at their default size: XDSSwitch
+ ships at a single fixed size with no `size` variant
+ (passing one is a type error that breaks the build),
+ so the neighboring XDSRadioList + XDSCheckboxInput
+ also use their default sizes to stay visually matched. */}
+ <XDSHStack gap={4} wrap="wrap" vAlign="center">
+ <XDSSwitch label="Toggle" value={true} />
+ <XDSRadioList
+ label="Radio"
+ isLabelHidden
+ value="radio"
+ onChange={() => {}}>
+ <XDSRadioListItem label="Radio Button" value="radio" />
+ </XDSRadioList>
+ <XDSCheckboxInput label="Checkbox" value={false} />
+ </XDSHStack>
+
+ {/* Action row — Primary / Secondary / Ghost button samples.
+ Passive demos thanks to the column's inert; the whole
+ tile is a single link to the theme page. Sits above
+ the banners so the demo flows from atomic interactive
+ chrome (buttons) into compound chrome (banner stack). */}
+ <div {...stylex.props(styles.actionRow)}>
+ <XDSHStack gap={2} wrap="wrap">
+ <XDSButton variant="primary" size="sm" label="Primary" />
+ <XDSButton variant="secondary" size="sm" label="Secondary" />
+ <XDSButton variant="ghost" size="sm" label="Ghost" />
+ </XDSHStack>
+ </div>
+
+ {/* Four banners stacked — demos the theme's info / success /
+ warning / error chrome (icon, surface color, text color). */}
+ <XDSVStack gap={2}>
+ <XDSBanner status="info" title="Banner Title" />
+ <XDSBanner status="success" title="Banner Title" />
+ <XDSBanner status="warning" title="Banner Title" />
+ <XDSBanner status="error" title="Banner Title" />
+ </XDSVStack>
</div>
- </div>
+ </XDSClickableCard>
);
}
diff --git a/apps/storybook/stories/ChatComposerInput.stories.tsx b/apps/storybook/stories/ChatComposerInput.stories.tsx
index 1641301a46..5a6a399efa 100644
--- a/apps/storybook/stories/ChatComposerInput.stories.tsx
+++ b/apps/storybook/stories/ChatComposerInput.stories.tsx
@@ -45,11 +45,31 @@ const USERS: XDSSearchableItem<{role: string}>[] = [
];
const COMMANDS: XDSSearchableItem<{description: string}>[] = [
- {id: 'summarize', label: 'summarize', auxiliaryData: {description: 'Summarize the conversation'}},
- {id: 'translate', label: 'translate', auxiliaryData: {description: 'Translate text to another language'}},
- {id: 'search', label: 'search', auxiliaryData: {description: 'Search the web or documents'}},
- {id: 'code', label: 'code', auxiliaryData: {description: 'Generate or explain code'}},
- {id: 'help', label: 'help', auxiliaryData: {description: 'Show available commands'}},
+ {
+ id: 'summarize',
+ label: 'summarize',
+ auxiliaryData: {description: 'Summarize the conversation'},
+ },
+ {
+ id: 'translate',
+ label: 'translate',
+ auxiliaryData: {description: 'Translate text to another language'},
+ },
+ {
+ id: 'search',
+ label: 'search',
+ auxiliaryData: {description: 'Search the web or documents'},
+ },
+ {
+ id: 'code',
+ label: 'code',
+ auxiliaryData: {description: 'Generate or explain code'},
+ },
+ {
+ id: 'help',
+ label: 'help',
+ auxiliaryData: {description: 'Show available commands'},
+ },
];
const userSource = createStaticSource(USERS);
@@ -151,9 +171,7 @@ export const MessageHistory: Story = {
<XDSChatComposer
onSubmit={v => setLog(prev => [...prev, v])}
input={
- <XDSChatComposerInput
- placeholder="Submit messages, then ArrowUp to recall..."
- />
+ <XDSChatComposerInput placeholder="Submit messages, then ArrowUp to recall..." />
}
/>
{log.length > 0 && (
@@ -258,7 +276,9 @@ export const SlashCommands: Story = {
renderItem: item => (
<XDSTypeaheadItem
item={item}
- description={(item.auxiliaryData as {description: string})?.description}
+ description={
+ (item.auxiliaryData as {description: string})?.description
+ }
/>
),
onSelect: item => ({
@@ -461,7 +481,6 @@ export const TokenVariants: Story = {
},
};
-
/** Custom render — full control via render() for rich token content */
export const CustomRender: Story = {
render: () => {
@@ -537,12 +556,36 @@ export const CustomRender: Story = {
export const GroupedItems: Story = {
render: () => {
const groupedUsers = createStaticSource([
- {id: 'cindy', label: 'Cindy Zhang', auxiliaryData: {group: 'Design', role: 'Design Systems'}},
- {id: 'taylor', label: 'Taylor Kim', auxiliaryData: {group: 'Design', role: 'Product Design'}},
- {id: 'alex', label: 'Alex Johnson', auxiliaryData: {group: 'Engineering', role: 'Frontend'}},
- {id: 'sam', label: 'Sam Rivera', auxiliaryData: {group: 'Engineering', role: 'Backend'}},
- {id: 'morgan', label: 'Morgan Chen', auxiliaryData: {group: 'Engineering', role: 'Infrastructure'}},
- {id: 'jordan', label: 'Jordan Lee', auxiliaryData: {group: 'Product', role: 'Product Manager'}},
+ {
+ id: 'cindy',
+ label: 'Cindy Zhang',
+ auxiliaryData: {group: 'Design', role: 'Design Systems'},
+ },
+ {
+ id: 'taylor',
+ label: 'Taylor Kim',
+ auxiliaryData: {group: 'Design', role: 'Product Design'},
+ },
+ {
+ id: 'alex',
+ label: 'Alex Johnson',
+ auxiliaryData: {group: 'Engineering', role: 'Frontend'},
+ },
+ {
+ id: 'sam',
+ label: 'Sam Rivera',
+ auxiliaryData: {group: 'Engineering', role: 'Backend'},
+ },
+ {
+ id: 'morgan',
+ label: 'Morgan Chen',
+ auxiliaryData: {group: 'Engineering', role: 'Infrastructure'},
+ },
+ {
+ id: 'jordan',
+ label: 'Jordan Lee',
+ auxiliaryData: {group: 'Product', role: 'Product Manager'},
+ },
] as XDSSearchableItem[]);
const mentionTrigger: XDSChatComposerTrigger = {
diff --git a/apps/storybook/stories/ChatDictation.stories.tsx b/apps/storybook/stories/ChatDictation.stories.tsx
index 562803417b..4355a2cc9b 100644
--- a/apps/storybook/stories/ChatDictation.stories.tsx
+++ b/apps/storybook/stories/ChatDictation.stories.tsx
@@ -218,32 +218,68 @@ export const Interactive: Story = {
{dictation.isListening && (
<div style={{marginTop: 12}}>
- <div style={{fontSize: 12, fontWeight: 600, marginBottom: 4}}>Band Debug (raw vs calibrated)</div>
- <div style={{display: 'flex', gap: 8, fontFamily: 'monospace', fontSize: 11}}>
- {['170-340', '340-860', '860-1.7k', '1.7-3k', '3k+'].map((label, i) => {
- const raw = dictation.rawBands[i] ?? 0;
- const clean = dictation.bands[i] ?? 0;
- const barH = 40;
- return (
- <div key={label} style={{display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2, flex: 1}}>
- <div style={{display: 'flex', gap: 2, alignItems: 'flex-end', height: barH}}>
- <div style={{
- width: 8, backgroundColor: 'rgba(200,200,200,0.5)',
- height: Math.min(raw * barH * 5, barH), borderRadius: 2,
- }} />
- <div style={{
- width: 8, backgroundColor: '#3b82f6',
- height: Math.min(clean * barH * 5, barH), borderRadius: 2,
- }} />
+ <div style={{fontSize: 12, fontWeight: 600, marginBottom: 4}}>
+ Band Debug (raw vs calibrated)
+ </div>
+ <div
+ style={{
+ display: 'flex',
+ gap: 8,
+ fontFamily: 'monospace',
+ fontSize: 11,
+ }}>
+ {['170-340', '340-860', '860-1.7k', '1.7-3k', '3k+'].map(
+ (label, i) => {
+ const raw = dictation.rawBands[i] ?? 0;
+ const clean = dictation.bands[i] ?? 0;
+ const barH = 40;
+ return (
+ <div
+ key={label}
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ gap: 2,
+ flex: 1,
+ }}>
+ <div
+ style={{
+ display: 'flex',
+ gap: 2,
+ alignItems: 'flex-end',
+ height: barH,
+ }}>
+ <div
+ style={{
+ width: 8,
+ backgroundColor: 'rgba(200,200,200,0.5)',
+ height: Math.min(raw * barH * 5, barH),
+ borderRadius: 2,
+ }}
+ />
+ <div
+ style={{
+ width: 8,
+ backgroundColor: '#3b82f6',
+ height: Math.min(clean * barH * 5, barH),
+ borderRadius: 2,
+ }}
+ />
+ </div>
+ <span style={{opacity: 0.5, fontSize: 9}}>{label}</span>
+ <span style={{opacity: 0.4}}>r:{raw.toFixed(3)}</span>
+ <span style={{color: '#3b82f6'}}>
+ c:{clean.toFixed(3)}
+ </span>
</div>
- <span style={{opacity: 0.5, fontSize: 9}}>{label}</span>
- <span style={{opacity: 0.4}}>r:{raw.toFixed(3)}</span>
- <span style={{color: '#3b82f6'}}>c:{clean.toFixed(3)}</span>
- </div>
- );
- })}
+ );
+ },
+ )}
+ </div>
+ <div style={{fontSize: 10, opacity: 0.4, marginTop: 4}}>
+ Gray = raw mic, Blue = after noise floor
</div>
- <div style={{fontSize: 10, opacity: 0.4, marginTop: 4}}>Gray = raw mic, Blue = after noise floor</div>
</div>
)}
diff --git a/apps/storybook/stories/ClickableCard.stories.tsx b/apps/storybook/stories/ClickableCard.stories.tsx
index a6b4ab1cb8..ac6ffc133f 100644
--- a/apps/storybook/stories/ClickableCard.stories.tsx
+++ b/apps/storybook/stories/ClickableCard.stories.tsx
@@ -14,9 +14,19 @@ const meta: Meta<typeof XDSClickableCard> = {
variant: {
control: 'select',
options: [
- 'default', 'transparent', 'muted',
- 'blue', 'cyan', 'gray', 'green', 'orange',
- 'pink', 'purple', 'red', 'teal', 'yellow',
+ 'default',
+ 'transparent',
+ 'muted',
+ 'blue',
+ 'cyan',
+ 'gray',
+ 'green',
+ 'orange',
+ 'pink',
+ 'purple',
+ 'red',
+ 'teal',
+ 'yellow',
],
},
},
@@ -41,15 +51,20 @@ export const Navigation: Story = {
render: () => (
<XDSClickableCard label="Settings" href="/settings" width={300}>
<XDSVStack gap={1}>
- <XDSText type="body" weight="bold">Settings</XDSText>
- <XDSText type="supporting" color="secondary">Manage your preferences</XDSText>
+ <XDSText type="body" weight="bold">
+ Settings
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ Manage your preferences
+ </XDSText>
</XDSVStack>
</XDSClickableCard>
),
parameters: {
docs: {
description: {
- story: 'Card with `href` — clicking navigates. Ctrl/Cmd+click opens new tab. Middle-click opens new tab.',
+ story:
+ 'Card with `href` — clicking navigates. Ctrl/Cmd+click opens new tab. Middle-click opens new tab.',
},
},
},
@@ -58,17 +73,25 @@ export const Navigation: Story = {
export const WithOnClick: Story = {
name: 'Action (onClick)',
render: () => (
- <XDSClickableCard label="Open modal" onClick={() => alert('Card clicked!')} width={300}>
+ <XDSClickableCard
+ label="Open modal"
+ onClick={() => alert('Card clicked!')}
+ width={300}>
<XDSVStack gap={1}>
- <XDSText type="body" weight="bold">Click me</XDSText>
- <XDSText type="supporting" color="secondary">Opens a modal</XDSText>
+ <XDSText type="body" weight="bold">
+ Click me
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ Opens a modal
+ </XDSText>
</XDSVStack>
</XDSClickableCard>
),
parameters: {
docs: {
description: {
- story: 'Card with `onClick` — fires the handler when the card surface is clicked.',
+ story:
+ 'Card with `onClick` — fires the handler when the card surface is clicked.',
},
},
},
@@ -79,8 +102,12 @@ export const NestedButton: Story = {
render: () => (
<XDSClickableCard label="Product card" href="/product/123" width={300}>
<XDSVStack gap={2}>
- <XDSText type="body" weight="bold">Product Name</XDSText>
- <XDSText type="supporting" color="secondary">$29.99</XDSText>
+ <XDSText type="body" weight="bold">
+ Product Name
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ $29.99
+ </XDSText>
<XDSButton
label="Add to cart"
onClick={() => alert('Added to cart! (card did NOT navigate)')}
@@ -103,17 +130,26 @@ export const NestedButton: Story = {
export const Disabled: Story = {
render: () => (
- <XDSClickableCard label="Disabled card" onClick={() => {}} isDisabled width={300}>
+ <XDSClickableCard
+ label="Disabled card"
+ onClick={() => {}}
+ isDisabled
+ width={300}>
<XDSVStack gap={1}>
- <XDSText type="body" weight="bold">Disabled</XDSText>
- <XDSText type="supporting" color="secondary">This card cannot be clicked</XDSText>
+ <XDSText type="body" weight="bold">
+ Disabled
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ This card cannot be clicked
+ </XDSText>
</XDSVStack>
</XDSClickableCard>
),
parameters: {
docs: {
description: {
- story: '`isDisabled` suppresses click, hover, focus, and sets `aria-disabled`. `tabIndex` becomes -1.',
+ story:
+ '`isDisabled` suppresses click, hover, focus, and sets `aria-disabled`. `tabIndex` becomes -1.',
},
},
},
@@ -123,16 +159,33 @@ export const ColorVariants: Story = {
name: 'Color Variants',
render: () => {
const variants = [
- 'default', 'muted', 'transparent',
- 'blue', 'cyan', 'gray', 'green', 'orange',
- 'pink', 'purple', 'red', 'teal', 'yellow',
+ 'default',
+ 'muted',
+ 'transparent',
+ 'blue',
+ 'cyan',
+ 'gray',
+ 'green',
+ 'orange',
+ 'pink',
+ 'purple',
+ 'red',
+ 'teal',
+ 'yellow',
] as const;
return (
<XDSHStack gap={3} wrap="wrap">
- {variants.map((v) => (
- <XDSClickableCard key={v} label={v} onClick={() => alert(v)} variant={v} width={140}>
- <XDSText type="body" weight="bold">{v}</XDSText>
+ {variants.map(v => (
+ <XDSClickableCard
+ key={v}
+ label={v}
+ onClick={() => alert(v)}
+ variant={v}
+ width={140}>
+ <XDSText type="body" weight="bold">
+ {v}
+ </XDSText>
</XDSClickableCard>
))}
</XDSHStack>
@@ -141,7 +194,8 @@ export const ColorVariants: Story = {
parameters: {
docs: {
description: {
- story: 'All color variants — same palette as XDSCard. Color cards have transparent borders.',
+ story:
+ 'All color variants — same palette as XDSCard. Color cards have transparent borders.',
},
},
},
diff --git a/apps/storybook/stories/Layer.stories.tsx b/apps/storybook/stories/Layer.stories.tsx
index 37acc9de45..2f8fc00036 100644
--- a/apps/storybook/stories/Layer.stories.tsx
+++ b/apps/storybook/stories/Layer.stories.tsx
@@ -73,9 +73,15 @@ function PlacementDemo() {
const layer = useXDSLayer({mode: 'context', lightDismiss: true});
return (
- <div style={{display: 'flex', flexDirection: 'column', gap: 16, alignItems: 'center'}}>
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 16,
+ alignItems: 'center',
+ }}>
<div style={{display: 'flex', gap: 8}}>
- {(['above', 'below', 'start', 'end'] as const).map((p) => (
+ {(['above', 'below', 'start', 'end'] as const).map(p => (
<XDSButton
key={p}
label={p}
@@ -118,9 +124,12 @@ function FixedModeDemo() {
borderRadius: 8,
cursor: 'crosshair',
}}
- onClick={(e) => {
+ onClick={e => {
const rect = e.currentTarget.getBoundingClientRect();
- setCoords({x: e.clientX - rect.left + rect.left, y: e.clientY - rect.top + rect.top});
+ setCoords({
+ x: e.clientX - rect.left + rect.left,
+ y: e.clientY - rect.top + rect.top,
+ });
layer.show();
}}>
<XDSText type="supporting" style={{padding: 16}}>
@@ -128,7 +137,9 @@ function FixedModeDemo() {
</XDSText>
{layer.render(
<div {...stylex.props(styles.popoverContent)}>
- <XDSText type="body">Fixed at ({Math.round(coords.x)}, {Math.round(coords.y)})</XDSText>
+ <XDSText type="body">
+ Fixed at ({Math.round(coords.x)}, {Math.round(coords.y)})
+ </XDSText>
</div>,
{x: coords.x, y: coords.y},
)}
diff --git a/apps/storybook/stories/NavMenu.stories.tsx b/apps/storybook/stories/NavMenu.stories.tsx
index c69d4b3d5f..a1fa5fb45e 100644
--- a/apps/storybook/stories/NavMenu.stories.tsx
+++ b/apps/storybook/stories/NavMenu.stories.tsx
@@ -27,7 +27,7 @@ const meta: Meta<typeof XDSNavHeadingMenu> = {
},
},
decorators: [
- (Story) => (
+ Story => (
<div style={{padding: 24, maxWidth: 300}}>
<Story />
</div>
@@ -56,31 +56,19 @@ export const WithIcons: Story = {
size: 'md',
children: (
<>
- <XDSNavHeadingMenuItem
- label="Profile"
- icon={UserIcon}
- href="#"
- />
+ <XDSNavHeadingMenuItem label="Profile" icon={UserIcon} href="#" />
<XDSNavHeadingMenuItem
label="Documents"
icon={DocumentTextIcon}
href="#"
/>
- <XDSNavHeadingMenuItem
- label="Analytics"
- icon={ChartBarIcon}
- href="#"
- />
+ <XDSNavHeadingMenuItem label="Analytics" icon={ChartBarIcon} href="#" />
<XDSNavHeadingMenuItem
label="Security"
icon={ShieldCheckIcon}
href="#"
/>
- <XDSNavHeadingMenuItem
- label="Settings"
- icon={Cog6ToothIcon}
- href="#"
- />
+ <XDSNavHeadingMenuItem label="Settings" icon={Cog6ToothIcon} href="#" />
</>
),
},
diff --git a/apps/storybook/stories/SelectableCard.stories.tsx b/apps/storybook/stories/SelectableCard.stories.tsx
index 6f032be7a1..c3a4df6b02 100644
--- a/apps/storybook/stories/SelectableCard.stories.tsx
+++ b/apps/storybook/stories/SelectableCard.stories.tsx
@@ -14,9 +14,19 @@ const meta: Meta<typeof XDSSelectableCard> = {
variant: {
control: 'select',
options: [
- 'default', 'transparent', 'muted',
- 'blue', 'cyan', 'gray', 'green', 'orange',
- 'pink', 'purple', 'red', 'teal', 'yellow',
+ 'default',
+ 'transparent',
+ 'muted',
+ 'blue',
+ 'cyan',
+ 'gray',
+ 'green',
+ 'orange',
+ 'pink',
+ 'purple',
+ 'red',
+ 'teal',
+ 'yellow',
],
},
},
@@ -47,17 +57,20 @@ export const SingleSelect: Story = {
return (
<XDSHStack gap={3}>
- {plans.map((plan) => (
+ {plans.map(plan => (
<XDSSelectableCard
key={plan.id}
label={plan.name}
isSelected={selected === plan.id}
onChange={() => setSelected(plan.id)}
- width={200}
- >
+ width={200}>
<XDSVStack gap={1}>
- <XDSText type="body" weight="bold">{plan.name}</XDSText>
- <XDSText type="supporting" color="secondary">{plan.price}</XDSText>
+ <XDSText type="body" weight="bold">
+ {plan.name}
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ {plan.price}
+ </XDSText>
</XDSVStack>
</XDSSelectableCard>
))}
@@ -67,7 +80,8 @@ export const SingleSelect: Story = {
parameters: {
docs: {
description: {
- story: 'Radio-style selection: track a single selected ID in state. Clicking a card sets it as selected, deselecting the previous.',
+ story:
+ 'Radio-style selection: track a single selected ID in state. Clicking a card sets it as selected, deselecting the previous.',
},
},
},
@@ -86,13 +100,13 @@ export const MultiSelect: Story = {
return (
<XDSHStack gap={3}>
- {filters.map((f) => (
+ {filters.map(f => (
<XDSSelectableCard
key={f.id}
label={f.name}
isSelected={selected.has(f.id)}
- onChange={(isNow) => {
- setSelected((prev) => {
+ onChange={isNow => {
+ setSelected(prev => {
const next = new Set(prev);
if (isNow) {
next.add(f.id);
@@ -102,9 +116,10 @@ export const MultiSelect: Story = {
return next;
});
}}
- width={150}
- >
- <XDSText type="body" weight="bold">{f.name}</XDSText>
+ width={150}>
+ <XDSText type="body" weight="bold">
+ {f.name}
+ </XDSText>
</XDSSelectableCard>
))}
</XDSHStack>
@@ -113,7 +128,8 @@ export const MultiSelect: Story = {
parameters: {
docs: {
description: {
- story: 'Checkbox-style selection: track selected IDs in a Set. Multiple cards can be selected simultaneously.',
+ story:
+ 'Checkbox-style selection: track selected IDs in a Set. Multiple cards can be selected simultaneously.',
},
},
},
@@ -124,19 +140,29 @@ export const ColorVariants: Story = {
render: () => {
const [selected, setSelected] = useState(new Set(['blue', 'purple']));
const variants = [
- 'default', 'muted', 'blue', 'cyan', 'gray', 'green',
- 'orange', 'pink', 'purple', 'red', 'teal', 'yellow',
+ 'default',
+ 'muted',
+ 'blue',
+ 'cyan',
+ 'gray',
+ 'green',
+ 'orange',
+ 'pink',
+ 'purple',
+ 'red',
+ 'teal',
+ 'yellow',
] as const;
return (
<XDSHStack gap={3} wrap="wrap">
- {variants.map((v) => (
+ {variants.map(v => (
<XDSSelectableCard
key={v}
label={v}
isSelected={selected.has(v)}
- onChange={(isNow) => {
- setSelected((prev) => {
+ onChange={isNow => {
+ setSelected(prev => {
const next = new Set(prev);
if (isNow) {
next.add(v);
@@ -147,9 +173,10 @@ export const ColorVariants: Story = {
});
}}
variant={v}
- width={140}
- >
- <XDSText type="body" weight="bold">{v}</XDSText>
+ width={140}>
+ <XDSText type="body" weight="bold">
+ {v}
+ </XDSText>
</XDSSelectableCard>
))}
</XDSHStack>
@@ -158,7 +185,8 @@ export const ColorVariants: Story = {
parameters: {
docs: {
description: {
- story: 'All color variants with selection. The accent border overlays the variant background.',
+ story:
+ 'All color variants with selection. The accent border overlays the variant background.',
},
},
},
@@ -167,21 +195,42 @@ export const ColorVariants: Story = {
export const Disabled: Story = {
render: () => (
<XDSHStack gap={3}>
- <XDSSelectableCard label="Enabled" isSelected={true} onChange={() => {}} width={200}>
- <XDSText type="body" weight="bold">Selected & Enabled</XDSText>
+ <XDSSelectableCard
+ label="Enabled"
+ isSelected={true}
+ onChange={() => {}}
+ width={200}>
+ <XDSText type="body" weight="bold">
+ Selected & Enabled
+ </XDSText>
</XDSSelectableCard>
- <XDSSelectableCard label="Disabled" isSelected={true} onChange={() => {}} isDisabled width={200}>
- <XDSText type="body" weight="bold">Selected & Disabled</XDSText>
+ <XDSSelectableCard
+ label="Disabled"
+ isSelected={true}
+ onChange={() => {}}
+ isDisabled
+ width={200}>
+ <XDSText type="body" weight="bold">
+ Selected & Disabled
+ </XDSText>
</XDSSelectableCard>
- <XDSSelectableCard label="Disabled unselected" isSelected={false} onChange={() => {}} isDisabled width={200}>
- <XDSText type="body" weight="bold">Unselected & Disabled</XDSText>
+ <XDSSelectableCard
+ label="Disabled unselected"
+ isSelected={false}
+ onChange={() => {}}
+ isDisabled
+ width={200}>
+ <XDSText type="body" weight="bold">
+ Unselected & Disabled
+ </XDSText>
</XDSSelectableCard>
</XDSHStack>
),
parameters: {
docs: {
description: {
- story: '`isDisabled` suppresses toggle, hover, focus. Accent border remains visible on disabled+selected cards.',
+ story:
+ '`isDisabled` suppresses toggle, hover, focus. Accent border remains visible on disabled+selected cards.',
},
},
},
diff --git a/apps/storybook/stories/SideNav.stories.tsx b/apps/storybook/stories/SideNav.stories.tsx
index b4ae0c0b63..5f0c771ef1 100644
--- a/apps/storybook/stories/SideNav.stories.tsx
+++ b/apps/storybook/stories/SideNav.stories.tsx
@@ -542,13 +542,13 @@ export const CollapsibleItems: Story = {
/>
}>
<XDSSideNavSection title="Collapsible (no href)">
- <XDSSideNavItem
- label="Settings"
- icon={Cog6ToothIcon}
- collapsible>
+ <XDSSideNavItem label="Settings" icon={Cog6ToothIcon} collapsible>
<XDSSideNavItem label="General" href="/settings/general" />
<XDSSideNavItem label="Security" href="/settings/security" />
- <XDSSideNavItem label="Notifications" href="/settings/notifications" />
+ <XDSSideNavItem
+ label="Notifications"
+ href="/settings/notifications"
+ />
</XDSSideNavItem>
<XDSSideNavItem
label="Documents"
@@ -566,7 +566,10 @@ export const CollapsibleItems: Story = {
collapsible>
<XDSSideNavItem label="General" href="/settings/general" />
<XDSSideNavItem label="Security" href="/settings/security" />
- <XDSSideNavItem label="Notifications" href="/settings/notifications" />
+ <XDSSideNavItem
+ label="Notifications"
+ href="/settings/notifications"
+ />
</XDSSideNavItem>
<XDSSideNavItem
label="Documents"
@@ -585,7 +588,10 @@ export const CollapsibleItems: Story = {
collapsible>
<XDSSideNavItem label="General" href="/settings/general" />
<XDSSideNavItem label="Security" href="/settings/security" />
- <XDSSideNavItem label="Notifications" href="/settings/notifications" />
+ <XDSSideNavItem
+ label="Notifications"
+ href="/settings/notifications"
+ />
</XDSSideNavItem>
</XDSSideNavSection>
</XDSSideNav>
@@ -616,10 +622,7 @@ export const IconlessNestedItems: Story = {
isSelected
href="/dashboard"
/>
- <XDSSideNavItem
- label="Settings"
- icon={Cog6ToothIcon}
- collapsible>
+ <XDSSideNavItem label="Settings" icon={Cog6ToothIcon} collapsible>
<XDSSideNavItem label="General" href="/settings/general" />
<XDSSideNavItem label="Security" href="/settings/security" />
<XDSSideNavItem
@@ -632,7 +635,11 @@ export const IconlessNestedItems: Story = {
<XDSSideNavItem label="Quarterly" href="/reports/quarterly" />
<XDSSideNavItem label="Annual" href="/reports/annual" />
</XDSSideNavItem>
- <XDSSideNavItem label="Analytics" icon={ChartBarIcon} href="/analytics" />
+ <XDSSideNavItem
+ label="Analytics"
+ icon={ChartBarIcon}
+ href="/analytics"
+ />
</XDSSideNavSection>
</XDSSideNav>
),
diff --git a/apps/storybook/stories/TextArea.stories.tsx b/apps/storybook/stories/TextArea.stories.tsx
index 4d9b09aca0..5a7d0b7faa 100644
--- a/apps/storybook/stories/TextArea.stories.tsx
+++ b/apps/storybook/stories/TextArea.stories.tsx
@@ -501,7 +501,11 @@ export const SizeVariants: Story = {
gap: '16px',
}}>
{(['sm', 'md', 'lg'] as const).map((sz, i) => {
- const label = {sm: 'Small (28px)', md: 'Medium (32px)', lg: 'Large (36px)'}[sz];
+ const label = {
+ sm: 'Small (28px)',
+ md: 'Medium (32px)',
+ lg: 'Large (36px)',
+ }[sz];
const [area, setArea] = [
[smArea, setSmArea],
[mdArea, setMdArea],
diff --git a/packages/core/src/Slider/XDSSlider.tsx b/packages/core/src/Slider/XDSSlider.tsx
index ab1a71d073..7db6b38596 100644
--- a/packages/core/src/Slider/XDSSlider.tsx
+++ b/packages/core/src/Slider/XDSSlider.tsx
@@ -373,10 +373,7 @@ export function XDSSlider({ref, ...props}: XDSSliderProps) {
// Value helpers — guard against undefined value (e.g. playground previews
// that render the component without providing a value prop).
const values: number[] = useMemo(
- () =>
- isRange
- ? (value)
- : [value != null ? (value) : min],
+ () => (isRange ? value : [value != null ? value : min]),
[isRange, value, min],
);
diff --git a/packages/lab/src/Schedule/dateMath.ts b/packages/lab/src/Schedule/dateMath.ts
index a9ef1a3f90..e11147b9b8 100644
--- a/packages/lab/src/Schedule/dateMath.ts
+++ b/packages/lab/src/Schedule/dateMath.ts
@@ -105,10 +105,7 @@ export function sortEvents(
});
}
-function getEventSortStart(
- event: CalendarEvent,
- timezoneID: string,
-): Instant {
+function getEventSortStart(event: CalendarEvent, timezoneID: string): Instant {
return isDayEvent(event)
? (plainDateToInstant(event.start, timezoneID) as Instant)
: event.start;
diff --git a/packages/themes/butter/package.json b/packages/themes/butter/package.json
index d13bcde684..34f86dce17 100644
--- a/packages/themes/butter/package.json
+++ b/packages/themes/butter/package.json
@@ -3,7 +3,7 @@
"version": "0.0.14",
"displayName": "Butter Theme",
"private": false,
- "description": "Warm, golden butter theme for XDS — creamy yellow palette with soft, inviting tones",
+ "description": "Warm, creamy yellows with a friendly blue accent. Playful enough for consumer surfaces, soft enough to stay readable.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/packages/themes/default/package.json b/packages/themes/default/package.json
index 9f1c325024..f20fd3a39a 100644
--- a/packages/themes/default/package.json
+++ b/packages/themes/default/package.json
@@ -3,7 +3,7 @@
"version": "0.0.14",
"displayName": "Default Theme",
"private": false,
- "description": "Clean neutrals with a blue accent. Pairs with Heroicons for a polished, professional look.",
+ "description": "Clean neutrals with a blue accent. The safe, professional starting point for any product.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/packages/themes/gothic/package.json b/packages/themes/gothic/package.json
index a21054ed70..9c968d6a08 100644
--- a/packages/themes/gothic/package.json
+++ b/packages/themes/gothic/package.json
@@ -3,7 +3,7 @@
"version": "0.0.14",
"displayName": "Gothic Theme",
"private": false,
- "description": "Dark gothic theme for XDS \u2014 deep blue-gray palette with Manufacturing Consent headings, Fustat body, and Lucide icons",
+ "description": "Deep blue-grays and a signature display serif. Dramatic and editorial, for surfaces that want to be remembered.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/packages/themes/matcha/package.json b/packages/themes/matcha/package.json
index 15709fbac2..fc292a692c 100644
--- a/packages/themes/matcha/package.json
+++ b/packages/themes/matcha/package.json
@@ -2,7 +2,7 @@
"name": "@xds/theme-matcha",
"version": "0.0.14",
"private": false,
- "description": "Matcha theme for XDS — earthy green palette with Figtree typography and Lucide icons",
+ "description": "Earthy greens with a calm, organic feel. Naturalistic and grounded, great for wellness or content-first apps.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/packages/themes/neutral/package.json b/packages/themes/neutral/package.json
index 25aa2d6690..aee90d99b7 100644
--- a/packages/themes/neutral/package.json
+++ b/packages/themes/neutral/package.json
@@ -3,7 +3,7 @@
"version": "0.0.14",
"displayName": "Neutral Theme",
"private": false,
- "description": "Understated warm grays with a subtle palette. Pairs with Lucide icons for a minimal, quiet aesthetic.",
+ "description": "Restrained warm grays. Minimal and quiet, so the content stays the focus.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/packages/themes/stone/package.json b/packages/themes/stone/package.json
index 18c81dce76..c0d9d119ea 100644
--- a/packages/themes/stone/package.json
+++ b/packages/themes/stone/package.json
@@ -3,7 +3,7 @@
"version": "0.0.14",
"displayName": "Stone Theme",
"private": false,
- "description": "Warm stone and slate theme for XDS \u2014 earthy neutral palette with Montserrat headings, Figtree body, and Lucide icons",
+ "description": "Warm stone and slate, earthy and understated, with just enough character to feel handcrafted.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/packages/themes/y2k/package.json b/packages/themes/y2k/package.json
index 23bc914241..ce7d33ca5a 100644
--- a/packages/themes/y2k/package.json
+++ b/packages/themes/y2k/package.json
@@ -3,7 +3,7 @@
"version": "0.0.14",
"displayName": "Y2K Theme",
"private": false,
- "description": "Bubbly Y2K pop theme for XDS — hot pink body, lime green accents, Poppins body, and playful categorical colors",
+ "description": "Hot pinks, lime greens, and Poppins. Bubbly, playful, and unmistakably retro.",
"author": "Meta Open Source",
"license": "MIT",
"homepage": "https://github.com/facebookexperimental/xds#readme",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4015038a11..90d0aca0e6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -108,6 +108,9 @@ importers:
'@xds/core':
specifier: '*'
version: link:../../packages/core
+ '@xds/theme-butter':
+ specifier: '*'
+ version: link:../../packages/themes/butter
'@xds/theme-default':
specifier: '*'
version: link:../../packages/themes/default
@@ -123,6 +126,9 @@ importers:
'@xds/theme-stone':
specifier: '*'
version: link:../../packages/themes/stone
+ '@xds/theme-y2k':
+ specifier: '*'
+ version: link:../../packages/themes/y2k
lz-string:
specifier: ^1.5.0
version: 1.5.0