vanilla-extract icon indicating copy to clipboard operation
vanilla-extract copied to clipboard

Calc methods should support unitless values

Open gkiely opened this issue 3 years ago • 1 comments

Describe the bug

export const ul = style({
  marginBottom: calc.subtract('3rem', 6),
});

// Should be converted to:
margin-bottom: calc(3rem - 6px);

// Actually coverts to:
margin-bottom: calc(3rem - 6);

Reproduction

https://codesandbox.io/s/quirky-grass-k0zvny?file=/src/styles.css.ts

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 506.03 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.4.0 - ~/.volta/tools/image/node/18.4.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 8.12.1 - ~/.volta/tools/image/node/18.4.0/bin/npm
    Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 105.0.5195.102
    Firefox: 103.0.2
    Safari: 15.3
  npmPackages:
    @vanilla-extract/css: ^1.7.4 => 1.7.4 
    @vanilla-extract/css-utils: ^0.1.2 => 0.1.2 
    @vanilla-extract/vite-plugin: ^3.3.1 => 3.3.1 
    vite: ^3.1.0 => 3.1.0

Used Package Manager

npm

Logs

No response

Validations

gkiely avatar Sep 07 '22 18:09 gkiely

calc can be used for non-pixel values like opacity or calc.multiply("5px", 2) which should not be converted to pixels.

rothsandro avatar Sep 12 '22 18:09 rothsandro

Yes, this is not really something that can be inferred as it is perfectly valid to use unitless values in calculations.

michaeltaranto avatar Feb 07 '23 04:02 michaeltaranto