Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add theme override behaviour configuration #631

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nmn
Copy link
Contributor

@nmn nmn commented Jul 6, 2024

Resolves #601

Add a new configuration option called themeOverride that can have the values:

  • var (current behaviour) - Only the variables set in the theme are overridden, the rest of the variables are unaffected
  • group - When setting a theme for a VarGroup, any variable omitted in the theme is set back to it's default value (when declared using defineVars)
  • global - When setting a theme all variables not in theme are reset back to their defaults, globally in all VarGroups.
    • With this configuration, in order to apply custom themes for different VarGroups, the themes must be applied to the same HTML element.

TODO: Some more tests to be added.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 6, 2024
Copy link

github-actions bot commented Jul 6, 2024

compressed-size: runtime library

Size change: 0.00 kB
Total size: 2.52 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./packages/stylex/lib/stylex.js 1.04 (3.22) 0.00 (0.00) 0.0% (0.0%)
./packages/stylex/lib/StyleXSheet.js 1.48 (3.75) 0.00 (0.00) 0.0% (0.0%)

Copy link

github-actions bot commented Jul 6, 2024

compressed-size: e2e bundles

Size change: 0.00 kB
Total size: 1125.73 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./apps/rollup-example/.build/bundle.js 1002.49 (10185.35) 0.00 (0.00) 0.0% (0.0%)
./apps/rollup-example/.build/stylex.css 123.24 (774.87) 0.00 (0.00) 0.0% (0.0%)

@nmn nmn requested a review from necolas July 9, 2024 12:01
@necolas
Copy link
Contributor

necolas commented Sep 9, 2024

Having options means that code could be author using one option and then work totally differently if used in a project that sets a different option. Internally we're only going to use one of these so probably best to just add that one. The extra complexity here doesn't seem worth it to me

@nmn
Copy link
Contributor Author

nmn commented Sep 10, 2024

I agree that the complexity isn't worth it. I didn't want to make a decision at the time as I don't agree with how global works as how themes should work. I also verified that other libraries like Vanilla Extract don't do theming the way global does.

Both var or group make sense to me however. var is currently the default and changing the behaviour to group sounds like a good idea to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Reactive Variables) Support of swapping underlying variables while using hierarchical variable references
3 participants