stylex icon indicating copy to clipboard operation
stylex copied to clipboard

feat: Allow "var(--" strings as values for all properties

Open nmn opened this issue 1 year ago • 6 comments

What changed / motivation ?

CSS properties are typed in StyleX, and while some properties allow arbitrary strings, many don't. These properties should still permit usages of string referencing CSS variables. The new StringPrefix<> type in Flow makes this possible.

nmn avatar Jul 22 '24 22:07 nmn

compressed-size: runtime library

Size change: +0.00 kB Total size: 2.52 kB

Filename: gzip (minify) kB size kB change % change
./packages/stylex/lib/StyleXSheet.js 1.48 (3.75) +0.00 (+0.00) +0.1% (+0.1%)
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%)

github-actions[bot] avatar Jul 22 '24 22:07 github-actions[bot]

compressed-size: e2e bundles

Size change: 0.00 kB Total size: 1125.68 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.19 (774.43) 0.00 (0.00) 0.0% (0.0%)

github-actions[bot] avatar Jul 22 '24 22:07 github-actions[bot]

We need so many FlowFixMe to use this API 🥲

necolas avatar Jul 24 '24 15:07 necolas

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

@stylexjs/[email protected] size:compare ./size-compare.js /tmp/tmp.yZNU1UH0mS /tmp/tmp.JKLLiRdqtC

Results Base Patch Ratio
stylex/lib/stylex.js
· compressed 899 899 1.00
· minified 3,223 3,223 1.00
stylex/lib/StyleXSheet.js
· compressed 1,266 1,266 1.00
· minified 3,776 3,776 1.00
rollup-example/.build/bundle.js
· compressed 563,484 563,484 1.00
· minified 10,185,368 10,185,368 1.00
rollup-example/.build/stylex.css
· compressed 99,154 99,154 1.00
· minified 745,649 745,649 1.00

github-actions[bot] avatar Sep 10 '24 08:09 github-actions[bot]

NOTE: this will be merged after verifying how it affects our code internally.

nmn avatar Sep 10 '24 22:09 nmn

Update: The StringPrefix type still isn't ready. It has some strange bugs when being used for reads. So, this PR will have to wait for now.

nmn avatar Oct 03 '24 03:10 nmn

Closing old PRs

necolas avatar Mar 06 '25 20:03 necolas