astroturfcss / astroturf

Better Styling through Compiling: CSS-in-JS for those that want it all.
https://astroturfcss.github.io/astroturf/
MIT License
2.28k stars 60 forks source link

decss #20

Closed ai closed 6 years ago

ai commented 6 years ago

What do you think about decss project? (syntax sugar over CSS Modules with styled-component’s like React components).

How can I combine decss and css-literar-loader?

taion commented 6 years ago

They should just work, no? In the worst case, you might need a different naming convention for things you pass through decss-loader (so you can use normal CSS-modules-style imports... I don't know if you can still import the styles object normally if you're using that loader), but otherwise there should be no conflicts?

ai commented 6 years ago

Should we add it to the docs as some sort of alternative for styled?

taion commented 6 years ago

okay, maybe i misunderstood. do you mean doing something like:

const { Button } = css`
  .Button {
    color: white;
  }

  .Button-disabled {
    opacity: 0.5;
  }
`;

Now that would be interesting. Still, I wonder if we could incorporate the decss runtime bits into styled. It seems like it could be nice if something like the below "just worked":

const Button = styled('button')`
  color: white;

  & .disabled {
    opacity: 0.5;
  }
`;
ai commented 6 years ago

I found that styled doesn't create a simple static CSS file and put styles in JS (maybe I did something wrong).

This is why I am looking for some additional solution.

taion commented 6 years ago

Wait, what do you see styled doing?

ai commented 6 years ago

Hm, maybe I had some problem because of other Babel plugins?

Does your loader generate same simple be CSS file for styled?

jquense commented 6 years ago

@ai it should yes, the loader will produce an in memory file as an optimization (that is eventually written out by webpack), and the babel plugin will/can write the extracted files to disk if you want

jquense commented 6 years ago

the way it works tho, is it removes the text inside the template literal and creates a file then replaces the tag with a require() to that file

ai commented 6 years ago

Perfect. I will mention your project in my PostCSS Way talk.

taion commented 6 years ago

Fixed in https://github.com/4Catalyzer/css-literal-loader/pull/23