You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I hope you are fine.
I have a react TS Button component. Its variant system is that it has main variants options. It gets main variant from variant prop. Each variant has its own color variants. To understand better, look at this interface, variants and color variants:
Button component props:
export interface ButtonProps<T extends keyof typeof variants> {
/** the main variant of component*/
variant?: T;
/** each main variant has some color variants and you can set the color variant of a main variant here */
colorVariant?: keyof (typeof colorVariants)[T];
/** a number that will be in use in border-radius of button */
radiusVariant?: keyof typeof radiusVariants;
fontVariant?: keyof typeof fontVariants;
/** the amount of height of button. if it is number, it will be used as `px` and if it is a sting it will be used itself */
height?: string | number;
/** the amount of width of button. if it is number, it will be used as `px` and if it is a sting it will be used itself */
width?: string | number;
/** the state of loading in button. if it is true, a loading spinner will be displayed at the center of button instead of displaying children */
isLoading?: boolean;
}
Well, base on my codes, if developer selects fill in variant prop, developer will only have primary option in colorVariant and if developer selects different colorVariant value like secondary, there will be an error for this. In other words, developer can set colorVariant option base on what is selected for variant.
Now i want to implement this functionality in storybook document. I want to display all properties of variants in variant field in document. And i want to display colorVariant options base on what option user did select in variant field in document.
I use storybook autodoc to generate document for my Button component. Here is a part of my codes for this section:
Storybook itself can't detect what i implemented for variant system and how options must be displayed. It displays just one option in select input in variant field of document and it is normal variant. It doesnt display other variants like fill and outline. And in colorVariant select field of document, there is just one option and it is primary.
So do you have any idea to do what i implemented for variant system in TS, in storybook too? thanks for your help :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello. I hope you are fine.
I have a react TS Button component. Its variant system is that it has main variants options. It gets main variant from
variant
prop. Each variant has its own color variants. To understand better, look at this interface, variants and color variants:Button component props:
Main variants data
Color variants:
It's important to see how Button component is:
Well, base on my codes, if developer selects
fill
invariant
prop, developer will only haveprimary
option incolorVariant
and if developer selects differentcolorVariant
value likesecondary
, there will be an error for this. In other words, developer can setcolorVariant
option base on what is selected forvariant
.Now i want to implement this functionality in storybook document. I want to display all properties of
variants
invariant
field in document. And i want to displaycolorVariant
options base on what option user did select invariant
field in document.I use storybook autodoc to generate document for my Button component. Here is a part of my codes for this section:
Storybook itself can't detect what i implemented for variant system and how options must be displayed. It displays just one option in select input in
variant
field of document and it isnormal
variant. It doesnt display other variants likefill
andoutline
. And incolorVariant
select field of document, there is just one option and it isprimary
.So do you have any idea to do what i implemented for variant system in TS, in storybook too? thanks for your help :)
Beta Was this translation helpful? Give feedback.
All reactions