Closed rtvenge closed 3 years ago
@rtvenge Very excited to see you in these parts! I think the !important
s are still necessary, unfortunately, but it's worth having to justify them!
This post summarizes the thinking.
The key reason is that these styles need to work with any theme and likely should override selectors of higher importance.
To use the no-bullets example, here's the CSS from the plugin without !important
:
.is-style-useful-no-markers,
.is-style-useful-no-markers li {
padding-left: 0;
list-style: none;
}
That would "lose" out to even a very responsible theme selector like this, regardless of the source order of stylesheets:
.entry-content ul li {
list-style: square;
}
So my thinking is that:
!important
to always override default theme styles because block styles are essentially utility classes that you always do exactly what you want them to when selected.What do you think?
@mrwweb that's a very good point.
I think if we are applying styles that we are 95% sure they wouldn't need to be overridden, then we are good. And you get that protection you mentioned above from resets and other theme styles.
I also like the idea that, worst case, the theme author can use a more specific selector with an !important
in that 5% chance they need to override.
Some thoughts for moving forward:
dep
in the enqueue seeing as these styles do technically depend on the base block styles?!important
so others can see that right away? Maybe just a link to this PR? 😄 This discussion is so great and why I wanted eyes on the plugin!
@mrwweb
I updated the code accordingly.
I also just noticed you use the same technique I do for caching enqueues. 😄
Thanks for doing that research, @rtvenge. This looks great (and I dealt with the merge conflict 😃).
I love busting cache this way! I think I first saw it on wp-rig well after you were doing it. FYI: Your code snippets have an alignment bug on your blog. Hopefully that's not a problem caused by wp-block-library
🤣
@mrwweb would this work instead for the styles? I would see that the dev might want to slightly override your styles on the front end, and battling
!important
's would make that difficult. I think using thedep
in the enqueue will accomplish the same thing, right?