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

Enable setting a single var from stylex.defineVars #7

Merged
merged 3 commits into from
Nov 27, 2023
Merged

Conversation

nmn
Copy link
Contributor

@nmn nmn commented Nov 22, 2023

@necolas mentioned that when using the workaround for descendent selector, the variable should come from defineVars. This adds basic support for doing just that.

Here are the current limitations:

  1. defineVars still needs to be in a separate .stylex.js file.
    • It should be possible to allow using defineVars inline within a file as long as it is only used within stylex.create or stylex.createTheme calls. No exports.
    • But, any use-cases for defining variables in the same file will be solved with better solutions.
  2. The ESlint rule only allows an object value
    • It might make sense to verify the value is a string at the very least as it's not clear what a number value should be.

@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 Nov 22, 2023
@nmn nmn requested a review from necolas November 22, 2023 10:56
Copy link

compressed-size: runtime library

Size change: 0.00 kB
Total size: 2.36 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./packages/stylex/lib/stylex.js 1.02 (3.53) 0.00 (0.00) 0.0% (0.0%)
./packages/stylex/lib/StyleXSheet.js 1.34 (3.41) 0.00 (0.00) 0.0% (0.0%)

Copy link

compressed-size: e2e bundles

Size change: 0.00 kB
Total size: 1119.39 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./apps/rollup-example/.build/bundle.js 1005.22 (9872.52) 0.00 (0.00) 0.0% (0.0%)
./apps/rollup-example/.build/stylex.css 114.18 (455.95) 0.00 (0.00) 0.0% (0.0%)

@nmn nmn merged commit 1149e49 into main Nov 27, 2023
7 checks passed
@nmn nmn deleted the set-vars-as-props branch November 27, 2023 11:57
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.

2 participants