3 ms·
Firstly, let me say that this looks great. I really like the classless approach. One minor question/nitpick: > To make a button primary, add the data-primary a
by lucideer 3y ago
Firstly, let me say that this looks great. I really like the classless approach. One minor question/nitpick:
> To make a button primary, add the data-primary attribute to it.
For things like this, I feel like a class would be ok while still calling the library "classless". Is there some advantage to using a data-* attribute here or is it just to retain "purity" of the classless tagline?
- Looky1173 3y agoIt's mainly the latter. I did consider just using a class, but ultimately settled on this solution. This approach might facilitate usage with additional CSS compilers/tooling.
- canadiantim 3y agoI admit I become hesitant when I see "data-*" attributes as it makes me think Javascript might be necessary to use it
- Looky1173 3y ago"data-*" attributes don't require any JavaScript; their values can even be accessed from CSS with `content: attr(data-*);`
- stronglikedan 3y agoI like the distinction. It separates effects applied by the library from affects applied by your custom class, since you can still add a class if you like. At a glance, I know where the effects are coming from.
- lucideer 3y agoThis is a good point. It also makes reasoning about classlists more clean, if all are guaranteed to be managed by your own code.
- robgibbons 3y agoThat caught my attention immediately. It just seems like a hacky, roundabout way to avoid using classes for different button styles, which to be clear, are an example of exactly why classes exist.