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

Styled-components: Support createGlobalStyle`` #9025

Closed
wants to merge 1 commit into from

Conversation

wmertens
Copy link

Adds support for https://styled-components.com/docs/api#createglobalstyle

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/pr-XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@SimenB
Copy link
Contributor

SimenB commented Aug 22, 2020

#5386 (comment)

@kachkaev
Copy link
Member

kachkaev commented Aug 22, 2020

A workaround we can use is:

const xyz = css`
  body {
    background: red;
  }
`;
/* ↑ gets formatted by Prettier */

createGlobalStyle`
  ${xyz}
`;

See example.

@wmertens
Copy link
Author

Note that createGlobalStyle is official API, it creates a component that you have to mount, so it won't be deprecated most likely.

@wmertens
Copy link
Author

Ah, and @SimenB - createGlobalStyle (creates component, SSR-friendly) is different from injectGlobalStyle (adds style as a side-effect on client only) which is no longer supported.

@SimenB
Copy link
Contributor

SimenB commented Aug 23, 2020

All I'm saying is that "add more template tags for auto formatting" has been rejected 4+ times before, and the specific issue I linked to was specifically asking for createGlobalStyle and was closed. I'm all for adding this (injectGlobal is still an emotion thing, I don't use styled-components), but I'm not a maintainer so that doesn't really impact anything. I'm not the person you need to convince 🙂

@sosukesuzuki
Copy link
Member

Just an idea, Prettier next(2.1) will introduce --embedded-language-formatting(#7875) new option. I think maybe we can use it to implement the formatting for createGlobalStyle in the future.

@thorn0
Copy link
Member

thorn0 commented Aug 27, 2020

Yes, this PR (as well as #5993 and #8647) is blocked by #5588. We won't move forward with it until we solve that problem.

@wmertens
Copy link
Author

👌 that looks like a nice solution! I'll close this

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

Successfully merging this pull request may close these issues.

None yet

5 participants