stitches icon indicating copy to clipboard operation
stitches copied to clipboard

Initial variant not applied when same as breakpoint variant

Open dlehmhus opened this issue 4 years ago • 8 comments

Bug report

Describe the bug

Context: Responsive Styles When setting the @initial variant to the same variant as the breakpoint, the initial variant gets not applied.

    <Container colorMode={{ "@initial": "light", "@bp1": "light" }}>
      <h1>Expected background-color: rgb(255 250 126) </h1>
    </Container>

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to CodeSandbox

Expected behavior

The initial variant should be applied, even it is the same for all breakpoints variants.

dlehmhus avatar Dec 13 '21 15:12 dlehmhus

@hadihallak Toggling between variants all seems to not be applied correctly. I believe this is due to duplicate class names being removed.

Eg:

  <Container colorMode={{ "@initial": "light", "@bp1": "dark", "@bp2": "light" }}>
     <h1>Expected Background color: rgb(255 250 126) </h1>
  </Container>
Screen Shot 2022-06-29 at 9 56 05 AM

DevinEdwards avatar Jun 29 '22 16:06 DevinEdwards

@DevinEdwards Not sure I fully understand this, would you be able to share a new codesandbox

hadihallak avatar Jul 04 '22 19:07 hadihallak

Sure thing @hadihallak. I forked the above and added extra breakpoints to illustrate the issue.

Codesandbox

Repeating responsive variants at different breakpoints doesn't work. From my perspective, Stitches relies on the ordering of class names for the specificity of responsive variants, and the duplicate class names are being stripped out.

For the record Stitches is amazing, and really appreciate all the time and effort that has been put into it. 🙏🏼

DevinEdwards avatar Jul 05 '22 16:07 DevinEdwards

Hi @hadihallak, this is the message I sent you in Discord - I think you were able to pinpoint the issue then as you pointed me to this thread!

Message link reference: https://discord.com/channels/752614004387610674/752795957674115092/989805725205291068

Message Content: For example: <Grid columns={{ "@initial": 2, "@bp1": 1, "@bp2": 2 }}> ✅ @bp1 - children items are laid out as 1 column ✅ @bp2 - children items are laid out as 2 columns. This also validates that 2 columns works. ❌ @intial - the code of the variant is simply not applied. Columns are not applied as indicated. Here is a codesandbox to easily see the issue. @bp1 starts at 100px, @bp2 starts at 200px. https://codesandbox.io/s/stitches-forked-tbwxcx?file=/src/App.js:929-992

MichaelDM avatar Jul 05 '22 18:07 MichaelDM

@DevinEdwards Thanks! really appreciate the support 🙏 Looks like you ended up linking the same codesandbox of the original issue by a mistake in your comment so would be helpful if you fix that

hadihallak avatar Jul 05 '22 19:07 hadihallak

@hadihallak. My apologies updated link here & edited above ☝🏼

DevinEdwards avatar Jul 05 '22 20:07 DevinEdwards

@DevinEdwards Thanks a lot for the updated link — it adds so much more context to this bug 🙏 I'm rewriting the internal sheet implementation of stitches and there is a very high chance this bug will automatically be fixed and be a s part of the 2.0 release.

Will keep you all updated in this issue once the fix is confirmed

hadihallak avatar Jul 06 '22 10:07 hadihallak

Hi @hadihallak, any news?

antoine-lin avatar Sep 07 '22 23:09 antoine-lin