Replies: 4 comments 8 replies
-
The only thing I don't like about this solution is that it limits the usage to theme keys, while cases where you want property values are not covered, like in this example #721 (comment). |
Beta Was this translation helpful? Give feedback.
-
Worthy mention: @pleunv's |
Beta Was this translation helpful? Give feedback.
-
This comment is a response to @pleunv's Commenting here as #721 is more about dynamic variant. If we offer an API for this, we're saying "it's a good idea", and I'm not yet convinced it is. Variants were not designed to be "CSS Properties". They were designed to be true variation of a component, like a I understand if you're coming from styled-system/theme-ui/chakra-ui it feels natural to pass CSS properties as prop, but that's not the goal with Stitches. That's why Stitches offers the
I'd like to understand more about the maintenance here. In design system worlds, changing tokens is an enormous breaking change. And something that rarely happens (if ever). Personally I think repetition and manual fixes are good! |
Beta Was this translation helpful? Give feedback.
-
It was not immediately clear to me when I first started tinkering with Stitches, but I do understand now that a prop API is not one of its goals. Which is fine, tooling can be (should be?) opinionated to some extent. It's then up to us to decide whether we want to adopt it or not. Just to give you some perspective on what I was trying to achieve with that Being able to swap out the underlying styling library without the need to change thousands of lines of JSX and styles is of course a massive benefit, while definitely also having its drawbacks. The library you're adopting might have a different philosophy and core principles which you are deliberately ignoring because you just want your code to run, while it has to provide this compatibility layer that might cause friction in its ecosystem and a maintenance burden moving forward. I agree that providing this functionality as part of Stitches' core when you haven't figured out yet if and how it fits into Stitches' core design is not a good idea. One possible solution here could be to provide it as some sort of separate compat layer, or give the community a way to plug one in (i.e. preact compat). I'm sure there are patterns in our codebase we've adopted over the past few years that can be done differently and/or better today, which is one of the points I see being made here and there. The difficulty is that detecting and adapting these is an effort that takes time. Time to familiarise yourself with a new library and gain new insights, time to transform these insights into actionable changes, and time to actually apply all these changes throughout your code. I believe you when you say that doing X in Stitches is better than how we used to do Y instead before Stitches, and I think it's important to share these insights in order to share experiences, push better practices and improve everyone's quality of life. But, you are only realistically able to apply these immediately when you're starting a project from scratch or have a smallish project and/or a small team that can be easily adjusted. Any other scenario will be almost impossible to tackle. This is basically where I was coming from. We have a large codebase built on top of styled-system and emotion. Styled-system has since become unmaintained, and we have adopted TypeScript. Both of these changes make styled-system rather annoying and painful to use. Having a way to swap out both styled-system and emotion without requiring a massive migration effort would of course be the prefered scenario here, but that is only feasible when the styling library we switch to can offer a similar prop API that the scale values can slot into. Again, not telling you to go this or that direction, just giving you one use-case which I'm sure also applies to other teams out there (if so, let yourselves be heard 😄). When it comes to To briefly touch the "prop API vs All of that said, Sprinkles is definitely one of the most exciting libraries I have run into in recent years, and you're all doing a stellar job 😄 |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
One thing I find myself doing regularly with stitches is mapping through themed values to generate my variants
For example, let's look at this demo
grid
style which reducestheme.space
into agap
variant:Which can then be used like so:
This solution's OK for one or two components, but it can become tedious and might not be immediately obvious for those expecting Stitches to offer "dynamic variants" from other run-time styling libraries.
Describe the solution you'd like
I'm not super keen on this exact proposed API, but I think something like this could enable users to roll their own themed variants (without having to worry about some of the runtime concerns that come with dynamic themed variants)
Describe alternatives you've considered
An alternative approach to #721
Additional context
This issue was raised following an informal chat of ideas with @peduarte
Beta Was this translation helpful? Give feedback.
All reactions