Add an option to output atomic css
See original GitHub issueDo you want to request a feature or report a bug? Feature
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install
and yarn test
.
What is the expected behavior? The current behavior is
// Input
const header = css`
text-transform: uppercase;
font-family: ${fonts.heading};
font-size: ${modularScale(2)};
`;
// Current Output
const header = 'header_t1ugh8t9';
// Expected Output
const header = 'tt_swer3 ff_Sers34 fs_5tsdf';
/*
tt_swer3 -> text-transform
ff_Sers34 -> font-family
fs_5tsdf -> font-size
*/
Please provide your exact Babel configuration and mention your Linaria, Node, Yarn/npm version and operating system.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:24
- Comments:30 (15 by maintainers)
Top Results From Across the Web
Let's Define Exactly What Atomic CSS is
This technique is a way to allow utility classes to override styles at different breakpoints to make implementation of responsive web design ...
Read more >Atomic CSS - Compiled CSS in JS
Atomic CSS. Compiled outputs your styles as atomic CSS. This page goes over what it is and what behaviors are enabled by using...
Read more >Frequently Asked Questions - Atomic CSS
Atomic CSS is a collection of single purpose styling units (single responsibility principle for maximum reuse) that fits well with components in templated ......
Read more >How to write Atomic (design) CSS with Sass in Angular2
ts and then @import all your other scss files into this one. Make sure to remove the styles property from all of your...
Read more >How to Dynamically Layout a Block using Atomic CSS Classes
Element uses Atomic CSS, a layout-focused CSS library that is designed for optimum performance on VOLT storefronts. When building a custom Block with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a really interesting discussion – I’ve done a bit of a prototyping into what would be required for supporting this in Linaria – it’d be a fairly different implementation, but we could keep a similar API shape (not too dissimilar from css-zero ). At a high level, what I’d suggest would be something like this in React:
which would produce:
To get there we’d need:
@linaria/atomic
package, that contains the new API (note: we’d probably also want new stylelint rules to enforce the fact that nesting / cascading isn’t allowed in atomic css)collect
utility from@linaria/server
to support sorting / deduping these atomic rules (I think prefixing them with a consistent prefix, eg.atm_
could help here)For @jayu 's point about deduping the produced rules, I think we dedupe rules at a file level, and rely on the bundler to dedupe those as well in produced css files (so, add webpack support, or similar).
For us, the big advantage of doing this is that the atomic rules don’t depend on declaration order – we can determine which atomic rules to apply at build time. Additionally, the total css size can be reduced.
It’d be a fairly big new addition to the library though – @jayu, if I created a proof of concept along the lines of the above, would you be open to discussing the potential inclusion? I think it’ll end up being a bunch of new work though so it’d be great to hear what your thoughts are for the direction on this going forward.
I would have loved to see this coming though! So sad to see it has been closed! This is the approach taken by the new Facebook style lib, which would be open source at some point. But I think, considering it seems that lib is quite opinionated in the way to write CSS (ReactNative style), it would be good to see this in Linaria as an opt-in feature.
If I have some time, does anyone mind me spiking it?