feat: support shared theme-aware tw styles - #16
Draft
e-simpson wants to merge 2 commits into
Draft
Conversation
e-simpson
force-pushed
the
codex/shared-theme-styles
branch
from
July 28, 2026 02:03
d0c2f54 to
f77b614
Compare
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
dark:andlight:variants generated by module-leveltwandtwStylecalls.useTwStyle()to resolve shared styles reactively inside a component.useTwStyle()honor the Babel plugin's configuredcolorScheme.importFromandcolorScheme.importNamehook.resolveTwStyle()for explicit or controlled scheme values.Why
Hooks cannot run at module scope, but shared styles still need to retain every theme variant. A runtime helper also cannot read consumer Babel options by itself, so hardcoding React Native's system
useColorSchemewould bypass applications with a custom theme provider.The compiler now injects the configured hook at the legal component boundary and passes its value to
useTwStyle:With:
the generated component uses
useAppColorScheme(), not React Native's system hook. The plugin also rejects module-scopeuseTwStylecalls and supports aliased imports.Validation
bun run spec— 1,066 passed, 1 skippedbun run checkbun run lintbun run format:checkbun run buildgit diff --check