Repository navigation
feat(theme): separate themes into @xds/theme package - #141
Conversation
Move defaultTheme and neutralTheme from @xds/core into a new
@xds/theme package with subpath exports:
- import { defaultTheme } from '@xds/theme/default'
- import { neutralTheme } from '@xds/theme/neutral'
@xds/core retains theme infrastructure (tokens, ThemeContext,
XDSTheme provider, types). Components work without any theme
applied using base defineVars defaults.
Theme files import tokens via relative path to core source
for StyleX createTheme cross-package compatibility.
Updates all downstream consumers:
- Storybook preview + stories
- Sandbox app
- CLI init command
Also adds 'No Theme' option to Storybook toolbar for testing
components without any theme wrapper.
Co-authored-by: Navi <[email protected]>
Replace workspace:* with * for yarn v1 compatibility. Add proper version ranges for theme package devDependencies. Add @xds/theme aliases to Storybook Vite + StyleX config. Co-authored-by: Navi <[email protected]>
defaultTheme.stylex.ts and neutralTheme.stylex.ts now live in packages/theme/. The copies in packages/core/src/theme/ are no longer imported by anything. Co-authored-by: Navi <[email protected]>
656aef8 to
98dfe99
Compare
Text, Heading, and FontWrapper tests were importing defaultTheme from the old location. These tests don't need a theme wrapper — components work standalone with base token defaults. Co-authored-by: Navi <[email protected]>
Components should work without a theme provider. useXDSTheme now returns null instead of throwing when used outside <XDSTheme>. Updated XDSFontWrapper to handle the null case with optional chaining, consistent with how all other components already use useContext(ThemeContext) directly. Co-authored-by: Navi <[email protected]>
PR Analysis Report📚 Storybook PreviewModified ComponentsText
Bundle Size Summary
Accessibility AuditStatus: 4 accessibility violation(s) found. XDSText - 2 issue(s)
XDSTextArea - 1 issue(s)
XDSTextInput - 1 issue(s)
Component PreviewsIncludes interactive hover previews as animated GIFs. XDSTextBodyScreenshot: Interaction Preview: (view video) Run LargeScreenshot: Interaction Preview: (view video) Run LabelScreenshot: Interaction Preview: (view video) Run SupportingScreenshot: Interaction Preview: (view video) Run CodeScreenshot: Interaction Preview: (view video) Run All TypesScreenshot: Interaction Preview: (view video) Run Color VariantsScreenshot: Interaction Preview: (view video) Run Weight VariantsScreenshot: Interaction Preview: (view video) Run Display ModesScreenshot: Interaction Preview: (view video) Run Single Line TruncationScreenshot: Interaction Preview: (view video) Run Multi Line TruncationScreenshot: Interaction Preview: (view video) Run Truncation Without TooltipScreenshot: Interaction Preview: (view video) Run Truncation VariantsScreenshot: Interaction Preview: (view video) Run Word Break VariantsScreenshot: Interaction Preview: (view video) Run Text Wrap VariantsScreenshot: Interaction Preview: (view video) Run StrikethroughScreenshot: Interaction Preview: (view video) Run Tabular NumbersScreenshot: Interaction Preview: (view video) Run CapsizeScreenshot: Interaction Preview: (view video) Run As ElementsScreenshot: Interaction Preview: (view video) Run Card ExampleScreenshot: Interaction Preview: (view video) Run Metrics ExampleScreenshot: Interaction Preview: (view video) Run Form ExampleScreenshot: Interaction Preview: (view video) Run Generated by PR Enrichment workflow | Storybook | View full report |
Packaging consideration: cross-package imports for source distributionThe relative path imports in theme files ( Suggestion: use package specifiers + StyleX
|
Replace relative path imports ('../../../core/src/theme/tokens.stylex')
with clean package specifiers ('@xds/core/theme/tokens.stylex').
This makes theme files portable across monorepo and source distribution:
- Monorepo: resolved via tsconfig paths + StyleX aliases
- Source tarball: resolved via StyleX aliases pointing to node_modules
Changes:
- Theme files: import from '@xds/core/theme/tokens.stylex'
- @xds/core package.json: add './theme/tokens.stylex' subpath export
- Theme tsconfig: add paths for '@xds/core/*'
- Theme tsup: add StyleX aliases config
Co-authored-by: Navi <[email protected]>
…ring Vite uses LightningCSS as its CSS transformer, which polyfills light-dark() into --lightningcss-light/--lightningcss-dark custom properties when targeting older browsers. Set explicit targets to Chrome 123+, Firefox 120+, Safari 17.5+ (where light-dark() is natively supported) to keep the output clean. Co-authored-by: Navi <[email protected]>
* feat(theme): separate themes into @xds/theme package
Move defaultTheme and neutralTheme from @xds/core into a new
@xds/theme package with subpath exports:
- import { defaultTheme } from '@xds/theme/default'
- import { neutralTheme } from '@xds/theme/neutral'
@xds/core retains theme infrastructure (tokens, ThemeContext,
XDSTheme provider, types). Components work without any theme
applied using base defineVars defaults.
Theme files import tokens via relative path to core source
for StyleX createTheme cross-package compatibility.
Updates all downstream consumers:
- Storybook preview + stories
- Sandbox app
- CLI init command
Also adds 'No Theme' option to Storybook toolbar for testing
components without any theme wrapper.
Co-authored-by: Navi <[email protected]>
* fix: use yarn v1 compatible dependency specifiers
Replace workspace:* with * for yarn v1 compatibility.
Add proper version ranges for theme package devDependencies.
Add @xds/theme aliases to Storybook Vite + StyleX config.
Co-authored-by: Navi <[email protected]>
* chore: remove old theme files from @xds/core
defaultTheme.stylex.ts and neutralTheme.stylex.ts now live in
packages/theme/. The copies in packages/core/src/theme/ are no
longer imported by anything.
Co-authored-by: Navi <[email protected]>
* fix(tests): remove theme dependency from core component tests
Text, Heading, and FontWrapper tests were importing defaultTheme
from the old location. These tests don't need a theme wrapper —
components work standalone with base token defaults.
Co-authored-by: Navi <[email protected]>
* fix(theme): make useXDSTheme return null when no provider
Components should work without a theme provider. useXDSTheme now
returns null instead of throwing when used outside <XDSTheme>.
Updated XDSFontWrapper to handle the null case with optional
chaining, consistent with how all other components already
use useContext(ThemeContext) directly.
Co-authored-by: Navi <[email protected]>
* refactor(theme): use package specifier imports + StyleX aliases
Replace relative path imports ('../../../core/src/theme/tokens.stylex')
with clean package specifiers ('@xds/core/theme/tokens.stylex').
This makes theme files portable across monorepo and source distribution:
- Monorepo: resolved via tsconfig paths + StyleX aliases
- Source tarball: resolved via StyleX aliases pointing to node_modules
Changes:
- Theme files: import from '@xds/core/theme/tokens.stylex'
- @xds/core package.json: add './theme/tokens.stylex' subpath export
- Theme tsconfig: add paths for '@xds/core/*'
- Theme tsup: add StyleX aliases config
Co-authored-by: Navi <[email protected]>
* fix(storybook): set LightningCSS targets to prevent light-dark() lowering
Vite uses LightningCSS as its CSS transformer, which polyfills light-dark()
into --lightningcss-light/--lightningcss-dark custom properties when targeting
older browsers. Set explicit targets to Chrome 123+, Firefox 120+, Safari 17.5+
(where light-dark() is natively supported) to keep the output clean.
Co-authored-by: Navi <[email protected]>
---------
Co-authored-by: Navi <[email protected]>
* feat(theme): separate themes into @xds/theme package
Move defaultTheme and neutralTheme from @xds/core into a new
@xds/theme package with subpath exports:
- import { defaultTheme } from '@xds/theme/default'
- import { neutralTheme } from '@xds/theme/neutral'
@xds/core retains theme infrastructure (tokens, ThemeContext,
XDSTheme provider, types). Components work without any theme
applied using base defineVars defaults.
Theme files import tokens via relative path to core source
for StyleX createTheme cross-package compatibility.
Updates all downstream consumers:
- Storybook preview + stories
- Sandbox app
- CLI init command
Also adds 'No Theme' option to Storybook toolbar for testing
components without any theme wrapper.
* fix: use yarn v1 compatible dependency specifiers
Replace workspace:* with * for yarn v1 compatibility.
Add proper version ranges for theme package devDependencies.
Add @xds/theme aliases to Storybook Vite + StyleX config.
* chore: remove old theme files from @xds/core
defaultTheme.stylex.ts and neutralTheme.stylex.ts now live in
packages/theme/. The copies in packages/core/src/theme/ are no
longer imported by anything.
* fix(tests): remove theme dependency from core component tests
Text, Heading, and FontWrapper tests were importing defaultTheme
from the old location. These tests don't need a theme wrapper —
components work standalone with base token defaults.
* fix(theme): make useXDSTheme return null when no provider
Components should work without a theme provider. useXDSTheme now
returns null instead of throwing when used outside <XDSTheme>.
Updated XDSFontWrapper to handle the null case with optional
chaining, consistent with how all other components already
use useContext(ThemeContext) directly.
* refactor(theme): use package specifier imports + StyleX aliases
Replace relative path imports ('../../../core/src/theme/tokens.stylex')
with clean package specifiers ('@xds/core/theme/tokens.stylex').
This makes theme files portable across monorepo and source distribution:
- Monorepo: resolved via tsconfig paths + StyleX aliases
- Source tarball: resolved via StyleX aliases pointing to node_modules
Changes:
- Theme files: import from '@xds/core/theme/tokens.stylex'
- @xds/core package.json: add './theme/tokens.stylex' subpath export
- Theme tsconfig: add paths for '@xds/core/*'
- Theme tsup: add StyleX aliases config
* fix(storybook): set LightningCSS targets to prevent light-dark() lowering
Vite uses LightningCSS as its CSS transformer, which polyfills light-dark()
into --lightningcss-light/--lightningcss-dark custom properties when targeting
older browsers. Set explicit targets to Chrome 123+, Firefox 120+, Safari 17.5+
(where light-dark() is natively supported) to keep the output clean.
---------
Summary
Extracts themes from
@xds/coreinto a new@xds/themepackage. Components now work standalone with no theme — themes are optional overlays that consumers opt into.Depends on #140 (base tokens with
light-dark()defaults — cherry-picked into this branch).What Changed
New:
packages/theme/(@xds/theme)@xds/theme/defaultand@xds/theme/neutral@xds/core../../../core/src/theme/tokens.stylex) for StyleXcreateThemecross-package compatibility (see spike findings in Separate themes into their own package (@xds/themes) #139)ThemeTypealias from@xds/core/themesinceThemeis exported as a component valueas Theme['components']assertion sinceComponentStylesaugmentations aren't visible across package boundariesUpdated:
@xds/core/themedefaultThemeandneutralThemere-exports fromindex.tsXDSTheme,useXDSTheme, tokens, typesUpdated: Downstream consumers
apps/storybook/.storybook/preview.tsx@xds/theme/*, added "No Theme" toolbar optionapps/storybook/stories/Layout.stories.tsx@xds/theme/*apps/storybook/stories/FontWrapper.stories.tsxapps/sandbox/src/app/layout.tsx@xds/theme/defaultpackages/cli/src/commands/init.mjsapps/storybook/package.json@xds/themedependencyapps/sandbox/package.json@xds/themedependencyUsage
Technical Notes
Cross-package
createThemeStyleX's
createThemerequires resolving the originaldefineVarssource file. Importing via@xds/core/theme(which resolves todist/) breaks static analysis. The solution: theme files use relative imports to the core source (../../../core/src/theme/tokens.stylex), which StyleX resolves correctly. See spike findings in #139.Module augmentation boundary
ComponentStylesis augmented by components viadeclare module(e.g.,XDSButtonaddsbutton?: {...}). Since the theme package doesn't import components, these augmentations aren't visible — hence theas Theme['components']assertion. Types are enforced at the consumer site where both components and themes are imported.Testing
npx tsc --noEmitpasses for bothpackages/themeandpackages/coreRelated
@xds/themes) #139 — Separate themes into their own package (tracking issue)light-dark()defaults (prerequisite)Crafted with care by Navi