amzn / style-dictionary

A build system for creating cross-platform styles.
https://amzn.github.io/style-dictionary/#/
Apache License 2.0
3.75k stars 525 forks source link

The size/rem tranform ads units (rem) to zero based values #1267

Open bengie opened 3 days ago

bengie commented 3 days ago

My setup is Styledictionary 4.0.0 with sd-transdorms 1.1.0 and now I get the rem unit appended to all 0 based values in CSS

// before
---some-border-width: 0;
// now
--some-border-width: 0rem;

Expected result: no units appended to zero-based values.

The size/rem transform doesn't account for zero-based values, see https://github.com/amzn/style-dictionary/blob/main/lib/common/transforms.js#L824

An example from sd-transforms that does account for zero-based values, see: https://github.com/tokens-studio/sd-transforms/blob/main/src/transformDimension.ts#L3

jorenbroekema commented 3 days ago

Yep would be good to follow the example from sd-transforms here and ignore 0 values, since 0 doesn't need a unit. PRs welcome!