feat(tokens,react): theme runtime improvements#127
Closed
wangdicoder wants to merge 1 commit intomasterfrom
Closed
feat(tokens,react): theme runtime improvements#127wangdicoder wants to merge 1 commit intomasterfrom
wangdicoder wants to merge 1 commit intomasterfrom
Conversation
…rades Fix scoped light-inside-dark theming, add SSR stylesheet helper, typed token keys, a primitive token layer, and unify useTheme with ConfigProvider via a shared external store. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
base.cssnow emits light defaults under:root, [data-tiny-theme='light']so a nested<ConfigProvider theme="light">inside a dark root flips back correctly.getThemeStylesheet(theme, { selector? })in@tiny-design/tokens/resolve-theme(re-exported from@tiny-design/react) returns a CSS string for pre-hydration<style>injection, includingcolor-scheme.useActiveTheme(): returns the effective{ mode, themeConfig }for the current subtree (nearestConfigProviderwins, falls back to the document-level store).useTheme: now reads the nearestConfigProvider's mode first; accepts{ initialMode }for SSR hydration. Extracted the shared external store into_utils/theme-store.ts.dist/registry.d.tsexportsPrimitiveTokenKey,SemanticTokenKey,ComponentTokenKey, andTokenKeyunions;dist/presets.d.tsexportsTypedThemeDocumentfor autocompleted theme authoring.source/primitive/directory with an initial brand color scale and spacing scale; build loadscategory: 'primitive'. Semantic tokens keep their current defaults — migrating them to reference primitives is a follow-up.fallbacktargets and on$type/$valuemismatches forcolor,dimension, andnumber(supportscolor-mix, gradients,calc(),var(), and padding-shorthand).Release
minor@tiny-design/react,@tiny-design/tokens(fixed version group, also moves@tiny-design/iconsand@tiny-design/charts)Test plan
pnpm --filter @tiny-design/react exec jest— all 799 tests across 97 suites passpnpm --filter @tiny-design/react exec tsc --noEmit— cleanpnpm build— full turborepo build (tokens→icons→react→docs) succeeds<ConfigProvider theme="light">inside<html data-tiny-theme="dark">now renders lightuseTheme().modeinside a scoped<ConfigProvider theme="dark">reports'dark'instead of the html-level modegetThemeStylesheet({ extends: 'tiny-dark', mode: 'dark' })server-side and confirm the returned CSS has only overrides +color-scheme: dark🤖 Generated with Claude Code