-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Allow multiple class names on buttons #744
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
This pull request allows the use of multiple class names when passing the `className` options to the button. The different classes should be separated by spaces.
|
Is this getting pushed? |
|
Shouldnt that be
Also, @t4t5 it would be great if we could get this feature added. It'd also be nice if we could exclude the |
krvajal
left a comment
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.
Please take a look a the suggested changes, as I am not a maintainer of the project you are not required to follow them but it will be nice to do :)
src/modules/init/buttons.ts
Outdated
| buttonEl.classList.add(name); | ||
| }); | ||
| } else if (Array.isArray(className)) { | ||
| className.forEach(name => { |
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.
Please check the length of the name here, and also DRY when adding the class names. In both cases, we get an array from the input, so you could instead do this
const classNameArray = Array.isArray(className)? className: className.split(' ')
classNameArray.forEach(name => {
buttonEl.classList.add(name);
});
Makes sense?
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.
Sure, great idea.
Do you agree with this?
const classNameArray = Array.isArray(className) ? className : className.split(' ');
classNameArray
.filter(name => name.length > 0)
.forEach(name => {
buttonEl.classList.add(name);
});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.
The first line can be split into parts for clarity if you want but yes, that's the idea.
|
@t4t5 are you considering adding this? |
|
please merge this ... we need this feature 👍 |
|
Looks great guys! Thanks for the work @krvajal @lionralfs! |
This pull request allows the use of multiple class names when passing the
classNameoptions to the button. The different classes should be separated by spaces.