-
-
Notifications
You must be signed in to change notification settings - Fork 364
[Twig] Resolving boolean as variant keys #1710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test that proves "false"
works as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect 👀
dcd5ec3
to
12e0a4c
Compare
Thank you Simon. |
Did you test for Like: {% set button = cva({
base: 'button',
variants: {
color: {
blue: 'btn-blue',
green: 'btn-red',
},
disabled: {
true: 'disabled',
}
},
compoundVariants: [
// Applied via:
// `button({ color: 'blue', disabled: true })`
{
color: 'blue',
disabled: 'true', // <-- This one
class: 'btn-outline-secondary',
},
],
defaultVariants: {
disabled: 'false', // <-- This one
}
}) %} |
This PR was merged into the 2.x branch. Discussion ---------- [Twig] add additional CVA boolean tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | Fix #1710 (comment) | License | MIT Some additional tests for using booleans with compounds and defaultVariables. Commits ------- 8a49bc9 [Twig] add additional CVA boolean tests
After some "back and forth", we agreed on the following behaviour. I hope this will match your needs :)
This PR allows users to pass real boolean when calling the component, to match string-boolean defined in the CVA definition.
Based on the work of @kbond in #1647 to fix #1614
Then the 3 following calls should be equivalent