stitches icon indicating copy to clipboard operation
stitches copied to clipboard

Variants incorrect priority

Open panzelva opened this issue 3 years ago • 2 comments

Bug report

Describe the bug

Looks like there is some inconsistency how stitches prioritizes styles from variants. I would expect, that variant that is declared later in styled component would take priority, but it looks like sometimes it does and sometimes it doesn't. If this is not the case, I would expect that it is atleast consistent.

I guess that this is not big issue, because I can use compoundVariants, but the inconsistency seems wierd.

To Reproduce

Please see this sandbox.

In the sandbox, there is styled component Button, that has variants variant and isDisabled. When combining these variants, isDisabled sometimes takes priority, sometimes doesn't.

Expected behavior

isDisabled always takes priority, because its declared later in styled component.

Screenshots

image

System information

  • OS: Ubuntu 21.10
  • Browser: chrome
  • Version of Stitches: 1.2.7
  • Version of Node.js: 16.14.0

panzelva avatar Apr 22 '22 14:04 panzelva

Related: https://github.com/stitchesjs/stitches/issues/883

lucastobrazil avatar Jun 02 '22 23:06 lucastobrazil

I changed this behavior in the fork I prepared for my company. Variants take priority due to the order of declaration, not the order of use

https://github.com/patchkit-net/stitches

yarn add git+https://github.com/patchkit-net/stitches-react-package.git

stitches-fork-demo.zip stitches-original-demo.zip Original: original Forked: fork

b3ncr0w avatar Sep 06 '23 21:09 b3ncr0w