Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically include "extended" CSS #2

Open
tizmagik opened this issue Jul 27, 2016 · 1 comment
Open

Automatically include "extended" CSS #2

tizmagik opened this issue Jul 27, 2016 · 1 comment

Comments

@tizmagik
Copy link
Owner

Currently, only the first-level CSS is included/injected by react-csjs out of the box. It would be nice to also include all of the "extended" styles as well.

See rtsao/csjs#51 for more details.

@tizmagik
Copy link
Owner Author

As a workaround for now, instead of doing this:

const labelBase = csjs`
  .boldBase {
    font-weight: bold;
  }
`;

const styles = csjs`
  .label extends ${labelBase.boldBase} {
    color: blue;
  }
`;

You can do this:

const labelBase = `
    font-weight: bold;
`;

const styles = csjs`
  .label {
    ${labelBase}
    color: blue;
  }
`;

Notice labelBase does not need to be run through the csjs function since it's just strings.

You can also take it a step further and provide "mixin-like" functional bases, e.g.

import {darken} from 'color'; // some color lib

const styles = csjs`
  .label {
    ${labelBase}
    color: ${darken('blue', 20)}
  }
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant