-
-
Notifications
You must be signed in to change notification settings - Fork 534
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
Cascade Layers #2322
base: main
Are you sure you want to change the base?
Cascade Layers #2322
Conversation
|
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Copying @mayank99 in on this PR! Will try to take a look soon. |
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.
Excited to see this!
I'll try to take a deeper look when I have some time. For now I've just left one question.
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.
Where is this file used? It is very important that this comes before any other starlight stylesheets.
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.
Currently, this is used in the <Page>
component before any other Starlight styles, altho this can still be overridden by a user through the virtual:starlight/user-css
import.
Excited to see interest in this, the draft may a bit rough at this point but I'll continue iterating on it and it should be a good starting point for discussion.
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 I've found is that order of imports is not a reliable way to ensure order of styles. I've run into many instances where Vite/Astro jumbles up the CSS order.
Should we move this layer statement into a <style>
tag in the <head>
? Ideally this would be placed after the user's own <head>
content, but before all the bundled stylesheets.
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 is something I'll need to investigate as this is not something I've encountered so far in this first iteration. The suggested approach could also decrease the DX for user customization. Adding that point to my todo list of things to investigate and I'll get back with my findings.
Description
This PR is a WIP that refactors all Starlight CSS to use cascade layers.
At the moment, Starlight will internally uses the following nested layers:
starlight.base
starlight.reset
starlight.shiki
starlight.components
starlight.content
starlight.user-components
starlight.asides
starlight.expressive-code
starlight.utils
This slightly reduces browser support by 0.3% (
Chrome >= 88
→Chrome >= 99
).Testing
As I quickly realized that manually inspecting would not be practical for this PR to ensure there are no regressions, I created a new temporary package to help test the changes (
packages/local-prod-visual-diff
) that can be run usingpnpm test
from that directory.For a list of routes, the tool will:
This has been very helpful to spot some tiny issues during the refactor, e.g. the following diff image that shows a tiny difference in the header
<Select>
component icons:Another one showing an issue with the content of the last step in a set of
<Steps>
:Of course, this is only a bonus and this PR would still be a good Talking & Doc'ing candidate with many different eyes/browsers.
Remaining tasks
TODO(HiDeoo)
comment in thedocs/astro.config.mjs
filepackages/local-prod-visual-diff
packagedata-astro-cid-*
attributes. Not sure yet if this PR is the right place to do that.