Replies: 1 comment 4 replies
-
The design of Panda is such that we won't have to rely on the css output order. Merging shorthand and longhand properties like this is one area we're looking to improve in Panda over time such that In mean time, we intend to ship an ESLint rule "prefer-longhand-properties" that shows an error/warning when using shorthand like Panda uses a combination of smart merging techniques and cascade layer to ensure that we never have to rely on deterministic rule order.
|
Beta Was this translation helpful? Give feedback.
-
Description
I'm considering using Panda for a large new project, as it supports many of the features I'm looking for: minimal runtime cost, atomic CSS output from CSS-in-JS object syntax input, RSC support, etc.
One of the other features I'd like to see in my CSS tooling is that CSS used in one component cannot affect the styling of another component (absent obvious loopholes like child and descendant combinators), but this is not the case in Panda. In particular, by mixing shorthand and longhand properties it's possible to construct cases where adding/removing CSS in one component changes the styling of another component.
In the playground I've constructed you can see an example of this with two components in the same file, but the same behavior could equally happen with two completely unrelated components, meaning that an engineer changing one part of a large codebase could inadvertently break the styling of some completely unrelated feature in another part of the codebase.
Is there a recommended solution here to avoid the risk of introducing bugs in other parts of the codebase? How have other users of Panda addressed this?
Thanks in advance for any insight you can provide!
Link to Reproduction
https://play.panda-css.com/ChaNc7V-5f
Steps to reproduce
SpacingComponent
: 200pxclassName
prop on theApp
component's inner<div>
(the one with thedata-text
prop)Specifically this is because the ordering in the output CSS has changed: with all CSS in place the
.pt_0px
definition comes before the.p_100px
definition, but after commenting out theclassName
prop the.p_100px
definition comes before the.pt_0px
definition.JS Framework
React, TS
Panda CSS Version
"@pandacss/dev": "0.30.1",
Browser
Any
Operating System
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions