RFC: Compound Props #317
Unanswered
kevinwolfcr
asked this question in
Ideas
Replies: 1 comment 1 reply
-
@kevinwolfdev thanks so much <3 I converted this from an issue to a discussion |
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
-
Is your feature request related to a problem? Please describe.
For the given
StyledText
component:Let's say that I want to change the
as
prop depending on thevariant
. Right now, I would need to wrap myStyledText
with a new component (preferably withforwardRef
) and map over the type to get the correctas
prop, as well as making some TS tricks or usingany
to avoid type errors:Describe the solution you'd like
Inspired by the
compoundVariant
API, it would be nice if a new API could exist:compoundProp
, which can take as a first argument any combination of variants and return new props that can be passed to theStyledText
:Describe alternatives you've considered
Wrapping
StyledText
with other component.Additional context
By doing this, we could map any combination of variants to any combination of props we want, the possibilities are endless.
Also, I think the change can be a seamless change according to the current implementation, because the
compoundVariant(compoundVariantsObject, compoundVariantStyles)
, could be changed to just callcompoundProp(compoundVariantsObject, { css: compoundVariantStyles })
.SandBox: https://codesandbox.io/s/gracious-heyrovsky-9pbxo?file=/src/App.tsx
Beta Was this translation helpful? Give feedback.
All reactions