Yahoo reinvented inline styles through classes
imgur.com
imgur.com
All in all this has some interesting performance benefits.
It may look insane, but as long as you don't have to manually make and use these atomic classes this is not such a bad idea.
I think the things such as atomic CSS, CSS-in-JS, CSS Modules, styled-components, inline styles, etc. are all symptoms of something being seriously wrong with CSS and at the same time attempts to fix these problems. They are pushing in the positive direction.
I recommend checking out [2] if somebody is interested in these topics. That's where I found out about Styletron.
Cheers.
[0] https://github.com/rtsao/styletron [1] https://ryantsao.com/blog/virtual-css-with-styletron [2] https://medium.com/seek-blog/a-unified-styling-language-d0c2...
If I were to design a better styling model, I'd take that desktop-publishing model and added multiple inheritance (something you can model in XSL-FO with XSLT attribute templates) and maybe tried to have pattern-based rules, but not hierarchical as in CSS. What you normally need is to be able to specify that "add that much space between a table and a paragraph", "remove first line indent if the paragraph comes after a picture", "do not add space if the paragraph is at the top of the page", and so on. All this seems to be based on a particular arrangement of sibling elements, not of parent-child relationship. The only exception I can think of are tables, but they seem to be special anyway.
It's funny how they say "The lower specificity of classes also allows for easier overrides" -- that's true, but what on earth would I want to override a class called "P(20px)" to do instead? :)
... or at least, that was the argument. In practice, most teams didn't adopt it unless mandated from above; because it sucks to use, has an infinitesimal decrease in individual page load time, and the bandwidth savings certainly don't outweigh the lost developer time.
But hey, all you gotta do is convince some VP that your niche approach is the right one, and you'll get some adoption in a large company like Yahoo.
If you believe the size argument, and care more about short term revenue over developer productivity or happiness, it makes sense, I guess.
[1] https://acss.io/frequently-asked-questions.html#what-are-the...
Too many engineers and not enough actual problems.
*[style*="text-align:justify"]{
text-align: left !important;
}lol maybe you might want to express the sizes in another base /s
.P(20px) {
font-size: 10px; // 20px in base 5 is 10px in base 10
}Admittedly, I have no idea how well this performs with code splitting though. I like the fact that with code splitting, each page will just load the assets that it needs for that page to render and function.
Atomics offers single level specificity thus providing a strategy to combat the specificity problem that plagues many projects.
They are single purpose and infinitely composable, which complements very well with component oriented architecture that's popular today.
They are localized to single DOM node. When combined with its single purpose nature offers fewer surprises when making changes to your style sheet. For example, when you add a margin 15 Atomics to a DOM node, it is very hard to accidentally add another margin 15 somewhere else. Versus if you add a label class, it is much easier to accidentally add another label class and cause unintended consequences.
I know it isn't the easiest to read and it seems counterintuitive at first, but in practice you can easily encapsulate long chains of inline classes into helper classes thus giving most projects a sort of sane middle ground.
[1] http://thedailywtf.com/articles/The_Inner-Platform_Effect
All of this is using a system that was effectively designed to share and display research papers 20 years ago.
Then you add the competition to _up_ everyone else. Sure you don't have to be the best, but you need to have flare.
Citing their website:
Most approaches to styling inside components rely on inline styles, which are limiting. Atomic CSS, like inline styles, offers single-purpose units of style, but applied via classes. This allows for the use of handy things such as media queries, contextual styling and pseudo-classes. The lower specificity of classes also allows for easier overrides. And the short, predictable classnames are highly reusable and compress well.