-
Notifications
You must be signed in to change notification settings - Fork 1
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
Normalize variant given to config #258
Labels
feature
New feature to be implemented
Comments
LeBenLeBen
added a commit
that referenced
this issue
Nov 20, 2022
…fig class, close #258 BREAKING CHANGE: The `variant` prop of all components must be a string, array is not supported anymore. This same `variant` value is now splitted by spaces and transformed into an object of type `{ [variant]: boolean }` before being passed to the component config `class` method. See « Styling components » guide for updated usage.
LeBenLeBen
added a commit
that referenced
this issue
Nov 20, 2022
…fig class, close #258 BREAKING CHANGE: The `variant` prop of all components must be a string, array is not supported anymore. This same `variant` value is now splitted by spaces and transformed into an object of type `{ [variant]: boolean }` before being passed to the component config `class` method. See « Styling components » guide for updated usage.
LeBenLeBen
added a commit
that referenced
this issue
Nov 21, 2022
…fig class, close #258 BREAKING CHANGE: The `variant` prop of all components must be a string, array is not supported anymore. This same `variant` value is now splitted by spaces and transformed into an object of type `{ [variant]: boolean }` before being passed to the component config `class` method. See « Styling components » guide for updated usage.
LeBenLeBen
added a commit
that referenced
this issue
Nov 27, 2022
…fig class, close #258 BREAKING CHANGE: The `variant` prop value of all components is now normalized into an object of type `{ [variant]: boolean }` before being given to the component config `class` method. See « Styling components » guide for updated usage.
LeBenLeBen
added a commit
that referenced
this issue
Nov 27, 2022
…fig class, close #258 BREAKING CHANGE: The `variant` prop value of all components is now normalized into an object of type `{ [variant]: boolean }` before being given to the component config `class` method. See « Styling components » guide for updated usage.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the variant prop is provided to the config
class
property as is, without any transformation. It means it can be an array or a string or whatever the user want it to be. I’m not sure this flexibility provides any added value. I personally like the simplicity of strings, but when you want to combine variants, it forces to end up with “complicated” tests to apply classes conditionally.I usually use
String.prototype.includes
to test if a variant is present, but it’s fragile:variant?.includes('something')
, which I forget to add by default too oftensomething
, not onlypurple
but alsorebeccapurple
for example. A behavior that is undesired most of the time if you split multiple variants with a space like I doI feel like we should normalize this prop to always be a string and make it behave similarly to how the native
class
works: split by spaces and provide an API to access every property in a simple way. A Proxy could be great solution to returnfalse
by default andtrue
when a variant is present; avoiding the necessity for conditional checks while keeping the syntax very short.The text was updated successfully, but these errors were encountered: