stitchesjs / stitches

[Not Actively Maintained] CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience.
https://stitches.dev
MIT License
7.73k stars 249 forks source link

Dynamic Variants #1095

Closed nmhieu1896 closed 1 year ago

nmhieu1896 commented 1 year ago

Hello guys,

Firstly, I just want to know if this project is still in developing or not, because I'm sooooo in love with Stitches. Looking it haven't got any commits for the last 5 months is so sad :(

If this's still in progress, I hope that we can have dynamic variants or component scope utils. For details, we can pass a dynamic values to variants as a function argument like we did with utils.

hope to see your comeback.

hadihallak commented 1 year ago

Hey @nmhieu1896 👋

We don't plan on adding dynamic variants as part of the library as most of the cases for dynamic variants can be achieved with normal variants and custom css properties.

I've made a demo here and the a bit of a discussion about it is available on discord

misaku commented 1 year ago

if i wouldlike create progressbar and i passed progress how can i do this without dinamic variant?

LexSwed commented 1 year ago

As an option (not a real code I tested)

const ProgressBar = styled('div', {
  width: '100%',
  transform: 'scaleX(var(--progress-bar-status, 0))',
})

const App = ({ progress }) => {
  return <ProgressBar style={{ --progress-bar-status: progress / 100 } as SomethingToSurpressReactStyleBeingUnhappy) />;
}