Orthogonality and CSS in JS
benmccormick.org
benmccormick.org
It's used for style & design, but also for functionality. In some ways, ideally, function related CSS would be stored with the module, but site-level design CSS would be separate.
Additionally, CSS by design has greedy selectors. If I put in a:
a { text-decoration: none; border-bottom: 1px solid pink;}
in my site.css, it will muck up any components which use an <a> tag, but don't specifically re-write the border.Are there good solutions to this?
I kind of feel in some ways, with SPAs and web apps being a thing rather than simple pages, we need a new way of defining styling, which then compiles to CSS, figuring out the correct over-rides along the way.
So true.
I once searched days for a broken event handler in JavaScript, just to find out that somewhere deep inside a CSS file, someone disabled events for the element.
Didn't even know CSS had that power.
You can layer elements how you like and then, in the end, disable all the elements "in the front" of the element that you want to have "clickable".
I never heard of that. I just looked up CSS pointer-events [0], is that what you're referring to or are there others?
Attribute selectors are indeed handy and are on par with class names in my suggestion.
The question should be "How do we define module interfaces?"
Take Bootstrap as practical example.
How does it "interface" with your code?
CSS classes of course!
But wait!
If you use its "components" it also interfaces via HTML elements.
If you use even more of it, it also interfaces via JavaScript.
But even if you just use their CSS, how to switch to BlazeCSS, for example?
Well, you kick out Bootstrap, include BlazeCSS and ... you replace the CSS classes in your HTML elements, done...almost, sometimes you even have to fix up the HTML.
Hopefully this gets better with Web Components.
The problem we have right now is that CSS stuff is top down, while it still requires heavy customization from the bottom up (some styling only work for specific element types, etc.)
With Web Components, we can have custom elements "at the bottom" which are transparent in their child element usage, and can let CSS frameworks target them from the top. V1 uses ul/li for tabs, V2 uses divs all the way, but the users just includes the css/js and the used tag <fw-tabs> stays the same.
maybe there should be a file editor that's feature aware but also separates those file for you.