How to define cssVar in Recipes ? #1147
-
Please Delete This Post!Orignal Version:export const buttonIconStyle = cva({
base: {
......
},
variants: {
size: {
small: {
iconSpacing: 'xs', // 4px
},
medium: {
iconSpacing: 'sNudge', // 6px
},
large: {
iconSpacing: 'sNudge', // 6px
},
},
iconPosition: {
before: {
marginRight: , 'sNudge'// Bad, fixed at 6px
},
after: {
marginLeft: , 'sNudge' // Bad, fixed at 6px
},
},
},
defaultVariants: {
size: "medium",
},
}); Orignal :
But I want “marginRight” to change with “size” :
Changed Version:const iconSpacingVar = "--pui-btn__icon-spacing"; // This cssVar will be changed with "size".
export const buttonIconStyle = cva({
base: {
......
},
variants: {
size: {
small: {
`${iconSpacingVar}`: 'xs', // error 1, red wave
},
medium: {
`${iconSpacingVar}`: 'sNudge', // error 2, red wave
},
large: {
`${iconSpacingVar}`: 'sNudge', // error 3, red wave
},
},
iconPosition: {
before: {
marginRight: iconSpacingVar, // no red wave
},
after: {
marginLeft: iconSpacingVar, // no red wave
},
},
},
defaultVariants: {
size: "medium",
},
}); Question 1, how do I modify error 1,2,3? Bad try Version, Every "size" was repeated.variants: {
size: {
smallBefore: {
marginRight: 'xs', // 4px
},
smallAfter: {
marginLeft: 'xs', // 4px
},
mediumBefore: {
marginRight: 'sNudge', // 6px
},
mediumAfter: {
marginLeft: 'sNudge', // 6px
},
largeBefore: {
marginRight: 'sNudge', // 6px
},
largeAfter: {
marginRight: 'sNudge', // 6px
},
},
}, |
Beta Was this translation helpful? Give feedback.
Answered by
hilodfulaidien
Aug 3, 2023
Replies: 2 comments
-
@hilodfulaidien Could you explain what exactly the issue is. This is quite vague |
Beta Was this translation helpful? Give feedback.
0 replies
-
The problem has been solved by using "compound variants". |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hilodfulaidien
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem has been solved by using "compound variants".