An open source design system that's fully customizable and agent ready
TypeScript
feat(docsite): stub Next.js docsite app for Vercel deployment (#1941)
Cindy Zhang35f5ca5c3c08
diff --git a/apps/docsite/.gitignore b/apps/docsite/.gitignorenew file mode 100644index 0000000000..9fb346fb7d--- /dev/null+++ b/apps/docsite/.gitignore@@ -0,0 +1,2 @@+.next+next-env.d.tsdiff --git a/apps/docsite/babel.config.js b/apps/docsite/babel.config.jsnew file mode 100644index 0000000000..8bd5d76ec2--- /dev/null+++ b/apps/docsite/babel.config.js@@ -0,0 +1,27 @@+/* global module, require, process, __dirname */+// eslint-disable-next-line @typescript-eslint/no-require-imports+const path = require('path');++const dev = process.env.NODE_ENV !== 'production';++module.exports = {+ presets: ['next/babel'],+ plugins: [+ [+ '@stylexjs/babel-plugin',+ {+ dev,+ runtimeInjection: false,+ enableInlinedConditionalMerge: true,+ treeshakeCompensation: true,+ aliases: {+ '@/*': [path.join(__dirname, '*')],+ },+ classNamePrefix: 'p',+ unstable_moduleResolution: {+ type: 'commonJS',+ },+ },+ ],+ ],+};diff --git a/apps/docsite/css.d.ts b/apps/docsite/css.d.tsnew file mode 100644index 0000000000..871e021524--- /dev/null+++ b/apps/docsite/css.d.ts@@ -0,0 +1,3 @@+// TypeScript 6 requires type declarations for CSS side-effect imports.+// This must be in a separate file from next-env.d.ts (which Next.js regenerates).+declare module '*.css';diff --git a/apps/docsite/next.config.mjs b/apps/docsite/next.config.mjsnew file mode 100644index 0000000000..4678774e6d--- /dev/null+++ b/apps/docsite/next.config.mjs@@ -0,0 +1,4 @@+/** @type {import('next').NextConfig} */+const nextConfig = {};++export default nextConfig;diff --git a/apps/docsite/package.json b/apps/docsite/package.jsonnew file mode 100644index 0000000000..2fd70c01e6--- /dev/null+++ b/apps/docsite/package.json@@ -0,0 +1,31 @@+{+ "name": "@xds/docsite",+ "version": "0.0.1",+ "private": true,+ "scripts": {+ "dev": "next dev",+ "build": "next build",+ "start": "next start"+ },+ "dependencies": {+ "@stylexjs/stylex": "^0.18.3",+ "@xds/core": "*",+ "@xds/theme-default": "*",+ "next": "^15.5.15",+ "react": "^19.2.5",+ "react-dom": "^19.2.5"+ },+ "devDependencies": {+ "@stylexjs/babel-plugin": "^0.18.3",+ "@stylexjs/postcss-plugin": "^0.18.3",+ "@babel/preset-react": "^7.25.0",+ "@babel/preset-typescript": "^7.25.0",+ "@types/react": "^19.2.14",+ "@types/react-dom": "^19.2.3",+ "typescript": "^6.0.3",+ "autoprefixer": "^10.4.0"+ },+ "browserslist": [+ "last 1 Chrome version"+ ]+}diff --git a/apps/docsite/postcss.config.js b/apps/docsite/postcss.config.jsnew file mode 100644index 0000000000..0da9b9486b--- /dev/null+++ b/apps/docsite/postcss.config.js@@ -0,0 +1,22 @@+/* global module, require */+// eslint-disable-next-line @typescript-eslint/no-require-imports+const babelConfig = require('./babel.config');++module.exports = {+ plugins: {+ '@stylexjs/postcss-plugin': {+ include: ['src/**/*.{js,jsx,ts,tsx}'],+ babelConfig: {+ babelrc: false,+ parserOpts: {+ plugins: ['typescript', 'jsx'],+ },+ plugins: babelConfig.plugins,+ },+ useCSSLayers: {+ before: ['reset', 'xds-base', 'xds-theme'],+ },+ },+ autoprefixer: {},+ },+};diff --git a/apps/docsite/src/app/globals.css b/apps/docsite/src/app/globals.cssnew file mode 100644index 0000000000..7880245bbf--- /dev/null+++ b/apps/docsite/src/app/globals.css@@ -0,0 +1,7 @@+@import "@xds/core/reset.css";+@import "@xds/core/xds.css";+@import "@xds/theme-default/theme.css";++/* StyleX app styles injected here. useCSSLayers.before declares+ reset, xds-base, xds-theme so product styles always win. */+@stylex;diff --git a/apps/docsite/src/app/layout.tsx b/apps/docsite/src/app/layout.tsxnew file mode 100644index 0000000000..d787ecc70c--- /dev/null+++ b/apps/docsite/src/app/layout.tsx@@ -0,0 +1,18 @@+import type {Metadata} from 'next';+import './globals.css';+import {Providers} from './providers';++export const metadata: Metadata = {+ title: 'XDS — Design System',+ description: 'Documentation for the XDS design system',+};++export default function RootLayout({children}: {children: React.ReactNode}) {+ return (+ <html lang="en">+ <body>+ <Providers>{children}</Providers>+ </body>+ </html>+ );+}diff --git a/apps/docsite/src/app/page.tsx b/apps/docsite/src/app/page.tsxnew file mode 100644index 0000000000..82343b302e--- /dev/null+++ b/apps/docsite/src/app/page.tsx@@ -0,0 +1,32 @@+'use client';++import * as stylex from '@stylexjs/stylex';+import {XDSVStack} from '@xds/core/Layout';+import {XDSText, XDSHeading} from '@xds/core/Text';+import {XDSButton} from '@xds/core/Button';++const styles = stylex.create({+ main: {+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ minHeight: '100vh',+ padding: '2rem',+ },+});++export default function Home() {+ return (+ <main {...stylex.props(styles.main)}>+ <XDSVStack gap={6} hAlign="center">+ <XDSVStack gap={2} hAlign="center">+ <XDSHeading level={1}>XDS</XDSHeading>+ <XDSText type="body" color="secondary">+ A design system for building internal tools and products.+ </XDSText>+ </XDSVStack>+ <XDSButton label="Get Started" variant="primary" />+ </XDSVStack>+ </main>+ );+}diff --git a/apps/docsite/src/app/providers.tsx b/apps/docsite/src/app/providers.tsxnew file mode 100644index 0000000000..2df97556c1--- /dev/null+++ b/apps/docsite/src/app/providers.tsx@@ -0,0 +1,14 @@+'use client';++import Link from 'next/link';+import {XDSTheme} from '@xds/core/theme';+import {XDSLinkProvider} from '@xds/core/Link';+import {defaultTheme} from '@xds/theme-default/built';++export function Providers({children}: {children: React.ReactNode}) {+ return (+ <XDSTheme theme={defaultTheme}>+ <XDSLinkProvider component={Link}>{children}</XDSLinkProvider>+ </XDSTheme>+ );+}diff --git a/apps/docsite/tsconfig.json b/apps/docsite/tsconfig.jsonnew file mode 100644index 0000000000..d2bba220e4--- /dev/null+++ b/apps/docsite/tsconfig.json@@ -0,0 +1,40 @@+{+ "compilerOptions": {+ "target": "ES2017",+ "lib": [+ "dom",+ "dom.iterable",+ "esnext"+ ],+ "allowJs": true,+ "skipLibCheck": true,+ "strict": true,+ "noEmit": true,+ "esModuleInterop": true,+ "module": "esnext",+ "moduleResolution": "bundler",+ "resolveJsonModule": true,+ "isolatedModules": true,+ "jsx": "preserve",+ "incremental": true,+ "plugins": [+ {+ "name": "next"+ }+ ],+ "paths": {+ "@/*": [+ "./src/*"+ ]+ }+ },+ "include": [+ "next-env.d.ts",+ "**/*.ts",+ "**/*.tsx",+ ".next/types/**/*.ts"+ ],+ "exclude": [+ "node_modules"+ ]+}diff --git a/apps/docsite/vercel.json b/apps/docsite/vercel.jsonnew file mode 100644index 0000000000..5b14cdee40--- /dev/null+++ b/apps/docsite/vercel.json@@ -0,0 +1,4 @@+{+ "installCommand": "cd ../.. && yarn install",+ "buildCommand": "cd ../.. && yarn build && yarn workspace @xds/docsite build"+}diff --git a/apps/example-nextjs-stylex/babel.config.js b/apps/example-nextjs-stylex/babel.config.jsindex c9c59376c9..d2070030b7 100644--- a/apps/example-nextjs-stylex/babel.config.js+++ b/apps/example-nextjs-stylex/babel.config.js@@ -19,6 +19,7 @@ module.exports = {aliases: {'@/*': [path.join(__dirname, '*')],},+ classNamePrefix: 'p',unstable_moduleResolution: {type: 'commonJS',},diff --git a/eslint.config.js b/eslint.config.jsindex b538dede96..869a178022 100644--- a/eslint.config.js+++ b/eslint.config.js@@ -35,6 +35,7 @@ export default tseslint.config("apps/example-nextjs/*.js","apps/example-nextjs/next-env.d.ts","apps/example-nextjs-source/*.js",+ "apps/docsite/*.js","apps/sandbox/*.js","packages/build/**",],