-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Babel plugin #62
Babel plugin #62
Conversation
"title": "Extending styles" | ||
}, { | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier auto did this , should I revert ?
/> | ||
</DocsLayout> | ||
) | ||
<NextPage href="/docs/api" title="API Reference" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! I might add prettier soon anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome ! I can do that if you want 👍
This is looking good! 🎉 I'm thinking, maybe we should move the section to API. What do you think, @mxstbr? |
@philpl I was on the fence between advanced and API so input would be great |
Awesomeee!! Hmm, I quite like it under Advanced but maybe we should just have another section "Tooling" or something that also includes some docs for |
@mxstbr Then let's put it into the "Advanced" section until we have enough content to create one for "Tooling"? |
SGTM |
Thanks @SaraVieira for your contribution. 👏 @mxstbr @philpl A "tooling" section sounds great, and I'll be happy to add more information about testing. Should I open an issue? Also, I'm glad to see the snapshots are working on this PR :) |
@MicheleBertoli I still have to add a An issue would be greatly appreciated :) |
@philpl @mxstbr @MicheleBertoli Should we leave it like this or create the tooling section already ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor changes that we'll need to do. Most of the mistakes come from the original readme, but need to be fixed before they just go into the website as well 😉
components/advanced/babel-plugin.js
Outdated
styles and gives you a nicer debugging experience when using{' '} | ||
<Code>styled-components</Code>. | ||
</p> | ||
<p>Usage</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This subsection can use the SectionLayout
component with the sub
prop, like the ones below.
Also, this is missing a small explanation, like:
Install the babel-plugin first:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🌮
components/advanced/babel-plugin.js
Outdated
<p> | ||
This plugin adds support for server-side rendering, for minification of | ||
styles and gives you a nicer debugging experience when using{' '} | ||
<Code>styled-components</Code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave out "when using styled-components" as that's quite obvious on the site. But we should add a paragraph that it's only for the web, not for React Native
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🎉
components/advanced/babel-plugin.js
Outdated
<p>Usage</p> | ||
<CodeBlock code={installNPM} language="node" /> | ||
<p> | ||
Then in your babel configuration (probably <Code>.babelrc</Code>): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds a bit odd. Maybe something like:
Then add it to your babel configuration ([...]) like so:
would make it nicer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed 👍
components/advanced/babel-plugin.js
Outdated
By adding a unique identifier to every styled component this plugin | ||
avoids checksum mismatches due to different class generation on the | ||
client and on the server. If you do not use this plugin and try to | ||
server-side render <Code>styled-components</Code> React will complain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Code>styled-components</Code>
needs to be changed to just styled components
. We're not talking about the lib 😄
If you do not use this plugin and try to server-side render styled-components React will complain.
This is a bit outdated and also sounds weird, so let's update it:
If you do not use this plugin and try to server-side render, you will likely encounter React warnings, if the import order is different on the client. For this reason we generally recommend you to turn on this option in any SSR setup.
We also need to add a reference to this babel-plugin option to our SSR section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to add a reference to this babel-plugin option to our SSR section. -> What can I do here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this, if it's unclear. In the SSR section on the website, it'd just be useful to say "You will probably need to use our babel plugin's ssr
option to not run into checksum mismatches with server-side rendering."
components/advanced/babel-plugin.js
Outdated
server-side render <Code>styled-components</Code> React will complain. | ||
</p> | ||
<p> | ||
If you want server-side rendering support you can enable it with the{' '} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can cut this short due to the prior intro:
If you want server-side rendering supportYou can enable it with the ssr option:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🎉
components/advanced/babel-plugin.js
Outdated
</p> | ||
<CodeBlock code={preprocess} language="node" /> | ||
</SectionLayout> | ||
<SectionLayout sub title="Preprocessing"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect title 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn , fixed :p
components/advanced/babel-plugin.js
Outdated
</SectionLayout> | ||
<SectionLayout sub title="Preprocessing"> | ||
<Note> | ||
This option is turned on by default! If you experience mangled CSS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can lose the exclamation mark here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 😄
components/advanced/babel-plugin.js
Outdated
</Note> | ||
<p> | ||
This plugin minifies your styles in the tagged template literals, giving | ||
you big bundle size savings. (note that you will not see the effect of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can lose the parantheses here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 💃
components/advanced/babel-plugin.js
Outdated
</p> | ||
<CodeBlock code={minify} language="node" /> | ||
<p> | ||
We also transpile <Code>styled-components</Code> tagged template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go into a new section, since it's a separate option actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should go in this section ? Just this paragraph ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this entire part about the template string transpilation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/advanced/babel-plugin.js
Outdated
literals down to a smaller representation than what Babel normally does, | ||
because <Code>styled-components</Code> template literals don't need to | ||
be 100% spec compliant. see{' '} | ||
<a href="https://github.com/styled-components/babel-plugin-styled-components/blob/master/minification.md"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link here can be swapped out for a link to our "Tagged Template Literals" section.
Also there's a trailing closed parenthesis below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link swapped :)
@philpl Made some of the changes |
@SaraVieira Thanks a lot again already! This is already so close to be shippable in such a short time 😄 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last problem :)
components/advanced/babel-plugin.js
Outdated
literals down to a smaller representation than what Babel normally does, | ||
because <Code>styled-components</Code> template literals don't need to | ||
be 100% spec compliant. see{' '} | ||
<a href="#tagged-template-literals">Tagged Template Literals</a> for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link will need to be swapped out with our Link component 😉 You can see some examples for this on other pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed @philpl 🎉
components/advanced/babel-plugin.js
Outdated
@@ -163,7 +164,7 @@ const BabelPlugin = () => | |||
literals down to a smaller representation than what Babel normally does, | |||
because <Code>styled-components</Code> template literals don't need to | |||
be 100% spec compliant. see{' '} | |||
<a href="#tagged-template-literals">Tagged Template Literals</a> for | |||
<Link href="#tagged-template-literals">Tagged Template Literals</Link> for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not being clear enough on this :( You'll have to pass the inline
prop for it to show up with the correct styling: https://github.com/styled-components/styled-components-website/blob/master/components/api/helpers/with-theme.js#L52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it ! It does look better now :p
@SaraVieira Thanks a lot for putting in such an effort to finally bring this section to our site 🎉 😄 I'll try to find a workaround for the SSR problem and then deploy a new version |
@philpl No problem man , I'm now working on adding eslint 😄 |
Yay this is awesome, thanks so much for the help @SaraVieira! |
@SaraVieira @mxstbr Should be deployed and the SSR bug should also be fixed (vendored a modified next.js version f9a9320) @mxstbr can you clear the cache so we get the website to be quick again asap please? :) |
Closes #13 and creates a section in advanced with the babel plugin docs