feat: Unify CSS-to-RN compiler and runtime pipeline - #5
Merged
Conversation
cray0000
marked this pull request as ready for review
June 24, 2026 02:30
cray0000
added a commit
to startupjs/startupjs
that referenced
this pull request
Jun 24, 2026
## Summary - wrap `StartupjsProvider` children in CSSX `CssxProvider` - pass `StartupjsProvider style` into CSSX and through the existing plugin `renderRoot` hook - pass `StartupjsProvider theme` into CSSX so apps can select `auto`, `default`, `light`, `dark`, or custom CSSX themes from the framework root - add a `.d.ts` surface for `StartupjsProvider`, including CSSX provider style and theme inputs - re-export CSSX theme assets from `startupjs/themes/tailwind` and `startupjs/themes/shadcn` ## Why The CSS-first UI theme migration needs framework users to configure global CSSX variables, utility classes, component tag overrides, and theme selection through the normal StartupJS root provider. Direct CSSX users can still use `CssxProvider` themselves; StartupJS users can pass the same style and theme inputs to `StartupjsProvider`. Bare StartupJS still does not include Tailwind, shadcn, or StartupJS UI theme styles by default. Those are included by startupjs-ui when its plugin injects the UI provider. ## Related PRs - startupjs/cssx#5 adds the unified CSSX compiler/runtime, `CssxProvider`, provider-scoped `:root`, tag selectors, CSS variable hooks, OKLCH/color-mix evaluation, custom media, theme assets, and runtime CSS support. - startupjs/startupjs-ui#41 moves the UI theme system onto CSSX theme assets, `startupjsUiTheme.cssx.css`, direct CSS variable primitives, and component tag/part overrides. ## Validation - `NODE_OPTIONS="-C cssx-ts" npm test` in `core/startupjs` - normal pre-commit hook, including eslint and `npx startupjs check`
cray0000
added a commit
to startupjs/startupjs-ui
that referenced
this pull request
Jun 24, 2026
## Summary
- migrate StartupJS UI to the CSSX-first theme model backed by CSS
variables, component tag selectors, and `:part()` overrides
- compose `UiProvider` from CSSX Tailwind tokens, CSSX shadcn semantic
tokens, and `startupjsUiTheme.cssx.css`, with app-provided
`StartupjsProvider style` layered after UI defaults
- replace the old palette/Colors/CssVariables theme runtime with normal
CSSX `:root` variables and semantic `--color-*` tokens
- remove public `useThemeColor()`, `getThemeColor()`,
`getThemeColorVariableName()`, `Colors`, `Palette`, `CssVariables`,
`generateColors`, and `useColors` APIs
- keep `@startupjs-ui/core` as a tiny non-style package for the `UIRole`
type only
- refactor component JS color reads to CSSX `useCssColor()` /
`useCssVariable()` primitives re-exported from `startupjs`
- inline all component, demo, MDX renderer, and docs styles into local
`css` templates; only the package-level `startupjsUiTheme.cssx.css`
theme asset remains
- replace Stylus helpers, `$UI`, `u`, `:export config`, and separate
`.cssx.styl` files with CSS variables, `rem`, `color-mix()`, `oklch()`,
and CSSX custom media
- preserve component customization through `themed(name, Component)`,
component tag selectors, semantic `part` props, and per-instance `style`
/ `*Style` props
- update documentation to present `StartupjsProvider style`, CSSX
tokens, tag overrides, and `:part()` as the customization model
- keep the generic Styling guide as the canonical theming doc while
component pages document only their own parts and variables/defaults
- memoize the UI provider style layer array so provider context does not
churn when `style` is unchanged
- improve generated part reference extraction for conditional part
arrays such as TextInput icon parts
## Why
CSSX now owns provider-scoped `:root` variables, global utility classes,
component tag selectors, `:part()` / `::part()` overrides, subscribed
CSS variable reads, OKLCH evaluation, and `color-mix()`. Keeping palette
generation, theme-color hooks, theme context, component override wiring,
or style helpers inside startupjs-ui would duplicate that model and keep
theming in the wrong layer.
With this change, the StartupJS UI theme is normal CSSX CSS:
```css
:root {
--color-primary: oklch(0.55 0.22 260);
--Button-radius: var(--radius-md);
}
Button {
border-radius: 12px;
}
Button:part(text) {
color: var(--color-primary-foreground);
}
```
Component color props still accept tokens such as `primary`, which map
to `--color-primary`. Raw CSS values and `var(--x)` remain valid where
component props accept raw colors.
## Related PRs
- startupjs/cssx#5 adds the unified CSSX compiler/runtime,
`CssxProvider`, provider-scoped `:root`, component tag selectors, CSS
variable/color hooks, OKLCH/color-mix evaluation, custom media, runtime
CSS support, and source-condition types.
- startupjs/startupjs#1327 wires `StartupjsProvider style` and `theme`
into CSSX so framework users can configure this without importing CSSX
directly.
## Validation
- `node scripts/update-style-reference-docs.mjs` idempotency check
- `yarn generate-package-dts`
- `node scripts/check-startupjs-ui-exports.mjs`
- `yarn build` for the docs app
- `git diff --check`
- CSSX docs/provider smoke with local source links:
- generic `/docs/Styling` theming guide renders and remains the
canonical styling model doc
- `/docs/TextInput` renders and includes conditional `inputIconLeft` /
`inputIconRight` parts
- component docs for Button, Item, Div, and DateTimePicker render their
generated Styling reference sections
- component reference sections list parts and component-specific
variables/defaults and link back to the generic Styling guide
- no unknown CSS color token warnings or page errors observed
- Storybook runtime smoke through `http://localhost:4400/iframe.html`:
- Introduction/Overview
- Actions/Button
- Data/Item
- Display/Badge
- Feedback/Modal
- Overlay/Popover
- System/StartupJS UI
- Inputs/TextInput
- Inputs/DateTimePicker
- Visual screenshots checked for Styling, Button, Item, DateTimePicker,
provider, and popover pages/stories.
- Known during DateTimePicker smoke: Moment Timezone logs its existing
missing timezone-data warning; no CSS token, page, or provider errors
were observed.
- Previous validation in this draft also included `yarn install
--immutable --mode=skip-build`, targeted eslint over migrated
packages/docs slices, and direct CSS-template compile smoke over
`packages/` plus `startupjsUiTheme.cssx.css`.
## Review Focus
- token naming and override surface in `startupjsUiTheme.cssx.css`
- remaining public API compatibility that should intentionally stay or
be removed for the breaking release
- `part` coverage on roots and semantically useful sub-elements
- JS-only color bridge usage where CSS variables could replace code
- docs clarity around `StartupjsProvider style`, CSSX variables,
component tag selectors, and `:part()` overrides
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR unifies the CSS-to-React-Native style pipeline into a new
@cssxjs/css-to-rnworkspace package and wires CSSX, loaders, Babel output, and runtime entrypoints through it. The goal is to replace the separate forked CSS-to-RN transform libraries and the old CSSX runtime with one maintainable compiler/runtime package.Key changes:
packages/css-to-rn, a TypeScript ESM package owning CSS parsing, selector IR, value resolution, property transforms, style resolution, caching, and React runtime tracking.css/styltemplates, with interpolation values reusing one cache slot per compiled call shape.useRuntimeCss(),useCssxLayer(), andcssx().var()resolution, partial shorthand substitution, dynamic dependency tracking, bounded cache behavior, deep inline-style hashing, media/dimension tracking, webmatchMediainvalidation, and React NativeDimensionsintegration.@nx-js/observer-util, including Suspense/aborted-render cleanup tests.CssxProvider styleandthemefor subtree-scoped provider CSS, global utility classes, scoped:root/:root.<theme>variables, OS dark-mode auto selection, and component tag overrides.cssxjs/themes/tailwindandcssxjs/themes/shadcn.@custom-media, CSS media range evaluation for width/height comparisons, built-in@media (--theme-*)aliases, and provider-awareuseMedia().themed(tagName, Component), includingTag,Tag.class,Tag:part(name),Tag::part(name),Tag:hover, andTag:activematching.useCssVariable(),useCssVariableRaw(),getCssVariable(), andgetCssVariableRaw()for subscribed and global JS access to resolved CSS variables.useCssColor()andgetCssColor()for provider-aware JS color bridges, including token lookup andcolor-mix()style mixing.u()helper and build diagnostics for deprecated CSSuunits.variablesanddefaultVariablesproxy methods:.assign(),.set(), and.clear().var()inside inline style props and tracks the variables used by those inline props.oklch(),oklab(), andcolor-mix()through pinned@colordx/core@5.4.3so modern color CSS works on RN.calc()in CSS value resolution for color-channel math while still rejecting mixed layout calc such ascalc(100% - 16px).color-mix(in srgb, color, transparent)with premultiplied alpha so transparent theme colors preserve the source RGB.themed()preserves wrapped component props, andcssx()accepts loader-produced opaque sheet records at the type boundary.:hover/:activealiases,filter,background-image/gradient support, limitedbackgroundshorthand, animations/transitions/keyframes, and Reanimated v4-compatible animation style output.distoutput; package builds still emitdistfor published/default exports.runtime/*-teamplayimport paths as compatibility wrappers only.packages/runtimepackage from the active graph.architecture.md,AGENTS.md,plan.md, public docs, README credits, and CI smoke checks for the new architecture.Architect Review Follow-up
After a multi-agent architecture/performance/test-coverage review, this PR now also:
useCssxLayer(false)hook order stable when toggled to a real sheet:rootcustom property values{ sheet, values }layersvar()values in box-shadow/filter/text-shadow/transform/background:rootinterpolation:part(root)to the rootstyleprop consistently in the unified resolver@custom-mediasubscriptions to concrete media dependencies and marks width/height range queries as dimension-dependentresolveCssx()for generated CSS callerscssxjs/runtime/webandcssxjs/runtime/react-nativeexporting the public CSSX/color helpers with smoke coverageRelated PRs
StartupjsProvider styleandthemeinto CSSX so framework users can pass provider CSS and theme selection through the StartupJS root provider.startupjsUiTheme.cssx.css, CSS variable primitives, and direct component tag/part overrides.Validation
cd packages/css-to-rn && npm testcd packages/babel-plugin-rn-stylename-inline && yarn testcd packages/babel-plugin-rn-stylename-to-style && yarn testgit diff --checkcd packages/cssxjs && yarn test.cssx.cssassets into consuming web builds.node scripts/update-style-reference-docs.mjsidempotency checkyarn generate-package-dtsnode scripts/check-startupjs-ui-exports.mjsyarn buildfor startupjs-ui docsNODE_OPTIONS="-C cssx-ts" npm testincore/startupjs, plus the normal pre-commit hook with eslint andnpx startupjs check.Review Focus
This is a large architectural PR. Please scrutinize:
:root/:root.<theme>variable scoping and precedence relative to runtime/default variables.@media (--theme-*)behavior.@custom-media, range media evaluation, anduseMedia()subscriptions.themed()render-local tracking model.useCssVariable()/useCssColor()exact subscriptions and Suspense/aborted-render safety.matchMediasubscriptions, React Native dimensions, and listener cleanup.var(), shorthand fragments, modern colors, gradients/backgrounds, transforms, animations, transitions, and invalid generated CSS.styleName,css,styl, and part workflows.