Skip to content

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

TypeScript

fix(docsite): Unified doc page templates (#2511)

Kenton Quatmanc9bacb3906d3
diff --git a/apps/docsite/README.md b/apps/docsite/README.md
index 4f46a6031e..65dc81be34 100644
--- a/apps/docsite/README.md
+++ b/apps/docsite/README.md
@@ -79,7 +79,7 @@ them. Check the theme's `## Fonts` section for the specific Google Fonts URL.
3. Run `pnpm generate`
The package appears in the sidebar, the libraries section, and gets its own
-`/packages/<name>` detail page. If the package contains `.doc.mjs` files,
+`/docs/<name>` detail page. If the package contains `.doc.mjs` files,
its components are extracted into `componentRegistry.ts` as well.
## Project Structure
diff --git a/apps/docsite/src/app/(docs)/docs/[topic]/page.tsx b/apps/docsite/src/app/(docs)/docs/[topic]/page.tsx
index c4c00dab9c..d380566844 100644
--- a/apps/docsite/src/app/(docs)/docs/[topic]/page.tsx
+++ b/apps/docsite/src/app/(docs)/docs/[topic]/page.tsx
@@ -1,17 +1,22 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
/**
- * Page type: long-form-doc
- * Renders guide and foundation docs from the pipeline.
- * Content blocks (prose, code, table, list) rendered via ContentBlockRenderer.
- * Token topics (foundations category) render TokensDocView with live token tables.
+ * Unified docs-section template. Serves two kinds of slug:
+ * - long-form-doc: guide/foundation topics from docsRegistry, rendered via
+ * ContentBlockRenderer (TokensDocView for live token tables, otherwise
+ * ReferenceDocView).
+ * - package: non-theme @xds packages (e.g. @xds/core, @xds/cli), rendered as
+ * a README stub via PackageStubPage with install steps and an optional CTA.
+ * Theme packages are NOT served here — they live at /themes/<name>.
*/
import {notFound} from 'next/navigation';
-import {XDSSection} from '@xds/core/Section';
import {docTopics} from '../../../../generated/docsRegistry';
+import {packages} from '../../../../generated/packageRegistry';
import {ReferenceDocView} from '../../../../components/docs/ReferenceDocView';
import {TokensDocView} from '../../../../components/docs/TokensDocView';
+import {PackageStubPage} from '../../../../components/docs/PackageStubPage';
+import {type InstallStep} from '../../../../components/docs/PackageActions';
const TOKEN_TOPICS = new Set([
'tokens',
@@ -23,8 +28,41 @@ const TOKEN_TOPICS = new Set([
'typography',
]);
+function slugToPackageName(slug: string): string {
+ return `@xds/${slug}`;
+}
+
+function isThemePackage(name: string): boolean {
+ return name.includes('theme-');
+}
+
+function getInstallSteps(pkgName: string): InstallStep[] {
+ if (pkgName.endsWith('/cli')) {
+ return [
+ {label: 'Install the CLI', code: `npm install -D ${pkgName}`},
+ {label: 'Run a command', code: `npx xds component --list`},
+ ];
+ }
+ return [
+ {label: 'Install the package', code: `npm install ${pkgName}`},
+ {
+ label: 'Import a component',
+ code: `import {...} from '${pkgName}/ComponentName';`,
+ language: 'typescript',
+ },
+ ];
+}
+
+/** Sections to remove from the @xds/core README on the package page. */
+const CORE_STRIP_SECTIONS = ['Quick Start', 'Resources', 'XDS CLI'];
+
export function generateStaticParams() {
- return docTopics.map(d => ({topic: d.topic}));
+ return [
+ ...docTopics.map(d => ({topic: d.topic})),
+ ...packages
+ .filter(p => !isThemePackage(p.name))
+ .map(p => ({topic: p.name.replace('@xds/', '')})),
+ ];
}
export default async function DocPage({
@@ -33,30 +71,50 @@ export default async function DocPage({
params: Promise<{topic: string}>;
}) {
const {topic: slug} = await params;
+
const topic = docTopics.find(d => d.topic === slug);
- if (!topic) {
+ if (topic) {
+ const isTokenTopic =
+ topic.category === 'foundations' && TOKEN_TOPICS.has(topic.topic);
+
+ return isTokenTopic ? (
+ <TokensDocView
+ title={topic.title}
+ description={topic.description}
+ sections={topic.sections}
+ topic={topic.topic}
+ />
+ ) : (
+ <ReferenceDocView
+ title={topic.title}
+ description={topic.description}
+ sections={topic.sections}
+ />
+ );
+ }
+
+ const pkgName = slugToPackageName(slug);
+ const pkg = packages.find(p => p.name === pkgName && !isThemePackage(p.name));
+ if (!pkg) {
notFound();
}
- const isTokenTopic =
- topic.category === 'foundations' && TOKEN_TOPICS.has(topic.topic);
+ const isComponentPkg = pkg.name === '@xds/core';
return (
- <XDSSection maxWidth="lg" padding={6}>
- {isTokenTopic ? (
- <TokensDocView
- title={topic.title}
- description={topic.description}
- sections={topic.sections}
- topic={topic.topic}
- />
- ) : (
- <ReferenceDocView
- title={topic.title}
- description={topic.description}
- sections={topic.sections}
- />
- )}
- </XDSSection>
+ <PackageStubPage
+ name={pkg.name}
+ description={pkg.description}
+ version={pkg.version}
+ readme={pkg.readme}
+ installSteps={getInstallSteps(pkg.name)}
+ cta={
+ isComponentPkg
+ ? {label: 'View Components', href: '/components/Button'}
+ : undefined
+ }
+ stripSections={isComponentPkg ? CORE_STRIP_SECTIONS : undefined}
+ stripIntro={isComponentPkg}
+ />
);
}
diff --git a/apps/docsite/src/app/(docs)/docs/page.tsx b/apps/docsite/src/app/(docs)/docs/page.tsx
index 8968d3bc07..d3d2e5ce6c 100644
--- a/apps/docsite/src/app/(docs)/docs/page.tsx
+++ b/apps/docsite/src/app/(docs)/docs/page.tsx
@@ -1,332 +1,12 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
/**
- * Page type: overview
- * Home page — hero, libraries, foundations.
- * All data from pipeline registries.
+ * Page type: redirect
+ * /docs immediately reroutes to the Getting Started guide.
*/
-import * as stylex from '@stylexjs/stylex';
-import Link from 'next/link';
-import {XDSHeading, XDSText} from '@xds/core/Text';
-import {XDSVStack, XDSHStack} from '@xds/core/Layout';
-import {XDSGrid} from '@xds/core/Grid';
-import {XDSSection} from '@xds/core/Section';
-import {XDSButton} from '@xds/core/Button';
-import {XDSMediaTheme} from '@xds/core/theme';
-import {XDSLink} from '@xds/core/Link';
-import {ThemedPreview} from '../../../components/ThemedPreview';
-import {packages} from '../../../generated/packageRegistry';
-import {componentCount} from '../../../generated/componentRegistry';
-import {docTopics} from '../../../generated/docsRegistry';
-import {ThemeShowcaseTile} from '../../../components/ThemeShowcaseTile';
-import {themeObjects} from '../../../generated/themeRegistry';
+import {redirect} from 'next/navigation';
-const TerminalIcon = (props: React.SVGProps<SVGSVGElement>) => (
- <svg
- aria-hidden="true"
- width="48"
- height="48"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- {...props}>
- <path d="m7 11 2-2-2-2" />
- <path d="M11 13h4" />
- <rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
- </svg>
-);
-
-const CodeIcon = (props: React.SVGProps<SVGSVGElement>) => (
- <svg
- aria-hidden="true"
- width="48"
- height="48"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- {...props}>
- <path d="m18 16 4-4-4-4" />
- <path d="m6 8-4 4 4 4" />
- <path d="m14.5 4-5 16" />
- </svg>
-);
-
-const PACKAGE_ICONS: Record<string, React.ReactNode> = {
- '@xds/cli': <TerminalIcon />,
- '@xds/core': <CodeIcon />,
-};
-
-const PACKAGE_IMAGES: Record<string, string> = {
- '@xds/cli': '/LibrariesCli.png',
- '@xds/core': '/LibrariesCore.png',
-};
-
-const foundationImages: Record<string, string> = {
- color: '/FoundationsColors.png',
- icons: '/FoundationsIcons.png',
- shape: '/FoundationsShape.png',
- spacing: '/FoundationsSpacing.png',
- typography: '/FoundationsTypogrpahy.png',
-};
-
-const styles = stylex.create({
- pageContainer: {
- maxWidth: 1200,
- marginInline: 'auto',
- paddingInline: {
- default: 16,
- '@media (min-width: 768px)': 40,
- },
- paddingBlockStart: 0,
- paddingBlockEnd: 32,
- },
- heroContainer: {
- position: 'relative',
- borderRadius: 16,
- overflow: 'hidden',
- backgroundColor: 'var(--color-background-card)',
- backgroundImage: 'url(/hero-bg.png)',
- backgroundSize: 'cover',
- backgroundPosition: 'center',
- minHeight: 300,
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- justifyContent: 'center',
- padding: {
- default: '48px 24px',
- '@media (min-width: 768px)': 48,
- },
- },
- heroTitle: {
- textAlign: 'center' as const,
- },
- heroSubtitle: {
- textAlign: 'center' as const,
- marginTop: 8,
- },
- heroDescription: {
- maxWidth: 480,
- marginTop: 4,
- fontSize: 16,
- lineHeight: 1.5,
- textAlign: 'center' as const,
- },
- heroButtons: {
- marginTop: 24,
- },
- foundationImage: {
- display: 'block',
- width: '100%',
- aspectRatio: '2/1',
- objectFit: 'cover' as const,
- borderRadius: 12,
- marginBottom: 12,
- backgroundColor: 'var(--color-background-card)',
- },
- packageImageWrapper: {
- aspectRatio: '2/1',
- backgroundSize: 'cover',
- backgroundPosition: 'center',
- borderRadius: 12,
- position: 'relative' as const,
- marginBottom: 12,
- backgroundColor: 'var(--color-background-card)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- },
- packageIconOverlay: {
- color: '#484233',
- opacity: 0.8,
- },
- monoText: {
- fontFamily: 'monospace',
- },
- versionText: {
- marginLeft: 8,
- },
- linkReset: {
- textDecoration: 'none',
- color: 'inherit',
- cursor: 'pointer',
- },
-});
-
-const foundationTopics = docTopics
- .filter(d => d.category === 'foundations')
- .sort((a, b) => {
- if (a.topic === 'tokens') {
- return -1;
- }
- if (b.topic === 'tokens') {
- return 1;
- }
- return a.title.localeCompare(b.title);
- });
-
-export default function HomePage() {
- const coreCount = componentCount;
-
- return (
- <div {...stylex.props(styles.pageContainer)}>
- <XDSSection padding={0}>
- <XDSVStack gap={10} style={{rowGap: 60}}>
- {/* Hero */}
- <div {...stylex.props(styles.heroContainer)}>
- <XDSMediaTheme mode="light">
- <XDSText type="large" weight="semibold" xstyle={styles.heroTitle}>
- Astryx
- </XDSText>
- <XDSText type="display-1" xstyle={styles.heroSubtitle}>
- Build with AI
- </XDSText>
- <XDSText
- type="body"
- color="secondary"
- xstyle={styles.heroDescription}>
- An open design system for building internal tools with
- AI-powered development. Ship faster with {coreCount} accessible,
- themeable components. Made with{' '}
- <XDSLink
- type="inherit"
- color="secondary"
- href="https://react.dev">
- React
- </XDSLink>
- {' and '}
- <XDSLink
- type="inherit"
- color="secondary"
- href="https://stylexjs.com">
- StyleX
- </XDSLink>
- .
- </XDSText>
- <XDSHStack gap={3} xstyle={styles.heroButtons}>
- <XDSButton
- variant="primary"
- label="Get started"
- href="/docs/getting-started"
- />
- <XDSButton
- variant="secondary"
- label="Browse components"
- href="/packages/core"
- />
- </XDSHStack>
- </XDSMediaTheme>
- </div>
-
- {/* Libraries & Packages */}
- <XDSVStack gap={5}>
- <XDSVStack gap={1}>
- <XDSHeading level={2}>Libraries &amp; packages</XDSHeading>
- <XDSText type="body" color="secondary">
- Install what you need. All packages are published under the @xds
- scope.
- </XDSText>
- </XDSVStack>
- <XDSGrid
- columns={{minWidth: 260, repeat: 'fit'}}
- gap={4}
- rowGap={8}>
- {packages.map(pkg => {
- const theme = themeObjects[pkg.name];
- const image = PACKAGE_IMAGES[pkg.name] ?? '/LibrariesCore.png';
- const icon = PACKAGE_ICONS[pkg.name] ?? null;
-
- return (
- <Link
- key={pkg.name}
- href={`/packages/${pkg.name.replace('@xds/', '')}`}
- {...stylex.props(styles.linkReset)}>
- {theme ? (
- <ThemedPreview theme={theme}>
- <div {...stylex.props(styles.packageImageWrapper)}>
- <ThemeShowcaseTile label={pkg.displayName} />
- </div>
- </ThemedPreview>
- ) : (
- <div
- {...stylex.props(styles.packageImageWrapper)}
- style={{backgroundImage: `url(${image})`}}>
- {icon && (
- <div {...stylex.props(styles.packageIconOverlay)}>
- {icon}
- </div>
- )}
- </div>
- )}
- <XDSVStack gap={0.5}>
- <span {...stylex.props(styles.monoText)}>
- <XDSText type="body" weight="bold">
- {pkg.name}
- </XDSText>
- <span {...stylex.props(styles.versionText)}>
- <XDSText type="supporting" color="secondary">
- v{pkg.version}
- </XDSText>
- </span>
- </span>
- <XDSText type="supporting" color="secondary">
- {pkg.description}
- </XDSText>
- </XDSVStack>
- </Link>
- );
- })}
- </XDSGrid>
- </XDSVStack>
-
- {/* Foundations */}
- <XDSVStack gap={5}>
- <XDSVStack gap={1}>
- <XDSHeading level={2}>Foundations</XDSHeading>
- <XDSText type="body" color="secondary">
- The design tokens and primitives that every component is built
- on.
- </XDSText>
- </XDSVStack>
- <XDSGrid
- columns={{minWidth: 300, repeat: 'fit'}}
- gap={4}
- rowGap={8}>
- {foundationTopics.map(topic => (
- <Link
- key={topic.topic}
- href={`/docs/${topic.topic}`}
- {...stylex.props(styles.linkReset)}>
- {foundationImages[topic.topic] ? (
- <img
- src={foundationImages[topic.topic]}
- alt={topic.title}
- {...stylex.props(styles.foundationImage)}
- />
- ) : (
- <div {...stylex.props(styles.foundationImage)} />
- )}
- <XDSVStack gap={1}>
- <XDSText type="body" weight="bold">
- {topic.title}
- </XDSText>
- <XDSText type="supporting" color="secondary">
- {topic.description}
- </XDSText>
- </XDSVStack>
- </Link>
- ))}
- </XDSGrid>
- </XDSVStack>
- </XDSVStack>
- </XDSSection>
- </div>
- );
+export default function DocsIndexPage() {
+ redirect('/docs/getting-started');
}
diff --git a/apps/docsite/src/app/(docs)/packages/[name]/ComponentPreviewCard.tsx b/apps/docsite/src/app/(docs)/packages/[name]/ComponentPreviewCard.tsx
deleted file mode 100644
index 2fc8a478a8..0000000000
--- a/apps/docsite/src/app/(docs)/packages/[name]/ComponentPreviewCard.tsx
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-import {
- useRef,
- useState,
- useEffect,
- useCallback,
- Suspense,
- type ComponentType,
-} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {XDSText} from '@xds/core/Text';
-import {XDSVStack} from '@xds/core/Layout';
-import {XDSClickableCard} from '@xds/core/ClickableCard';
-import {XDSSkeleton} from '@xds/core/Skeleton';
-import {showcaseRegistry} from '../../../../generated/showcaseRegistry';
-
-const FIXED_SCALE = 0.5;
-
-const styles = stylex.create({
- thumbnail: {
- width: '100%',
- aspectRatio: '16/10',
- overflow: 'hidden',
- position: 'relative' as const,
- borderRadius: 'var(--radius-container)',
- backgroundColor: 'var(--color-background-muted)',
- contentVisibility: 'auto',
- containIntrinsicSize: 'auto 300px 187px',
- },
- scaler: {
- position: 'absolute' as const,
- top: 0,
- left: 0,
- height: '200%',
- transformOrigin: 'top left',
- pointerEvents: 'none' as const,
- overflow: 'hidden',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- },
- placeholder: {
- width: '100%',
- aspectRatio: '16/10',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- backgroundColor: 'var(--color-background-muted)',
- borderRadius: 'var(--radius-container)',
- },
- textContent: {
- padding: '0 var(--spacing-2) var(--spacing-1)',
- },
-});
-
-function ComponentThumbnail({name}: {name: string}) {
- const containerRef = useRef<HTMLDivElement>(null);
- const [renderWidth, setRenderWidth] = useState(0);
- const [isVisible, setIsVisible] = useState(false);
- const [Component, setComponent] = useState<ComponentType | null>(null);
- const [error, setError] = useState(false);
-
- const updateWidth = useCallback(() => {
- if (containerRef.current) {
- setRenderWidth(containerRef.current.offsetWidth / FIXED_SCALE);
- }
- }, []);
-
- useEffect(() => {
- const loader = showcaseRegistry[name];
- if (!loader) {
- setError(true);
- return;
- }
- loader()
- .then(mod => setComponent(() => mod.default))
- .catch(() => setError(true));
- }, [name]);
-
- useEffect(() => {
- const el = containerRef.current;
- if (!el) {
- return;
- }
- const observer = new IntersectionObserver(
- ([entry]) => setIsVisible(entry.isIntersecting),
- {rootMargin: '200px'},
- );
- observer.observe(el);
- return () => observer.disconnect();
- }, []);
-
- useEffect(() => {
- updateWidth();
- const el = containerRef.current;
- if (!el) {
- return;
- }
- const ro = new ResizeObserver(updateWidth);
- ro.observe(el);
- return () => ro.disconnect();
- }, [updateWidth]);
-
- if (error) {
- return (
- <div {...stylex.props(styles.placeholder)}>
- <XDSText type="supporting" color="secondary">
- {name}
- </XDSText>
- </div>
- );
- }
-
- return (
- <div ref={containerRef} {...stylex.props(styles.thumbnail)} inert>
- {renderWidth > 0 && isVisible && Component && (
- <div
- {...stylex.props(styles.scaler)}
- style={{width: renderWidth, transform: `scale(${FIXED_SCALE})`}}>
- <Suspense fallback={<XDSSkeleton width="100%" height="100%" />}>
- <Component />
- </Suspense>
- </div>
- )}
- </div>
- );
-}
-
-interface ComponentPreviewCardProps {
- name: string;
- href: string;
- description: string;
- groupSize: number;
-}
-
-export function ComponentPreviewCard({
- name,
- href,
- description,
- groupSize,
-}: ComponentPreviewCardProps) {
- return (
- <XDSClickableCard
- label={name}
- href={href}
- variant="transparent"
- padding={0}>
- <XDSVStack gap={2}>
- <ComponentThumbnail name={name} />
- <div {...stylex.props(styles.textContent)}>
- <XDSVStack gap={0.5}>
- <XDSText type="body" weight="bold">
- {name}
- {groupSize > 1 ? (
- <XDSText type="supporting" color="secondary">
- {' '}
- +{groupSize - 1}
- </XDSText>
- ) : null}
- </XDSText>
- <XDSText type="supporting" color="secondary">
- {description}
- </XDSText>
- </XDSVStack>
- </div>
- </XDSVStack>
- </XDSClickableCard>
- );
-}
diff --git a/apps/docsite/src/app/(docs)/packages/[name]/PackageHeading.tsx b/apps/docsite/src/app/(docs)/packages/[name]/PackageHeading.tsx
deleted file mode 100644
index 40425555d5..0000000000
--- a/apps/docsite/src/app/(docs)/packages/[name]/PackageHeading.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-import {XDSText} from '@xds/core/Text';
-import {XDSVStack, XDSHStack} from '@xds/core/Layout';
-import {XDSPopover} from '@xds/core/Popover';
-import {XDSCodeBlock} from '@xds/core/CodeBlock';
-import {XDSButton} from '@xds/core/Button';
-import {XDSCard} from '@xds/core/Card';
-
-export interface InstallStep {
- label: string;
- code: string;
- language?: string;
-}
-
-interface PackageHeadingProps {
- packageName: string;
- description?: string;
- version?: string;
- installSteps?: InstallStep[];
- cta?: {label: string; href: string};
-}
-
-export function PackageHeading({
- packageName,
- description,
- version,
- installSteps,
- cta,
-}: PackageHeadingProps) {
- const steps = installSteps ?? [
- {label: 'Install the package', code: `npm install ${packageName}`},
- {
- label: 'Import',
- code: `import {...} from '${packageName}';`,
- language: 'typescript',
- },
- ];
-
- return (
- <XDSVStack gap={1}>
- {version && (
- <XDSText type="supporting" color="secondary">
- v{version}
- </XDSText>
- )}
- <XDSHStack vAlign="center" hAlign="between">
- <XDSText type="display-1">{packageName}</XDSText>
- <XDSHStack gap={2}>
- {cta && (
- <XDSButton label={cta.label} href={cta.href} variant="secondary" />
- )}
- <XDSPopover
- width={360}
- content={
- <XDSVStack gap={3}>
- {steps.map((step, i) => (
- <XDSVStack key={i} gap={1}>
- <XDSText type="body" weight="bold">
- {i + 1}. {step.label}
- </XDSText>
- <XDSCard padding={0}>
- <XDSCodeBlock
- code={step.code}
- language={step.language ?? 'bash'}
- hasCopyButton
- />
- </XDSCard>
- </XDSVStack>
- ))}
- </XDSVStack>
- }>
- <XDSButton label="Install" variant="primary" />
- </XDSPopover>
- </XDSHStack>
- </XDSHStack>
- {description && (
- <XDSText type="body" color="secondary">
- {description}
- </XDSText>
- )}
- </XDSVStack>
- );
-}
diff --git a/apps/docsite/src/app/(docs)/packages/[name]/page.tsx b/apps/docsite/src/app/(docs)/packages/[name]/page.tsx
deleted file mode 100644
index 911536febc..0000000000
--- a/apps/docsite/src/app/(docs)/packages/[name]/page.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-/**
- * Page type: package
- * Adapts based on the package type:
- * - component-pkg (@xds/core): stub page with CTA to browse components
- * - theme-pkg (@xds/theme-*): redirects to the canonical /themes/<name>
- * page on the themes side of the site (one URL per theme).
- * - generic (@xds/cli, etc.): README rendered via XDSMarkdown
- */
-
-import {notFound, redirect} from 'next/navigation';
-import {XDSSection} from '@xds/core/Section';
-import {packages} from '../../../../generated/packageRegistry';
-import {type InstallStep} from './PackageHeading';
-import {themeObjects} from '../../../../generated/themeRegistry';
-import {PackageStubPage} from './PackageStubPage';
-
-function slugToPackageName(slug: string): string {
- return `@xds/${slug}`;
-}
-
-function getInstallSteps(pkgName: string): InstallStep[] {
- if (pkgName.includes('theme-')) {
- const shortName = pkgName.replace('@xds/theme-', '');
- const varName = shortName + 'Theme';
- return [
- {label: 'Install the theme', code: `npm install ${pkgName}`},
- {
- label: 'Import the built theme',
- code: `import {${varName}} from '${pkgName}/built';`,
- language: 'typescript',
- },
- {
- label: 'Wrap your app',
- code: `<XDSTheme theme={${varName}}>{children}</XDSTheme>`,
- language: 'tsx',
- },
- ];
- }
- if (pkgName.endsWith('/cli')) {
- return [
- {label: 'Install the CLI', code: `npm install -D ${pkgName}`},
- {label: 'Run a command', code: `npx xds component --list`},
- ];
- }
- return [
- {label: 'Install the package', code: `npm install ${pkgName}`},
- {
- label: 'Import a component',
- code: `import {...} from '${pkgName}/ComponentName';`,
- language: 'typescript',
- },
- ];
-}
-
-/** Sections to remove from the @xds/core README on the package page. */
-const CORE_STRIP_SECTIONS = [
- 'Quick Start',
- 'Resources',
- 'XDS CLI',
-];
-
-/**
- * Rewrite the @xds/core README intro to incorporate the package description
- * and remove the now-dead Quick Start cross-reference.
- */
-function rewriteCoreReadme(readme: string | null): string | null {
- if (!readme) {
- return null;
- }
- return readme.replace(
- /Core UI components, theme system, and utilities for the XDS design system\..*?(?=\n)/,
- 'Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling — the core building blocks of the XDS design system.',
- );
-}
-
-export function generateStaticParams() {
- return packages.map(p => ({name: p.name.replace('@xds/', '')}));
-}
-
-export default async function PackagePage({
- params,
-}: {
- params: Promise<{name: string}>;
-}) {
- const {name: slug} = await params;
- const pkgName = slugToPackageName(slug);
- const pkg = packages.find(p => p.name === pkgName);
- if (!pkg) {
- notFound();
- }
-
- const isTheme = pkg.name.includes('theme-');
- const isComponentPkg = pkg.name === '@xds/core';
-
- // Theme packages live on /themes/<name> — the canonical surface for
- // each theme, hosting the full ThemeShowcasePreview alongside the
- // install affordance and README. Redirect every /packages/theme-*
- // hit (incoming links, search results, bookmarks) to that page so
- // there is one URL per theme.
- if (isTheme && themeObjects[pkg.name]) {
- const themeSlug = pkg.name.replace('@xds/theme-', '');
- redirect(`/themes/${themeSlug}`);
- }
-
- if (!isComponentPkg) {
- return (
- <XDSSection maxWidth="lg" padding={6}>
- <PackageStubPage
- name={pkg.name}
- version={pkg.version}
- readme={pkg.readme}
- installSteps={getInstallSteps(pkg.name)}
- />
- </XDSSection>
- );
- }
-
- return (
- <XDSSection maxWidth="lg" padding={6}>
- <PackageStubPage
- name={pkg.name}
- version={pkg.version}
- readme={rewriteCoreReadme(pkg.readme)}
- installSteps={getInstallSteps(pkg.name)}
- cta={{label: 'View Components', href: '/components/Button'}}
- stripSections={CORE_STRIP_SECTIONS}
- />
- </XDSSection>
- );
-}
diff --git a/apps/docsite/src/app/(site)/themes/[name]/page.tsx b/apps/docsite/src/app/(site)/themes/[name]/page.tsx
index b8b6769452..ce5f99b0f6 100644
--- a/apps/docsite/src/app/(site)/themes/[name]/page.tsx
+++ b/apps/docsite/src/app/(site)/themes/[name]/page.tsx
@@ -11,8 +11,8 @@
* the destination for the "Preview" affordance on the /themes
* gallery cards.
*
- * The /packages/theme-* route redirects here so there is a single
- * canonical URL per theme (see (docs)/packages/[name]/page.tsx).
+ * This is the canonical URL per theme. Theme entry points (gallery
+ * cards, sidebar, search) link here directly.
*/
import {notFound} from 'next/navigation';
diff --git a/apps/docsite/src/app/layout.tsx b/apps/docsite/src/app/layout.tsx
index d3fbcbfedc..fb58e84bd0 100644
--- a/apps/docsite/src/app/layout.tsx
+++ b/apps/docsite/src/app/layout.tsx
@@ -12,9 +12,9 @@ import {Providers} from './providers';
// "Good" path from the theming wiki §Font Declarations.
export const metadata: Metadata = {
- title: 'Astryx — Design System',
+ title: 'Astryx Design System',
description:
- 'Open-source design system for building internal tools and products.',
+ 'An open source design system that is fully customizable and agent ready.',
icons: {
icon: '/favicon.svg',
},
diff --git a/apps/docsite/src/app/playground/PropertyPanel.tsx b/apps/docsite/src/app/playground/PropertyPanel.tsx
index 800c022eb6..8f9967bd7b 100644
--- a/apps/docsite/src/app/playground/PropertyPanel.tsx
+++ b/apps/docsite/src/app/playground/PropertyPanel.tsx
@@ -315,7 +315,7 @@ export function PropertyPanel({
<div {...stylex.props(s.emptyWrap)}>
<XDSEmptyState
title="No components detected"
- description="Add an XDS component in the Code tab to edit its props here."
+ description="Add a component in the Code tab to view properties."
isCompact
/>
</div>
diff --git a/apps/docsite/src/components/ChangelogView.tsx b/apps/docsite/src/components/ChangelogView.tsx
index 94167d05e5..4543d19b9e 100644
--- a/apps/docsite/src/components/ChangelogView.tsx
+++ b/apps/docsite/src/components/ChangelogView.tsx
@@ -80,7 +80,7 @@ export function ChangelogView({
<XDSVStack gap={2}>
<XDSHeading level={1}>What&apos;s New</XDSHeading>
<XDSText type="body" color="secondary">
- Release notes and changelog for XDS packages.
+ Release notes and changelog for all packages.
</XDSText>
</XDSVStack>
diff --git a/apps/docsite/src/components/DocsShell.tsx b/apps/docsite/src/components/DocsShell.tsx
index 10820c9a43..cc07e1a377 100644
--- a/apps/docsite/src/components/DocsShell.tsx
+++ b/apps/docsite/src/components/DocsShell.tsx
@@ -105,9 +105,10 @@ export function DocsShell({
const isTheme = (p: PackageMeta) => p.name.includes('theme-');
const libraryPackages = packages.filter(p => !isTheme(p));
- // Classify doc topics by category (from data)
+ // Classify doc topics by category (from data). Getting Started is promoted
+ // to a top-level nav item, so it is excluded from the Guide section.
const guideTopics = docTopics
- .filter(d => d.category === 'guide')
+ .filter(d => d.category === 'guide' && d.topic !== 'getting-started')
.sort((a, b) => a.title.localeCompare(b.title));
const foundationTopics = docTopics
.filter(d => d.category === 'foundations')
@@ -129,12 +130,12 @@ export function DocsShell({
<XDSSideNav>
{!isOnComponentsRoute && (
<>
- {/* Documentation */}
- <XDSSideNavSection title="Documentation" isHeaderHidden>
+ {/* Getting Started */}
+ <XDSSideNavSection title="Getting Started" isHeaderHidden>
<XDSSideNavItem
- label="Documentation"
- href="/docs"
- isSelected={pathname === '/docs'}
+ label="Getting Started"
+ href="/docs/getting-started"
+ isSelected={pathname === '/docs/getting-started'}
/>
</XDSSideNavSection>
@@ -188,9 +189,9 @@ export function DocsShell({
<XDSSideNavItem
key={p.name}
label={p.name}
- href={`/packages/${p.name.replace('@xds/', '')}`}
+ href={`/docs/${p.name.replace('@xds/', '')}`}
isSelected={
- pathname === `/packages/${p.name.replace('@xds/', '')}`
+ pathname === `/docs/${p.name.replace('@xds/', '')}`
}
/>
))}
diff --git a/apps/docsite/src/components/SearchPalette.tsx b/apps/docsite/src/components/SearchPalette.tsx
index f8bb882067..9baf9b7b23 100644
--- a/apps/docsite/src/components/SearchPalette.tsx
+++ b/apps/docsite/src/components/SearchPalette.tsx
@@ -55,8 +55,11 @@ export function SearchPalette({
}
for (const pkg of packages) {
+ const isTheme = pkg.name.includes('theme-');
items.push({
- id: `/packages/${pkg.name.replace('@xds/', '')}`,
+ id: isTheme
+ ? `/themes/${pkg.name.replace('@xds/theme-', '')}`
+ : `/docs/${pkg.name.replace('@xds/', '')}`,
label: pkg.displayName,
auxiliaryData: {group: 'Package'},
});
diff --git a/apps/docsite/src/components/SharedTopNav.tsx b/apps/docsite/src/components/SharedTopNav.tsx
index 3308e2b49f..7328ff416d 100644
--- a/apps/docsite/src/components/SharedTopNav.tsx
+++ b/apps/docsite/src/components/SharedTopNav.tsx
@@ -9,7 +9,7 @@ import {XDSButton} from '@xds/core/Button';
import {XDSHStack} from '@xds/core/Layout';
import {Search, HandHeart, Sun, Moon} from 'lucide-react';
import {GITHUB_REPO} from '../constants';
-import {XDS_BRAND_ICON} from './XDSWordmark';
+import {BRAND_ICON} from './XDSWordmark';
import {SearchPalette} from './SearchPalette';
import {components} from '../generated/componentRegistry';
import {packages} from '../generated/packageRegistry';
@@ -44,7 +44,6 @@ export function SharedTopNav() {
if (
pathname === '/docs' ||
pathname.startsWith('/docs/') ||
- pathname.startsWith('/packages/') ||
pathname.startsWith('/changelog')
) {
return 'docs';
@@ -68,7 +67,7 @@ export function SharedTopNav() {
<>
<XDSTopNav
label="Astryx navigation"
- heading={<XDSTopNavHeading logo={XDS_BRAND_ICON} headingHref="/" />}
+ heading={<XDSTopNavHeading logo={BRAND_ICON} headingHref="/" />}
centerContent={
<>
<XDSTopNavItem
diff --git a/apps/docsite/src/components/ThemedPreview.tsx b/apps/docsite/src/components/ThemedPreview.tsx
deleted file mode 100644
index 3bfb8e0353..0000000000
--- a/apps/docsite/src/components/ThemedPreview.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-import {XDSTheme} from '@xds/core/theme';
-import type {ReactNode} from 'react';
-import {useThemeMode} from '../app/providers';
-
-/**
- * Client wrapper that applies a given theme with the site's active mode.
- * Use in server components that can't call useThemeMode directly.
- */
-export function ThemedPreview({
- theme,
- children,
-}: {
- theme: Parameters<typeof XDSTheme>[0]['theme'];
- children: ReactNode;
-}) {
- const {mode} = useThemeMode();
- return (
- <XDSTheme theme={theme} mode={mode}>
- {children}
- </XDSTheme>
- );
-}
diff --git a/apps/docsite/src/components/XDSWordmark.tsx b/apps/docsite/src/components/XDSWordmark.tsx
index 0b550e665c..88344957ef 100644
--- a/apps/docsite/src/components/XDSWordmark.tsx
+++ b/apps/docsite/src/components/XDSWordmark.tsx
@@ -2,7 +2,7 @@
// Brand mark used in shell chrome (top nav). Renders the icon-only logo
// from /public/brand-icon.svg so the wordmark is replaced by the icon.
-export const XDS_BRAND_ICON = (
+export const BRAND_ICON = (
<img
src="/brand-icon.svg"
alt="Astryx"
diff --git a/apps/docsite/src/components/docs/DocPageLayout.tsx b/apps/docsite/src/components/docs/DocPageLayout.tsx
new file mode 100644
index 0000000000..22578de076
--- /dev/null
+++ b/apps/docsite/src/components/docs/DocPageLayout.tsx
@@ -0,0 +1,39 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * Shared layout shell for every page in the docs section.
+ * Owns the section padding, content container width, title and description
+ * treatment, and vertical spacing. Pages supply only their unique body via
+ * `children`.
+ */
+
+import type {ReactNode} from 'react';
+import {XDSText} from '@xds/core/Text';
+import {XDSVStack} from '@xds/core/Layout';
+import {XDSSection} from '@xds/core/Section';
+
+export function DocPageLayout({
+ title,
+ description,
+ children,
+}: {
+ title: string;
+ description?: string;
+ children: ReactNode;
+}) {
+ return (
+ <XDSSection maxWidth={800} padding={6} style={{marginInline: 'auto'}}>
+ <XDSVStack gap={8}>
+ <XDSVStack gap={2}>
+ <XDSText type="display-2">{title}</XDSText>
+ {description ? (
+ <XDSText type="body" color="secondary">
+ {description}
+ </XDSText>
+ ) : null}
+ </XDSVStack>
+ {children}
+ </XDSVStack>
+ </XDSSection>
+ );
+}
diff --git a/apps/docsite/src/components/docs/PackageActions.tsx b/apps/docsite/src/components/docs/PackageActions.tsx
new file mode 100644
index 0000000000..4f5adcf692
--- /dev/null
+++ b/apps/docsite/src/components/docs/PackageActions.tsx
@@ -0,0 +1,81 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+import {XDSText} from '@xds/core/Text';
+import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {XDSPopover} from '@xds/core/Popover';
+import {XDSCodeBlock} from '@xds/core/CodeBlock';
+import {XDSButton} from '@xds/core/Button';
+import {XDSCard} from '@xds/core/Card';
+
+export interface InstallStep {
+ label: string;
+ code: string;
+ language?: string;
+}
+
+interface PackageActionsProps {
+ packageName: string;
+ version?: string;
+ installSteps?: InstallStep[];
+ cta?: {label: string; href: string};
+}
+
+/**
+ * Package-only affordances rendered in the page body: version label, the
+ * Install popover, and an optional CTA. The title and description come from
+ * the shared DocPageLayout, so they are intentionally absent here.
+ */
+export function PackageActions({
+ packageName,
+ version,
+ installSteps,
+ cta,
+}: PackageActionsProps) {
+ const steps = installSteps ?? [
+ {label: 'Install the package', code: `npm install ${packageName}`},
+ {
+ label: 'Import',
+ code: `import {...} from '${packageName}';`,
+ language: 'typescript',
+ },
+ ];
+
+ return (
+ <XDSVStack gap={2}>
+ {version && (
+ <XDSText type="supporting" color="secondary">
+ v{version}
+ </XDSText>
+ )}
+ <XDSHStack gap={2}>
+ <XDSPopover
+ width={360}
+ content={
+ <XDSVStack gap={3}>
+ {steps.map((step, i) => (
+ <XDSVStack key={i} gap={1}>
+ <XDSText type="body" weight="bold">
+ {i + 1}. {step.label}
+ </XDSText>
+ <XDSCard padding={0}>
+ <XDSCodeBlock
+ code={step.code}
+ language={step.language ?? 'bash'}
+ hasCopyButton
+ />
+ </XDSCard>
+ </XDSVStack>
+ ))}
+ </XDSVStack>
+ }>
+ <XDSButton label="Install" variant="primary" />
+ </XDSPopover>
+ {cta && (
+ <XDSButton label={cta.label} href={cta.href} variant="secondary" />
+ )}
+ </XDSHStack>
+ </XDSVStack>
+ );
+}
diff --git a/apps/docsite/src/app/(docs)/packages/[name]/PackageStubPage.tsx b/apps/docsite/src/components/docs/PackageStubPage.tsx
similarity index 50%
rename from apps/docsite/src/app/(docs)/packages/[name]/PackageStubPage.tsx
rename to apps/docsite/src/components/docs/PackageStubPage.tsx
index 44a5eb8f17..d27c62ae18 100644
--- a/apps/docsite/src/app/(docs)/packages/[name]/PackageStubPage.tsx
+++ b/apps/docsite/src/components/docs/PackageStubPage.tsx
@@ -2,18 +2,11 @@
'use client';
-import stylex from '@stylexjs/stylex';
import {XDSVStack} from '@xds/core/Layout';
import {XDSText} from '@xds/core/Text';
import {XDSMarkdown} from '@xds/core/Markdown';
-import {PackageHeading, type InstallStep} from './PackageHeading';
-
-const styles = stylex.create({
- container: {
- maxWidth: 800,
- marginInline: 'auto',
- },
-});
+import {DocPageLayout} from './DocPageLayout';
+import {PackageActions, type InstallStep} from './PackageActions';
interface PackageStubPageProps {
name: string;
@@ -24,6 +17,13 @@ interface PackageStubPageProps {
cta?: {label: string; href: string};
/** Markdown section headings (## level) to strip from the README */
stripSections?: string[];
+ /**
+ * Drop the README's leading intro prose (everything before the first `##`
+ * section). The canonical short description already renders as the page
+ * subtitle via `description`, so this avoids duplicating it — and removes any
+ * cross-references in the intro that point at stripped sections.
+ */
+ stripIntro?: boolean;
}
export function PackageStubPage({
@@ -34,9 +34,15 @@ export function PackageStubPage({
installSteps,
cta,
stripSections,
+ stripIntro,
}: PackageStubPageProps) {
let body = readme ? readme.replace(/^# .+\n+/, '') : null;
+ if (body && stripIntro) {
+ // Remove leading prose up to the first ## section heading.
+ body = body.replace(/^[\s\S]*?(?=\n## |^## )/, '').trimStart();
+ }
+
if (body && stripSections && stripSections.length > 0) {
for (const section of stripSections) {
// Remove ## Section through to the next ## or end of string
@@ -50,23 +56,24 @@ export function PackageStubPage({
}
return (
- <XDSVStack gap={8} xstyle={styles.container}>
- <PackageHeading
- packageName={name}
- version={version}
- description={description}
- installSteps={installSteps}
- cta={cta}
- />
- {body ? (
- <XDSMarkdown headingLevelStart={3} contentWidth={800}>
- {body}
- </XDSMarkdown>
- ) : (
- <XDSText type="body" color="secondary">
- No README available.
- </XDSText>
- )}
- </XDSVStack>
+ <DocPageLayout title={name} description={description}>
+ <XDSVStack gap={8}>
+ <PackageActions
+ packageName={name}
+ version={version}
+ installSteps={installSteps}
+ cta={cta}
+ />
+ {body ? (
+ <XDSMarkdown headingLevelStart={3} contentWidth={800}>
+ {body}
+ </XDSMarkdown>
+ ) : (
+ <XDSText type="body" color="secondary">
+ No README available.
+ </XDSText>
+ )}
+ </XDSVStack>
+ </DocPageLayout>
);
}
diff --git a/apps/docsite/src/components/docs/ReferenceDocView.tsx b/apps/docsite/src/components/docs/ReferenceDocView.tsx
index a5cb8ed485..da4a002c01 100644
--- a/apps/docsite/src/components/docs/ReferenceDocView.tsx
+++ b/apps/docsite/src/components/docs/ReferenceDocView.tsx
@@ -2,20 +2,15 @@
'use client';
-import * as stylex from '@stylexjs/stylex';
import {XDSText} from '@xds/core/Text';
import {XDSVStack} from '@xds/core/Layout';
import {XDSSection} from '@xds/core/Section';
import {ContentBlockRenderer} from './ContentBlockRenderer';
import {BestPracticesBlock} from './BestPracticesBlock';
+import {DocPageLayout} from './DocPageLayout';
import type {DocSection} from '../../generated/docsRegistry';
import type {ReactNode} from 'react';
-const styles = stylex.create({
- container: {maxWidth: 1200, marginInline: 'auto'},
- prose: {maxWidth: 800},
-});
-
export type SectionOverrides = Record<
string,
(section: DocSection) => ReactNode
@@ -60,13 +55,7 @@ export function ReferenceDocView({
sectionOverrides?: SectionOverrides;
}) {
return (
- <XDSVStack gap={8} xstyle={styles.container}>
- <XDSVStack gap={2}>
- <XDSText type="display-2">{title}</XDSText>
- <XDSText type="body" color="secondary" xstyle={styles.prose}>
- {description}
- </XDSText>
- </XDSVStack>
+ <DocPageLayout title={title} description={description}>
{sections.map(section => {
const override = sectionOverrides?.[section.title];
return (
@@ -86,6 +75,6 @@ export function ReferenceDocView({
</XDSSection>
);
})}
- </XDSVStack>
+ </DocPageLayout>
);
}