-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Introduce <style global>
#824
Conversation
🦋 Changeset detectedLatest commit: a1cdf73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is being automatically deployed with Vercel (learn more). astro-www – ./www🔍 Inspect: https://vercel.com/pikapkg/astro-www/DqeEiWSTzVrxa3Vzfwi9Mj4WENys astro-docs – ./docs🔍 Inspect: https://vercel.com/pikapkg/astro-docs/Fp2bdMEPAK63p8VRxtJbKKCDDktj |
c6d17c1
to
b7516fb
Compare
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.
Small punctuation change, otherwise, lgtm, =)
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 work, LGTM! Would want someone from @snowpackjs/contributors-core with more experience in our styling logic to give a review as well before merging.
Would be cool if we could get this in for v0.18.0! But can also go out immediately after if not.
Is there an associated RFC for this? I'm all for having this functionality but am curious if the idea was already discussed or not. |
Sorry! I should have included a link to the RFC (#507) |
<style global>
<style global>
docs/src/pages/guides/styling.md
Outdated
@@ -30,6 +30,32 @@ To create global styles, add a `:global()` wrapper around a selector (the same a | |||
<h1>I have both scoped and global styles</h1> | |||
``` | |||
|
|||
To include every selector in a `<style>` as global styles, use `<style global>`. It's best to avoid using this escape hatch if possible, but it can be useful when importing global styling libraries like [Tailwind](/guides/styling#tailwind) or changing theme variables. |
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.
Can you provide an example in the docs on how this helps with Tailwind? This is mentioned a couple of times but it's not clear to me on how it does, so users might also not understand, so an example would help.
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.
Yeah I think I'll actually just remove the mentions of how it helps with Tailwind. My thought was that people might want to use this to wrap around the @tailwind
setup, but that's not really the best example for when you'd want a global style block
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.
Just updated the docs to remove the Tailwind references, replaced it with a little more generic description of when you'd use it
It was discussed and accepted at a past RFC meeting |
Just one question regarding docs, code looks good to me. |
<style global>
<style global>
Looks great, merging! Thanks so much @tony-sull |
* Adding support for multiple <style> blocks * Adding support for `<style global>` * scoping @Keyframes should also be skipped for <style global> * Adding test coverage for muliple style blocks, global blocks, and scoped keyframes * docs: Updating docs for `<style global>` support * Adding yarn changeset * Punctuation fix in styling docs * docs: Clarifying example use cases given in the docs Co-authored-by: Tony Sullivan <[email protected]>
Co-authored-by: tony-sull <[email protected]> Co-authored-by: Chris Swithinbank <[email protected]>
Changes
Fixes RFC #507
<style>
blocks in an Astro component<style global>
to skip scoped styles for all selectors in the style blockTesting
Updated the
astro-css-bundling
test to cover:<style>
blocks<style global>
blocks@keyframes
in scoped and global stylesDocs
Docs site updated to note support for
<style global>
, including a couple examples and details on when to use this (and that you should probably avoid it)