RFC | Design Variants for individual components #547
JayaKrishnaNamburu
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Variants
Proposal's aim's to bring component-scoped variants for individual component. Let's take a generic and common use case of a button. We will have a primary, secondary, highlighted, active, inactive etc states for a button. And these states are called as Variants. So, when we call a button from a parent component/page. We can call using
These variants are component specific and can't be re-used while defining any other component. Or anywhere else other than the component itself.
Examples for Inspiration
Let's look at Styled System's Variants and Stitches Variants.
Here are some of the points that needs a discussion and brain-storming w.r.t to variants.
Ideology
focus, disabled, media-states. Can use prop's, tokens for defining.
UIDL
So, in UIDL, we need to introduce a
styleSetDefinitions
for allComponentUIDL
. Right now, it is available only forRootComponentUIDL
, which is basically a router. We use thestyleSetDefinitions
on theroot
as project-style-sheet.Referring the variant of the root of Component
I strongly suggest that we should not mix-up the variant as a generic attr. Currently, we can simply have className dynamic attr on any node. And it just refers to the variant prop. But, here is the draw-back of the approach
https://repl.teleporthq.io/?uidlLink=u4pti7db6be446yb8rqnz1
If the component has some default styles. Then it adds the className two times. Since, generators don't know the difference between a className attr and className added by the style-plugin. So, we need to have a separate variant reference on the nodes that refer to the variant. So, generators can mix up the default styles and variant class-name at the same time.
Beta Was this translation helpful? Give feedback.
All reactions