Skip to content

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

TypeScript

add component-specific variant theming

Cindy Zhang7310c86c5bf8
diff --git a/.claude/commands/create-component.md b/.claude/commands/create-component.md
index 26d2fbb503..a230be8b34 100644
--- a/.claude/commands/create-component.md
+++ b/.claude/commands/create-component.md
@@ -23,12 +23,12 @@ Use this structure based on Button.tsx:
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/{ComponentName}/README.md
- * - /packages/core/src/{ComponentName}/{ComponentName}.stories.tsx
+ * - /packages/core/src/{ComponentName}/{ComponentName}.test.tsx
* - /packages/core/src/{ComponentName}/index.ts
* - /apps/storybook/stories/{ComponentName}.stories.tsx
*/
-import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
+import { forwardRef, useContext, type HTMLAttributes, type ReactNode } from 'react';
import * as stylex from '@stylexjs/stylex';
import {
colorTokens,
@@ -37,6 +37,8 @@ import {
transitionTokens,
typographyTokens,
} from '../theme/tokens.stylex';
+import { ThemeContext } from '../theme/ThemeContext';
+import type { StyleXStyles } from '../theme/types';
// Define styles first
const styles = stylex.create({
@@ -59,6 +61,19 @@ const variants = stylex.create({
// Derive variant type from the variants object
export type {ComponentName}Variant = keyof typeof variants;
+// =============================================================================
+// Module Augmentation - Register variant type with ComponentStyles
+// =============================================================================
+// This allows themes to provide type-safe variant overrides for this component
+
+declare module '../theme/types' {
+ interface ComponentStyles {
+ {componentName}?: {
+ variants?: Partial<Record<{ComponentName}Variant, StyleXStyles>>;
+ };
+ }
+}
+
export interface {ComponentName}Props extends HTMLAttributes<HTMLElement> {
variant?: {ComponentName}Variant;
children: ReactNode;
@@ -66,10 +81,18 @@ export interface {ComponentName}Props extends HTMLAttributes<HTMLElement> {
export const {ComponentName} = forwardRef<HTMLElement, {ComponentName}Props>(
({ variant = 'default', children, ...props }, ref) => {
+ // Get theme context for component-level variant overrides (optional)
+ const themeContext = useContext(ThemeContext);
+ const themeVariantOverride = themeContext?.theme.components?.{componentName}?.variants?.[variant];
+
return (
<div
ref={ref}
- {...stylex.props(styles.base, variants[variant])}
+ {...stylex.props(
+ styles.base,
+ variants[variant],
+ themeVariantOverride
+ )}
{...props}
>
{children}
@@ -124,50 +147,13 @@ import { {ComponentName} } from '@xds/core/{ComponentName}';
| `index.ts` | Entry | Exports component and types |
| `{ComponentName}.tsx` | Core | Component implementation |
| `{ComponentName}.test.tsx` | Test | Unit tests |
-| `{ComponentName}.stories.tsx` | Docs | Storybook stories |
## Implementation Notes
- Variant type derived from `keyof typeof variants`
```
-### 4. {ComponentName}.stories.tsx
-
-```tsx
-/**
- * @file {ComponentName}.stories.tsx
- */
-
-import type { Meta, StoryObj } from '@storybook/react';
-import { {ComponentName} } from './{ComponentName}';
-
-const meta = {
- title: 'Components/{ComponentName}',
- component: {ComponentName},
- parameters: {
- layout: 'centered',
- },
- tags: ['autodocs'],
- argTypes: {
- variant: {
- control: 'select',
- options: ['default'], // Add variants here
- },
- },
-} satisfies Meta<typeof {ComponentName}>;
-
-export default meta;
-type Story = StoryObj<typeof meta>;
-
-export const Default: Story = {
- args: {
- children: '{ComponentName} content',
- variant: 'default',
- },
-};
-```
-
-### 5. Update /packages/core/src/index.ts
+### 4. Update /packages/core/src/index.ts
Add export for the new component:
@@ -180,6 +166,8 @@ export * from './{ComponentName}';
1. **Derive types from StyleX objects**: Use `keyof typeof variants` for variant types
2. **Use tokens**: Import from `../theme/tokens.stylex` - never use hardcoded values
3. **SYNC comments**: List all files that need updating when the component changes
+4. **Theme variant ingestion**: Use `ThemeContext` to apply theme-level variant overrides on top of defaults
+5. **Module augmentation**: Use `declare module` to register the component's variant type with `ComponentStyles` - this keeps theme types decoupled from component imports
## Token Reference
@@ -197,5 +185,5 @@ See `.context/explorations/component-reference.md` for the complete Button imple
## After Creation
1. Run `pnpm --filter @xds/core build` to verify the build
-2. Create stories in `/apps/storybook/stories/{ComponentName}.stories.tsx`
-3. Add tests in `{ComponentName}.test.tsx`
+2. Create stories in `/apps/storybook/stories/{ComponentName}.stories.tsx` (import from `@xds/core/{ComponentName}`)
+3. Add tests in `/packages/core/src/{ComponentName}/{ComponentName}.test.tsx`
diff --git a/.context/proposals/xds-architecture.md b/.context/proposals/xds-architecture.md
index 1a74666b6a..0ef0d995b2 100644
--- a/.context/proposals/xds-architecture.md
+++ b/.context/proposals/xds-architecture.md
@@ -469,120 +469,120 @@ const button = createVariants({
## Theme Definition API
-### Light/Dark Mode Enforcement
+> **Implementation Status**: ✅ Implemented in `/packages/core/src/theme/`
-All color tokens are **required** to be `[light, dark]` pairs — TypeScript enforces this:
+### Actual Implementation
+
+XDS uses StyleX for theming, with pre-compiled theme objects:
```typescript
-type LightDarkPair = [light: string, dark: string];
+// /packages/core/src/theme/tokens.stylex.ts
+import * as stylex from '@stylexjs/stylex';
-// ❌ Type error: expected [string, string]
-primary: '#0066cc',
+// Define CSS variables with stylex.defineVars
+export const colorTokens = stylex.defineVars({
+ accent: 'light-dark(#0064E0, #2694FE)',
+ accentText: 'light-dark(#0064E0, #2694FE)',
+ surface: 'light-dark(#FFFFFF, #1C1C1C)',
+ textPrimary: 'light-dark(#171717, #FAFAFA)',
+ hoverOverlay: 'light-dark(#0000000C, #FFFFFF0C)',
+ pressedOverlay: 'light-dark(#00000019, #FFFFFF19)',
+ // ... more tokens
+});
-// ✅ Valid: both light and dark values
-primary: ['#0066cc', '#66b3ff'],
+export const spacingTokens = stylex.defineVars({
+ space0: '0px',
+ space1: '4px',
+ space2: '8px',
+ space3: '12px',
+ space4: '16px',
+ // ...
+});
```
-### The "on*" Pattern
-
-Every background color has a corresponding foreground color for accessible contrast:
+### Theme Creation
-```
-primary → onPrimary (text color when on primary background)
-surface → onSurface (general text color)
-danger → onDanger (text on danger background)
-```
-
-### createTheme Function
+Themes override token values using `stylex.createTheme`:
```typescript
-import { createTheme } from '@xds/core';
-
-export const myTheme = createTheme({
- tokens: {
- color: {
- // Surfaces — [light, dark]
- background: ['#ffffff', '#121212'],
- onBackground: ['#1a1a1a', '#e0e0e0'],
- surface: ['#f5f5f5', '#1e1e1e'],
- onSurface: ['#1a1a1a', '#e0e0e0'],
-
- // Brand — [light, dark]
- primary: ['#0066cc', '#66b3ff'],
- onPrimary: ['#ffffff', '#000000'],
- secondary: ['#6b7280', '#9ca3af'],
- onSecondary: ['#ffffff', '#000000'],
-
- // Semantic — [light, dark]
- danger: ['#dc2626', '#f87171'],
- onDanger: ['#ffffff', '#000000'],
- success: ['#16a34a', '#4ade80'],
- onSuccess: ['#ffffff', '#000000'],
-
- // Borders
- border: ['#e5e7eb', '#374151'],
- borderFocus: ['#0066cc', '#66b3ff'],
- },
-
- spacing: {
- xs: '0.25rem',
- sm: '0.5rem',
- md: '1rem',
- lg: '1.5rem',
- xl: '2rem',
- },
+// /packages/core/src/theme/neutralTheme.stylex.ts
+import * as stylex from '@stylexjs/stylex';
+import { colorTokens } from './tokens.stylex';
+import type { Theme } from './types';
- radius: {
- sm: '0.25rem',
- md: '0.5rem',
- lg: '1rem',
- full: '9999px',
- },
+const colorTheme = stylex.createTheme(colorTokens, {
+ accent: 'light-dark(oklch(0.205 0 0), oklch(0.922 0 0))',
+ surface: 'light-dark(oklch(1 0 0), oklch(0.145 0 0))',
+ // ... override values
+});
- typography: {
- fontFamily: {
- sans: 'Inter, system-ui, sans-serif',
- mono: 'JetBrains Mono, monospace',
- },
- fontSize: {
- sm: '0.875rem',
- md: '1rem',
- lg: '1.125rem',
- }
- },
+// Component-specific variant overrides
+const buttonVariants = stylex.create({
+ primary: {
+ color: 'light-dark(white, oklch(0.145 0 0))',
+ },
+ secondary: {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: colorTokens.divider,
},
});
-type MyTheme = typeof myTheme;
+export const neutralTheme: Theme = {
+ name: 'neutral',
+ colorTheme,
+ elevationTheme,
+ spacingTheme,
+ radiusTheme,
+ transitionTheme,
+ typographyTheme,
+ components: {
+ button: { variants: buttonVariants },
+ },
+};
```
-**Note**: Theme contains only tokens. Component variants are defined in component files.
+### Theme Type Structure
-### Generated CSS Output
+```typescript
+// /packages/core/src/theme/types.ts
+export interface ComponentStyles {
+ // Components register via module augmentation
+ // See Button.tsx for example
+}
-Themes generate CSS using the `light-dark()` function:
+export interface Theme {
+ name: string;
+ colorTheme: StyleXTheme;
+ elevationTheme: StyleXTheme;
+ spacingTheme?: StyleXTheme;
+ radiusTheme?: StyleXTheme;
+ transitionTheme?: StyleXTheme;
+ typographyTheme?: StyleXTheme;
+ components?: ComponentStyles; // Component-level variant overrides
+}
+```
-```css
-:root {
- color-scheme: light dark;
+### Light/Dark Mode
- /* Colors with automatic light/dark support */
- --xds-color-primary: light-dark(#0066cc, #66b3ff);
- --xds-color-on-primary: light-dark(#ffffff, #000000);
- --xds-color-background: light-dark(#ffffff, #121212);
- --xds-color-on-background: light-dark(#1a1a1a, #e0e0e0);
+All color values use CSS `light-dark()` function for automatic mode switching:
- /* Spacing (no light/dark needed) */
- --xds-spacing-sm: 0.5rem;
- --xds-spacing-md: 1rem;
-}
+```css
+/* Generated CSS */
+--xds-color-accent: light-dark(#0064E0, #2694FE);
+--xds-color-surface: light-dark(#FFFFFF, #1C1C1C);
```
-Components reference these variables and automatically adapt to light/dark mode.
+The Theme provider sets `color-scheme` to control which value is used:
-### Manual Mode Override
+```tsx
+// Theme.tsx applies color-scheme based on mode prop
+<div style={{ colorScheme: mode === 'dark' ? 'dark' : mode === 'light' ? 'light' : 'light dark' }}>
+ {children}
+</div>
+```
-For apps that want manual light/dark toggle:
+### Manual Mode Override
```tsx
// Follow system preference (default)
@@ -595,44 +595,113 @@ For apps that want manual light/dark toggle:
<Theme theme={myTheme} mode="light">
```
-### Using the Theme
+---
+
+## Component Implementation
+
+> **Implementation Status**: ✅ Button implemented as reference component
+
+### Actual Button Implementation
+
+Components use StyleX with theme tokens and support theme-level variant overrides:
```typescript
-import { Theme } from '@xds/core';
-import { myTheme } from './theme';
+// /packages/core/src/Button/Button.tsx
+import * as stylex from '@stylexjs/stylex';
+import { colorTokens, spacingTokens, radiusTokens } from '../theme/tokens.stylex';
+import { ThemeContext } from '../theme/ThemeContext';
+import type { StyleXStyles } from '../theme/types';
+
+// Variant styles using tokens
+const variants = stylex.create({
+ primary: {
+ backgroundColor: colorTokens.accent,
+ color: 'white',
+ ':hover': {
+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,
+ },
+ ':active': {
+ backgroundImage: `linear-gradient(${colorTokens.pressedOverlay}, ${colorTokens.pressedOverlay})`,
+ },
+ ':focus-visible': {
+ outline: `2px solid ${colorTokens.focusOutline}`,
+ outlineOffset: '3px',
+ },
+ },
+ secondary: { /* ... */ },
+ ghost: { /* ... */ },
+ destructive: { /* ... */ },
+});
-function App() {
- return (
- <Theme theme={myTheme}>
- <Button variant="primary" size="md">
- Click me
- </Button>
- </Theme>
- );
+// Derive variant type from StyleX object
+export type ButtonVariant = keyof typeof variants;
+
+// Module augmentation - register with theme types
+declare module '../theme/types' {
+ interface ComponentStyles {
+ button?: {
+ variants?: Partial<Record<ButtonVariant, StyleXStyles>>;
+ };
+ }
}
+
+// Component consumes theme variant overrides
+export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
+ ({ variant = 'primary', children, ...props }, ref) => {
+ const themeContext = useContext(ThemeContext);
+ const themeVariantOverride = themeContext?.theme.components?.button?.variants?.[variant];
+
+ return (
+ <button
+ ref={ref}
+ {...stylex.props(
+ styles.base,
+ variants[variant],
+ themeVariantOverride // Theme override applied on top
+ )}
+ {...props}
+ >
+ {children}
+ </button>
+ );
+ }
+);
```
-### Theme Composition
+### Key Patterns
-Themes can extend other themes:
+| Pattern | Purpose |
+|---------|---------|
+| `keyof typeof variants` | Derive variant type from StyleX object |
+| `backgroundImage` for overlays | Layer hover/active colors on top of background |
+| Module augmentation | Register component variants with theme types without circular imports |
+| `ThemeContext` consumption | Apply theme-level variant overrides |
-```typescript
-import { baseTheme } from '@xds/themes/base';
+### Overlay Hover/Active States
-const myTheme = createTheme({
- extends: baseTheme,
+StyleX doesn't support combined pseudo-selectors like `:hover::after`. Use `backgroundImage` instead:
- // Override specific tokens
- tokens: {
- color: {
- primary: ['#custom-brand', '#custom-brand-dark'],
- secondary: ['#custom-secondary', '#custom-secondary-dark'],
- }
- },
-});
+```typescript
+':hover': {
+ // backgroundImage layers on TOP of backgroundColor
+ backgroundImage: `linear-gradient(${colorTokens.hoverOverlay}, ${colorTokens.hoverOverlay})`,
+},
```
-To add new button variants, swizzle the Button component instead of modifying the theme.
+---
+
+## Token Categories
+
+> **Implementation Status**: ✅ Implemented in `/packages/core/src/theme/tokens.stylex.ts`
+
+| Category | Purpose | Examples |
+|----------|---------|----------|
+| `colorTokens` | All colors (semantic, text, icon, status, dividers) | `accent`, `textPrimary`, `hoverOverlay`, `negative` |
+| `spacingTokens` | Consistent spacing scale | `space1` (4px), `space2` (8px), `space4` (16px) |
+| `radiusTokens` | Border radius for different contexts | `rounded`, `container`, `element`, `content` |
+| `elevationTokens` | Box shadows | `base`, `thumb`, `dialog`, `hover`, `menu` |
+| `transitionTokens` | Animation durations | `fast` (0.15s), `normal` (0.2s) |
+| `typographyTokens` | Font families | `fontFamilyBody`, `fontFamilyCode`, `fontFamilyHeading` |
---
@@ -1004,15 +1073,21 @@ Components have their own types based on their variant definitions — no cross-
## Open Questions
-### Resolved
+### Resolved (with actual implementation)
+
+1. ~~**Light/dark mode support?**~~ → **Resolved**: CSS `light-dark()` function. Theme provider sets `color-scheme` property. Mode prop (`system`/`light`/`dark`) controls behavior.
+
+2. ~~**Component themes in theme vs component file?**~~ → **Resolved**: Hybrid approach - component variants defined in component files, themes can provide variant overrides via `components.button.variants`.
-1. ~~**Light/dark mode support?**~~ → **Resolved**: Color tokens are always `[light, dark]` pairs. CSS uses `light-dark()` function. TypeScript enforces pairs.
+3. ~~**Prop naming (intent vs variant)?**~~ → **Resolved**: Use `variant` — more corpus representation for AI.
-2. ~~**Swizzle layer ergonomics?**~~ → **Resolved**: Swizzle with Tailwind Variants as default format. StyleX available for advanced users.
+4. ~~**Type inference from StyleX objects?**~~ → **Resolved**: `keyof typeof variants` derives variant type from StyleX object. Types stay in sync automatically.
-3. ~~**Component themes in theme vs component file?**~~ → **Resolved**: Token-only themes. Component variants are defined in component files, customized via swizzle.
+5. ~~**Theme-to-component type coupling?**~~ → **Resolved**: Module augmentation - each component declares its own entry in `ComponentStyles` interface, avoiding circular imports.
-4. ~~**Prop naming (intent vs variant)?**~~ → **Resolved**: Use `variant` — more corpus representation for AI.
+6. ~~**Default theme?**~~ → **Resolved**: XDS ships `defaultTheme` and `neutralTheme`. Themes are required to wrap components.
+
+7. ~~**Compile-time vs runtime themes?**~~ → **Resolved**: Compile-time via StyleX. Themes are pre-compiled `stylex.createTheme()` objects.
### Unresolved Design Decisions
@@ -1020,42 +1095,33 @@ Components have their own types based on their variant definitions — no cross-
- `button.slots.icon.hover` or just `button.slots.icon`?
- Risk of over-specification vs. flexibility
-2. **Should themes be runtime or compile-time?**
- - Compile-time: Better performance, type safety
- - Runtime: Dynamic theming, user preferences
- - Hybrid: Base at compile-time, overrides at runtime?
-
-3. **How to handle responsive tokens?**
+2. **How to handle responsive tokens?**
- `spacing: { md: { default: '1rem', '@md': '1.5rem' } }`
- Or separate responsive layer?
-4. **Theme validation/linting?**
+3. **Theme validation/linting?**
- Warn if theme is missing required tokens?
- Provide a `validateTheme()` function?
-5. **Default theme?**
- - Should XDS ship a default theme?
- - Or require users to always define one?
+### Swizzle Layer (Not Yet Implemented)
-### Swizzle Layer
+4. **Swizzle CLI?**
+ - `npx xds swizzle Button` to eject component?
+ - Currently, component variant overrides are theme-based, not file-based
-6. **Swizzle sync command?**
+5. **Swizzle sync command?**
- `npx xds sync Button` to see upstream changes?
- How do we help users stay up-to-date?
-7. **Component versioning in swizzled files?**
- - Should swizzled files track which XDS version they came from?
- - Warnings when upstream has breaking changes?
-
-### `@xds/variants` Implementation
+### Future Considerations
-8. **Type inference complexity?**
- - How do we infer variant props from nested StyleX objects?
- - Tailwind Variants handles this well — can we match it?
-
-9. **Responsive variants?**
+6. **Responsive variants?**
- Should responsive breakpoints be part of variant API?
- - Or handled via Tailwind/StyleX media queries?
+ - Or handled via StyleX media queries?
+
+7. **Tailwind preset?**
+ - XDS tokens available as Tailwind utilities for hybrid projects
+ - Not yet implemented
---
@@ -1134,31 +1200,48 @@ This provides tw-classed ergonomics without exposed CSS classes.
---
-## Proposed Implementation Phases
+## Implementation Phases
+
+### Phase 1: Core Infrastructure ✅ Complete
-### Phase 1: Core Infrastructure
-- `@xds/variants` wrapper around StyleX — tw-classed-like ergonomics with compile-time enforcement
-- `createTheme()` function with TypeScript inference
-- `Theme` context
-- Basic token system (colors, spacing, typography)
-- 3-5 pilot components (Button, Input, Text, Box, Stack)
+**Token System**
+- `stylex.defineVars` for tokens (colors, spacing, typography, radius, transitions, elevation)
+- `light-dark()` CSS function for automatic light/dark mode switching
+- Token categories: color, spacing, radius, transition, typography, elevation
+
+**Theme System**
+- `ThemeContext` for providing theme to component tree
+- `Theme` provider component with mode prop ('light' | 'dark' | 'system')
+- `stylex.createTheme` for theme-level token overrides
+- Component-level variant overrides via `theme.components.{component}.variants`
+- Module augmentation pattern for type-safe component styles (avoids circular imports)
+
+**Pilot Components**
+- Button with variants (primary, secondary, ghost, destructive)
+- Loading state with spinner animation
+- Press effect (scale 98%)
+- Theme variant consumption pattern
+
+**Infrastructure**
+- Storybook integration with theme switching
+- Vitest with StyleX babel plugin for testing
+- Component template (`/create-component` slash command)
### Phase 2: Component Library
-- Full component set with variant/size/part slots
-- Swizzle CLI
-- Storybook integration
+- Additional components (Input, Text, Box, Stack, Card, etc.)
+- Slot-level styling (icon, label, prefix, suffix)
+- Full variant/size matrix across components
### Phase 3: Ecosystem
-- Tailwind preset
-- CSS variable export
-- Lint rules for arbitrary value prevention
- Theme gallery / community themes
+- Documentation site
+- Migration guides from other design systems
### Phase 4: Advanced Features
-- Runtime theme switching
-- Responsive tokens
+- Swizzle CLI for component customization
- Animation tokens
- Multi-theme composition
+- Responsive tokens
---
diff --git a/internal/test-utils/src/setup.ts b/internal/test-utils/src/setup.ts
index 2ef02eadd7..8cd1ce8297 100644
--- a/internal/test-utils/src/setup.ts
+++ b/internal/test-utils/src/setup.ts
@@ -7,4 +7,5 @@
* SYNC: When modified, update this header and /internal/test-utils/src/README.md
*/
+/// <reference types="@testing-library/jest-dom" />
import '@testing-library/jest-dom/vitest';
diff --git a/package.json b/package.json
index 67e08a020e..2d1ed18f96 100644
--- a/package.json
+++ b/package.json
@@ -20,12 +20,14 @@
"devDependencies": {
"@changesets/cli": "^2.27.0",
"@playwright/test": "^1.48.0",
+ "@testing-library/user-event": "^14.5.0",
"@types/node": "^22.0.0",
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
"@vitest/coverage-v8": "^2.1.0",
"eslint": "^9.15.0",
+ "jsdom": "^27.4.0",
"prettier": "^3.4.0",
"react": "^18.3.0",
"react-dom": "^18.3.0",
diff --git a/packages/core/src/Button/Button.stories.tsx b/packages/core/src/Button/Button.stories.tsx
deleted file mode 100644
index f9d0efa3f0..0000000000
--- a/packages/core/src/Button/Button.stories.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * @file Button.stories.tsx
- * @input Uses @storybook/react, Button component
- * @output Storybook stories for Button variants and states
- * @position Documentation; visual testing and component showcase in Storybook
- *
- * SYNC: When modified, update this header and /packages/core/src/Button/README.md
- */
-
-import type { Meta, StoryObj } from '@storybook/react';
-import { Button } from './Button';
-
-const meta = {
- title: 'Components/Button',
- component: Button,
- parameters: {
- layout: 'centered',
- },
- tags: ['autodocs'],
- argTypes: {
- variant: {
- control: 'select',
- options: ['primary', 'secondary', 'ghost', 'destructive'],
- },
- loading: {
- control: 'boolean',
- },
- disabled: {
- control: 'boolean',
- },
- },
-} satisfies Meta<typeof Button>;
-
-export default meta;
-type Story = StoryObj<typeof meta>;
-
-export const Primary: Story = {
- args: {
- children: 'Primary Button',
- variant: 'primary',
- },
-};
-
-export const Secondary: Story = {
- args: {
- children: 'Secondary Button',
- variant: 'secondary',
- },
-};
-
-export const Ghost: Story = {
- args: {
- children: 'Ghost Button',
- variant: 'ghost',
- },
-};
-
-export const Destructive: Story = {
- args: {
- children: 'Delete',
- variant: 'destructive',
- },
-};
-
-export const Loading: Story = {
- args: {
- children: 'Saving...',
- loading: true,
- },
-};
-
-export const Disabled: Story = {
- args: {
- children: 'Disabled Button',
- disabled: true,
- },
-};
diff --git a/packages/core/src/Button/Button.test.tsx b/packages/core/src/Button/Button.test.tsx
index 989fdce5da..5d03975ba1 100644
--- a/packages/core/src/Button/Button.test.tsx
+++ b/packages/core/src/Button/Button.test.tsx
@@ -4,7 +4,7 @@
* @output Unit tests for Button component behavior
* @position Testing; validates Button.tsx implementation
*
- * SYNC: When modified, update this header and /packages/core/src/Button/README.md
+ * SYNC: When Button.tsx changes, update tests to match new behavior
*/
import { describe, it, expect, vi } from 'vitest';
@@ -18,22 +18,27 @@ describe('Button', () => {
expect(screen.getByRole('button', { name: 'Click me' })).toBeInTheDocument();
});
- it('applies variant data attribute', () => {
- render(<Button variant="secondary">Test</Button>);
- expect(screen.getByRole('button')).toHaveAttribute('data-variant', 'secondary');
- });
+ it('renders with different variants', () => {
+ const { rerender } = render(<Button variant="primary">Primary</Button>);
+ expect(screen.getByRole('button')).toBeInTheDocument();
+
+ rerender(<Button variant="secondary">Secondary</Button>);
+ expect(screen.getByRole('button')).toBeInTheDocument();
+
+ rerender(<Button variant="ghost">Ghost</Button>);
+ expect(screen.getByRole('button')).toBeInTheDocument();
- it('applies size data attribute', () => {
- render(<Button size="lg">Test</Button>);
- expect(screen.getByRole('button')).toHaveAttribute('data-size', 'lg');
+ rerender(<Button variant="destructive">Destructive</Button>);
+ expect(screen.getByRole('button')).toBeInTheDocument();
});
- it('shows loading state', () => {
+ it('shows loading state with spinner', () => {
render(<Button loading>Submit</Button>);
const button = screen.getByRole('button');
- expect(button).toHaveTextContent('Loading...');
+ // Button should be disabled when loading
expect(button).toBeDisabled();
- expect(button).toHaveAttribute('data-loading');
+ // Children text should still be present (but visually hidden)
+ expect(button).toHaveTextContent('Submit');
});
it('handles click events', async () => {
diff --git a/packages/core/src/Button/Button.tsx b/packages/core/src/Button/Button.tsx
index 41332a600b..44066baf41 100644
--- a/packages/core/src/Button/Button.tsx
+++ b/packages/core/src/Button/Button.tsx
@@ -6,12 +6,12 @@
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/Button/README.md (props table, features, implementation notes)
- * - /packages/core/src/Button/Button.stories.tsx (argTypes, stories for new variants)
+ * - /packages/core/src/Button/Button.test.tsx (tests for new/changed behavior)
* - /packages/core/src/Button/index.ts (exports if types change)
- * - /apps/storybook/stories/Button.stories.tsx (storybook app stories)
+ * - /apps/storybook/stories/Button.stories.tsx (storybook stories)
*/
-import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react';
+import { forwardRef, useContext, type ButtonHTMLAttributes, type ReactNode } from 'react';
import * as stylex from '@stylexjs/stylex';
import {
colorTokens,
@@ -20,6 +20,8 @@ import {
transitionTokens,
typographyTokens,
} from '../theme/tokens.stylex';
+import { ThemeContext } from '../theme/ThemeContext';
+import type { StyleXStyles } from '../theme/types';
/**
* Base button styles
@@ -41,12 +43,18 @@ const styles = stylex.create({
lineHeight: 1.429,
fontWeight: 500,
cursor: 'pointer',
- transitionProperty: 'background-image',
+ transitionProperty: 'background-image, transform',
transitionDuration: transitionTokens.fast,
+ ':active': {
+ transform: 'scale(0.98)',
+ },
},
disabled: {
cursor: 'not-allowed',
opacity: 0.5,
+ ':active': {
+ transform: 'none',
+ },
},
});
@@ -119,6 +127,20 @@ const variants = stylex.create({
*/
export type ButtonVariant = keyof typeof variants;
+// =============================================================================
+// Module Augmentation - Register Button's variant type with ComponentStyles
+// =============================================================================
+// This allows themes to provide type-safe variant overrides for Button
+// without requiring theme/types.ts to import from Button (avoiding circular deps)
+
+declare module '../theme/types' {
+ interface ComponentStyles {
+ button?: {
+ variants?: Partial<Record<ButtonVariant, StyleXStyles>>;
+ };
+ }
+}
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/**
* The visual style variant of the button.
@@ -179,6 +201,7 @@ const loadingStyles = stylex.create({
*
* Styles use XDS theme tokens via StyleX.
* Wrap your app in <Theme> to apply a theme.
+ * Themes can provide component-level variant overrides via theme.components.button.variants
*
* @example
* ```tsx
@@ -192,6 +215,10 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
const isDisabled = disabled || loading;
const useLightSpinner = variant === 'primary' || variant === 'destructive';
+ // Get theme context for component-level overrides (optional)
+ const themeContext = useContext(ThemeContext);
+ const themeVariantOverride = themeContext?.theme.components?.button?.variants?.[variant];
+
return (
<button
ref={ref}
@@ -199,6 +226,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
{...stylex.props(
styles.base,
variants[variant],
+ themeVariantOverride,
isDisabled && styles.disabled,
loading && loadingStyles.loading
)}
diff --git a/packages/core/src/Button/README.md b/packages/core/src/Button/README.md
index 00eea7aab8..3345ff678e 100644
--- a/packages/core/src/Button/README.md
+++ b/packages/core/src/Button/README.md
@@ -42,7 +42,6 @@ import { Button } from '@xds/core/Button';
| `index.ts` | Entry | Exports Button component and types |
| `Button.tsx` | Core | Button component implementation |
| `Button.test.tsx` | Test | Unit tests for Button component |
-| `Button.stories.tsx` | Docs | Storybook stories for visual documentation |
## Implementation Notes
diff --git a/packages/core/src/theme/Theme.tsx b/packages/core/src/theme/Theme.tsx
index a0fb79e316..d97fde0945 100644
--- a/packages/core/src/theme/Theme.tsx
+++ b/packages/core/src/theme/Theme.tsx
@@ -16,20 +16,14 @@
* ```
*/
-import React, { createContext, useContext, useMemo } from 'react';
+import React, { useContext, useMemo } from 'react';
import * as stylex from '@stylexjs/stylex';
import type { Theme as ThemeType, ThemeMode } from './types';
import { publicVariables } from './publicVariables.stylex';
+import { ThemeContext, type ThemeContextValue } from './ThemeContext';
-/**
- * Theme context value
- */
-interface ThemeContextValue {
- theme: ThemeType;
- mode: ThemeMode;
-}
-
-const ThemeContext = createContext<ThemeContextValue | null>(null);
+// Re-export for backwards compatibility
+export { ThemeContext } from './ThemeContext';
/**
* Hook to access current theme
diff --git a/packages/core/src/theme/ThemeContext.ts b/packages/core/src/theme/ThemeContext.ts
new file mode 100644
index 0000000000..2027e250df
--- /dev/null
+++ b/packages/core/src/theme/ThemeContext.ts
@@ -0,0 +1,23 @@
+/**
+ * Theme Context
+ *
+ * Separated from Theme.tsx to allow components to consume theme
+ * without pulling in the full theme provider implementation.
+ */
+
+import { createContext } from 'react';
+import type { Theme, ThemeMode } from './types';
+
+/**
+ * Theme context value
+ */
+export interface ThemeContextValue {
+ theme: Theme;
+ mode: ThemeMode;
+}
+
+/**
+ * Theme context - provides theme to components
+ * Components use this to access theme-level variant overrides
+ */
+export const ThemeContext = createContext<ThemeContextValue | null>(null);
diff --git a/packages/core/src/theme/index.ts b/packages/core/src/theme/index.ts
index 32e0ad77d3..85321503a3 100644
--- a/packages/core/src/theme/index.ts
+++ b/packages/core/src/theme/index.ts
@@ -23,4 +23,4 @@ export {
typographyTokens,
} from './tokens.stylex';
-export type { Theme as ThemeType, ThemeMode } from './types';
+export type { Theme as ThemeType, ThemeMode, ComponentStyles } from './types';
diff --git a/packages/core/src/theme/neutralTheme.stylex.ts b/packages/core/src/theme/neutralTheme.stylex.ts
index 0c9773423c..0ba7f76b23 100644
--- a/packages/core/src/theme/neutralTheme.stylex.ts
+++ b/packages/core/src/theme/neutralTheme.stylex.ts
@@ -222,6 +222,26 @@ const typographyTheme = stylex.createTheme(typographyTokens, {
fontFamilyHeading: 'Geist, "Geist Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
});
+// =============================================================================
+// Component Style Overrides
+// =============================================================================
+// Theme-specific component customizations using stylex.create()
+// These styles are applied on top of default component variants
+
+const buttonVariants = stylex.create({
+ // Primary button text needs to contrast with accent color
+ // In dark mode, accent is light so text should be dark
+ primary: {
+ color: 'light-dark(white, oklch(0.145 0 0))',
+ },
+ // Add border to secondary button for shadcn-style appearance
+ secondary: {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: colorTokens.divider,
+ },
+});
+
// =============================================================================
// Theme Export
// =============================================================================
@@ -234,4 +254,9 @@ export const neutralTheme: Theme = {
radiusTheme,
transitionTheme,
typographyTheme,
+ components: {
+ button: {
+ variants: buttonVariants,
+ },
+ },
};
diff --git a/packages/core/src/theme/types.ts b/packages/core/src/theme/types.ts
index 8baeb5df58..8a5bf2c722 100644
--- a/packages/core/src/theme/types.ts
+++ b/packages/core/src/theme/types.ts
@@ -5,11 +5,30 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type StyleXTheme = any;
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export type StyleXStyles = any;
+
/**
* Theme mode - system follows OS preference
*/
export type ThemeMode = 'system' | 'light' | 'dark';
+/**
+ * Component-specific style overrides
+ * Each component augments this interface to add its own entry
+ * See Button.tsx for an example of module augmentation
+ */
+// eslint-disable-next-line @typescript-eslint/no-empty-object-type
+export interface ComponentStyles {
+ // Components add their entries via module augmentation
+ // Example in Button.tsx:
+ // declare module '../theme/types' {
+ // interface ComponentStyles {
+ // button?: { variants?: Partial<Record<ButtonVariant, StyleXStyles>> };
+ // }
+ // }
+}
+
/**
* Theme object - pre-compiled StyleX theme
*/
@@ -28,4 +47,6 @@ export interface Theme {
transitionTheme?: StyleXTheme;
/** Typography theme StyleX styles (optional) */
typographyTheme?: StyleXTheme;
+ /** Component-specific style overrides (optional) */
+ components?: ComponentStyles;
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c9912c2272..e5240235d0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -14,6 +14,9 @@ importers:
'@playwright/test':
specifier: ^1.48.0
version: 1.57.0
+ '@testing-library/user-event':
+ specifier: ^14.5.0
+ version: 14.6.1(@testing-library/[email protected])
'@types/node':
specifier: ^22.0.0
version: 22.19.3
@@ -28,10 +31,13 @@ importers:
version: 4.7.0([email protected](@types/[email protected]))
'@vitest/coverage-v8':
specifier: ^2.1.0
- version: 2.1.9([email protected](@types/[email protected]))
eslint:
specifier: ^9.15.0
version: 9.39.2
+ jsdom:
+ specifier: ^27.4.0
+ version: 27.4.0
prettier:
specifier: ^3.4.0
version: 3.7.4
@@ -52,7 +58,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^2.1.0
- version: 2.1.9(@types/[email protected])
+ version: 2.1.9(@types/[email protected])([email protected])
apps/docs: {}
@@ -164,6 +170,9 @@ importers:
packages:
+ '@acemir/[email protected]':
+ resolution: {integrity: sha512-ZnR3GSaH+/vJ0YlHau21FjfLYjMpYVIzTD8M8vIEQvIGxeOXyXdzCI140rrCY862p/C/BbzWsjc1dgnM9mkoTA==}
+
resolution: {integrity: sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==}
@@ -171,6 +180,15 @@ packages:
resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}
engines: {node: '>=6.0.0'}
+ '@asamuzakjp/[email protected]':
+ resolution: {integrity: sha512-B0Hv6G3gWGMn0xKJ0txEi/jM5iFpT3MfDxmhZFb4W047GvytCf1DHQ1D69W3zHI4yWe2aTZAA0JnbMZ7Xc8DuQ==}
+
+ '@asamuzakjp/[email protected]':
+ resolution: {integrity: sha512-hBaJER6A9MpdG3WgdlOolHmbOYvSk46y7IQN/1+iqiCuUu6iWdQrs9DGKF8ocqsEqWujWf/V7b7vaDgiUmIvUg==}
+
+ '@asamuzakjp/[email protected]':
+ resolution: {integrity: sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==}
+
resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==}
engines: {node: '>=6.9.0'}
@@ -410,6 +428,38 @@ packages:
'@changesets/[email protected]':
resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==}
+ '@csstools/[email protected]':
+ resolution: {integrity: sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==}
+ engines: {node: '>=18'}
+
+ '@csstools/[email protected]':
+ resolution: {integrity: sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ '@csstools/css-parser-algorithms': ^3.0.5
+ '@csstools/css-tokenizer': ^3.0.4
+
+ '@csstools/[email protected]':
+ resolution: {integrity: sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ '@csstools/css-parser-algorithms': ^3.0.5
+ '@csstools/css-tokenizer': ^3.0.4
+
+ '@csstools/[email protected]':
+ resolution: {integrity: sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ '@csstools/css-tokenizer': ^3.0.4
+
+ '@csstools/[email protected]':
+ resolution: {integrity: sha512-g0Kw9W3vjx5BEBAF8c5Fm2NcB/Fs8jJXh85aXqwEXiL+tqtOut07TWgyaGzAAfTM+gKckrrncyeGEZPcaRgm2Q==}
+ engines: {node: '>=18'}
+
+ '@csstools/[email protected]':
+ resolution: {integrity: sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==}
+ engines: {node: '>=18'}
+
'@dual-bundle/[email protected]':
resolution: {integrity: sha512-id+7YRUgoUX6CgV0DtuhirQWodeeA7Lf4i2x71JS/vtA5pRb/hIGWlw+G6MeXvsM+MXrz0VAydTGElX1rAfgPg==}
@@ -1051,6 +1101,15 @@ packages:
resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@exodus/[email protected]':
+ resolution: {integrity: sha512-8JPn18Bcp8Uo1T82gR8lh2guEOa5KKU/IEKvvdp0sgmi7coPBWf1Doi1EXsGZb2ehc8ym/StJCjffYV+ne7sXQ==}
+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
+ peerDependencies:
+ '@exodus/crypto': ^1.0.0-rc.4
+ peerDependenciesMeta:
+ '@exodus/crypto':
+ optional: true
+
'@humanfs/[email protected]':
resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==}
engines: {node: '>=18.18.0'}
@@ -1649,6 +1708,10 @@ packages:
engines: {node: '>=0.4.0'}
hasBin: true
+ resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
+ engines: {node: '>= 14'}
+
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
@@ -1726,6 +1789,9 @@ packages:
resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==}
engines: {node: '>=4'}
+ resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}
+
resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==}
@@ -1831,12 +1897,24 @@ packages:
resolution: {integrity: sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q==}
+ resolution: {integrity: sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==}
+ engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}
+
resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==}
+ resolution: {integrity: sha512-7D2EPVltRrsTkhpQmksIu+LxeWAIEk6wRDMJ1qljlv+CKHJM+cJLlfhWIzNA44eAsHXSNe3+vO6DW1yCYx8SuQ==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
+ resolution: {integrity: sha512-BnBS08aLUM+DKamupXs3w2tJJoqU+AkaE/+6vQxi/G/DPmIZFJJp9Dkb1kM03AZx8ADehDUZgsNxju3mPXZYIA==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
engines: {node: '>=6.0'}
@@ -1846,6 +1924,9 @@ packages:
supports-color:
optional: true
+ resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}
+
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
engines: {node: '>=6'}
@@ -1903,6 +1984,10 @@ packages:
resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==}
engines: {node: '>=8.6'}
+ resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==}
+ engines: {node: '>=0.12'}
+
resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
engines: {node: '>= 0.4'}
@@ -2164,9 +2249,21 @@ packages:
resolution: {integrity: sha512-fWT40jJ/BtlzuyiiQS7lzNIlB5h6flVZoN8Jn8v5l987HL5dK9s+/4+py0FaBmeIEROC2zxt5qMLwXFTPLQ7BA==}
+ resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==}
+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
+
resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==}
+ resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==}
+ engines: {node: '>= 14'}
+
+ resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==}
+ engines: {node: '>= 14'}
+
resolution: {integrity: sha512-tsYlhAYpjCKa//8rXZ9DqKEawhPoSytweBC2eNvcaDK+57RZLHGqNs3PZTQO6yekLFSuvA6AlnAfrw1uBvtb+Q==}
hasBin: true
@@ -2234,6 +2331,9 @@ packages:
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'}
+ resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}
+
resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==}
engines: {node: '>= 0.4'}
@@ -2295,6 +2395,15 @@ packages:
resolution: {integrity: sha512-iZ8Bdb84lWRuGHamRXFyML07r21pcwBrLkHEuHgEY5UbCouBwv7ECknDRKzsQIXMiqpPymqtIf8TC/shYKB5rw==}
engines: {node: '>=12.0.0'}
+ resolution: {integrity: sha512-mjzqwWRD9Y1J1KUi7W97Gja1bwOOM5Ug0EZ6UDK3xS7j7mndrkwozHtSblfomlzyB4NepioNt+B2sOSzczVgtQ==}
+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
+ peerDependencies:
+ canvas: ^3.0.0
+ peerDependenciesMeta:
+ canvas:
+ optional: true
+
resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}
engines: {node: '>=6'}
@@ -2362,6 +2471,10 @@ packages:
resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}
+ resolution: {integrity: sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg==}
+ engines: {node: 20 || >=22}
+
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
@@ -2390,6 +2503,9 @@ packages:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==}
+
resolution: {integrity: sha512-/EuHYwAPdLtXwAwSZkh/Gutery6pD2KYd44oQLhAvQp/50mpyduZh8Q7PYHXTCJ+wuXxt7oij2LXyIJOOYFPog==}
@@ -2496,6 +2612,9 @@ packages:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-9m4m5GSgXjL4AjumKzq1Fgfp3Z8rsvjRNbnkVwfu2ImRqE5D0LnY2QfDen18FSY9C573YU5XxSapdHZTZ2WolA==}
+
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'}
@@ -2663,6 +2782,10 @@ packages:
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'}
@@ -2695,6 +2818,10 @@ packages:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
+ resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}
+ engines: {node: '>=v12.22.7'}
+
resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==}
@@ -2811,6 +2938,9 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
+
resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==}
engines: {node: '>=8'}
@@ -2851,10 +2981,25 @@ packages:
resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==}
engines: {node: '>=14.0.0'}
+ resolution: {integrity: sha512-lJX2dEWx0SGH4O6p+7FPwYmJ/bu1JbcGJ8RLaG9b7liIgZ85itUVEPbMtWRVrde/0fnDPEPHW10ZsKW3kVsE9A==}
+
+ resolution: {integrity: sha512-8PWx8tvC4jDB39BQw1m4x8y5MH1BcQ5xHeL2n7UVFulMPH/3Q0uiamahFJ3lXA0zO2SUyRXuVVbWSDmstlt9YA==}
+ hasBin: true
+
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
+ resolution: {integrity: sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==}
+ engines: {node: '>=16'}
+
+ resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
hasBin: true
@@ -3026,9 +3171,25 @@ packages:
jsdom:
optional: true
+ resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}
+ engines: {node: '>=18'}
+
+ resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==}
+ resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==}
+ engines: {node: '>=18'}
+
+ resolution: {integrity: sha512-2ytDk0kiEj/yu90JOAp44PVPUkO9+jVhyf+SybKlRHSDlvOOZhdPIrr7xTH64l4WixO2cP+wQIcgujkGBPPz6g==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==}
engines: {node: '>= 0.4'}
@@ -3067,6 +3228,13 @@ packages:
utf-8-validate:
optional: true
+ resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}
+ engines: {node: '>=18'}
+
+ resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
+
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
@@ -3076,6 +3244,8 @@ packages:
snapshots:
+ '@acemir/[email protected]': {}
+
'@adobe/[email protected]': {}
'@ampproject/[email protected]':
@@ -3083,6 +3253,24 @@ snapshots:
'@jridgewell/gen-mapping': 0.3.13
'@jridgewell/trace-mapping': 0.3.31
+ '@asamuzakjp/[email protected]':
+ dependencies:
+ '@csstools/css-calc': 2.1.4(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])
+ '@csstools/css-color-parser': 3.1.0(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])
+ '@csstools/css-parser-algorithms': 3.0.5(@csstools/[email protected])
+ '@csstools/css-tokenizer': 3.0.4
+ lru-cache: 11.2.4
+
+ '@asamuzakjp/[email protected]':
+ dependencies:
+ '@asamuzakjp/nwsapi': 2.3.9
+ bidi-js: 1.0.3
+ css-tree: 3.1.0
+ is-potential-custom-element-name: 1.0.1
+ lru-cache: 11.2.4
+
+ '@asamuzakjp/[email protected]': {}
+
dependencies:
'@babel/helper-validator-identifier': 7.28.5
@@ -3473,6 +3661,28 @@ snapshots:
human-id: 4.1.3
prettier: 2.8.8
+ '@csstools/[email protected]': {}
+
+ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':
+ dependencies:
+ '@csstools/css-parser-algorithms': 3.0.5(@csstools/[email protected])
+ '@csstools/css-tokenizer': 3.0.4
+
+ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':
+ dependencies:
+ '@csstools/color-helpers': 5.1.0
+ '@csstools/css-calc': 2.1.4(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])
+ '@csstools/css-parser-algorithms': 3.0.5(@csstools/[email protected])
+ '@csstools/css-tokenizer': 3.0.4
+
+ '@csstools/[email protected](@csstools/[email protected])':
+ dependencies:
+ '@csstools/css-tokenizer': 3.0.4
+
+ '@csstools/[email protected]': {}
+
+ '@csstools/[email protected]': {}
+
'@dual-bundle/[email protected]': {}
'@esbuild/[email protected]':
@@ -3821,6 +4031,8 @@ snapshots:
'@eslint/core': 0.17.0
levn: 0.4.1
+ '@exodus/[email protected]': {}
+
'@humanfs/[email protected]': {}
'@humanfs/[email protected]':
@@ -4421,7 +4633,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@ampproject/remapping': 2.3.0
'@bcoe/v8-coverage': 0.2.3
@@ -4435,7 +4647,7 @@ snapshots:
std-env: 3.10.0
test-exclude: 7.0.1
tinyrainbow: 1.2.0
- vitest: 2.1.9(@types/[email protected])
+ vitest: 2.1.9(@types/[email protected])([email protected])
transitivePeerDependencies:
- supports-color
@@ -4507,6 +4719,8 @@ snapshots:
+
dependencies:
fast-deep-equal: 3.1.3
@@ -4570,6 +4784,10 @@ snapshots:
dependencies:
is-windows: 1.0.2
+ dependencies:
+ require-from-string: 2.0.2
+
dependencies:
balanced-match: 1.0.2
@@ -4673,14 +4891,33 @@ snapshots:
+ dependencies:
+ mdn-data: 2.12.2
+ source-map-js: 1.2.1
+
+ dependencies:
+ '@asamuzakjp/css-color': 4.1.1
+ '@csstools/css-syntax-patches-for-csstree': 1.0.25
+ css-tree: 3.1.0
+ lru-cache: 11.2.4
+
+ dependencies:
+ whatwg-mimetype: 4.0.0
+ whatwg-url: 15.1.0
+
dependencies:
ms: 2.1.3
+
@@ -4728,6 +4965,8 @@ snapshots:
ansi-colors: 4.1.3
strip-ansi: 6.0.1
+
@@ -5101,8 +5340,28 @@ snapshots:
dependencies:
hermes-estree: 0.26.0
+ dependencies:
+ '@exodus/bytes': 1.8.0
+ transitivePeerDependencies:
+ - '@exodus/crypto'
+
+ dependencies:
+ agent-base: 7.1.4
+ debug: 4.4.3
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ agent-base: 7.1.4
+ debug: 4.4.3
+ transitivePeerDependencies:
+ - supports-color
+
@@ -5157,6 +5416,8 @@ snapshots:
+
dependencies:
call-bound: 1.0.4
@@ -5222,6 +5483,34 @@ snapshots:
+ dependencies:
+ '@acemir/cssom': 0.9.31
+ '@asamuzakjp/dom-selector': 6.7.6
+ '@exodus/bytes': 1.8.0
+ cssstyle: 5.3.7
+ data-urls: 6.0.0
+ decimal.js: 10.6.0
+ html-encoding-sniffer: 6.0.0
+ http-proxy-agent: 7.0.2
+ https-proxy-agent: 7.0.6
+ is-potential-custom-element-name: 1.0.1
+ parse5: 8.0.0
+ saxes: 6.0.0
+ symbol-tree: 3.2.4
+ tough-cookie: 6.0.0
+ w3c-xmlserializer: 5.0.0
+ webidl-conversions: 8.0.1
+ whatwg-mimetype: 4.0.0
+ whatwg-url: 15.1.0
+ ws: 8.19.0
+ xml-name-validator: 5.0.0
+ transitivePeerDependencies:
+ - '@exodus/crypto'
+ - bufferutil
+ - supports-color
+ - utf-8-validate
+
@@ -5273,6 +5562,8 @@ snapshots:
+
dependencies:
yallist: 3.1.1
@@ -5301,6 +5592,8 @@ snapshots:
+
dependencies:
map-or-similar: 1.5.0
@@ -5402,6 +5695,10 @@ snapshots:
dependencies:
callsites: 3.1.0
+ dependencies:
+ entities: 6.0.1
+
@@ -5540,6 +5837,8 @@ snapshots:
indent-string: 4.0.0
strip-indent: 3.0.0
+
@@ -5595,6 +5894,10 @@ snapshots:
+ dependencies:
+ xmlchars: 2.2.0
+
dependencies:
loose-envify: 1.4.0
@@ -5699,6 +6002,8 @@ snapshots:
+
@@ -5732,10 +6037,24 @@ snapshots:
+
+ dependencies:
+ tldts-core: 7.0.19
+
dependencies:
is-number: 7.0.0
+ dependencies:
+ tldts: 7.0.19
+
+ dependencies:
+ punycode: 2.3.1
+
@@ -5869,7 +6188,7 @@ snapshots:
'@types/node': 22.19.3
fsevents: 2.3.3
dependencies:
'@vitest/expect': 2.1.9
'@vitest/mocker': 2.1.9([email protected](@types/[email protected]))
@@ -5893,6 +6212,7 @@ snapshots:
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 22.19.3
+ jsdom: 27.4.0
transitivePeerDependencies:
- less
- lightningcss
@@ -5904,8 +6224,21 @@ snapshots:
- supports-color
- terser
+ dependencies:
+ xml-name-validator: 5.0.0
+
+
+
+ dependencies:
+ tr46: 6.0.0
+ webidl-conversions: 8.0.1
+
dependencies:
available-typed-arrays: 1.0.7
@@ -5941,6 +6274,10 @@ snapshots:
+
+
diff --git a/tsconfig.json b/tsconfig.json
index 2d64d55479..102807613f 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -15,7 +15,8 @@
"sourceMap": true,
"isolatedModules": true,
"noEmit": true,
- "resolveJsonModule": true
+ "resolveJsonModule": true,
+ "types": ["@testing-library/jest-dom"]
},
"exclude": ["node_modules", "dist"]
}
diff --git a/vitest.config.ts b/vitest.config.ts
index ae8435968d..2a0fc22437 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -11,7 +11,27 @@ import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
export default defineConfig({
- plugins: [react()],
+ plugins: [
+ react({
+ babel: {
+ plugins: [
+ [
+ '@stylexjs/babel-plugin',
+ {
+ dev: true,
+ runtimeInjection: true,
+ genConditionalClasses: true,
+ treeshakeCompensation: true,
+ unstable_moduleResolution: {
+ type: 'commonJS',
+ rootDir: '.',
+ },
+ },
+ ],
+ ],
+ },
+ }),
+ ],
test: {
globals: true,
environment: 'jsdom',