Skip to content

Support undefined props and private variants applied last #9

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

Merged
merged 3 commits into from
Nov 14, 2022

Conversation

cr0cK
Copy link
Member

@cr0cK cr0cK commented Nov 10, 2022

Description of the Change

  • Prop values passed to variant(s) and compoundVariant(s) are now optional.
    It allows to not apply default styles or having to create "empty variant" for default cases.

  • Private variants (prop starting by _) now overrides composed variants got from an existing variant declaration.

    For example, let's consider a Button on which the "primary" variant define a white color, if a private variant is defining a different color, it's possible to override the primary color like this:

<Button variant="primary" _color="red" />

Benefits

Possible Drawbacks

Testing Instructions

Checklist

  • Tests added

Previously, as the props value was required, the (compound)variant(s)
matching the default value were applyed.

If no style was expected, a "default" variant with an empty declaration
was required.

Now, you only need to define props as optional and if no fallback is
passed, no style will be applyed.
@cr0cK cr0cK force-pushed the feature/experiments-undefined-props branch from 157c32b to ba24e7c Compare November 10, 2022 20:11
Having private properties applied last allows to use public variants and
override a few props by using an extra private variant.
@cr0cK cr0cK force-pushed the feature/experiments-undefined-props branch from ba24e7c to 578768c Compare November 14, 2022 11:56
@cr0cK cr0cK merged commit ed49500 into main Nov 14, 2022
@cr0cK cr0cK deleted the feature/experiments-undefined-props branch November 14, 2022 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant