-
-
Notifications
You must be signed in to change notification settings - Fork 551
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
Add Expressive Code to Starlight #742
Conversation
🦋 Changeset detectedLatest commit: 46103c7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 comment was marked as outdated.
This comment was marked as outdated.
This is looking super great 🎉 Amazing work! I'll play more with it later and make a more thorough review but I have a few small questions:
Again, great work! 👏 |
Thank you for the valuable feedback, @HiDeoo!
|
Wow, thanks for the quick and efficient updates and answers! Really appreciate it. |
Both correct, good observations! The slightly rounded corners could be turned off by providing a styleOverrides setting of The different syntax highlighting colors are a result of different default themes. Starlight only supported a single theme before and used custom CSS variables to make this one theme work in both dark and light mode, while Expressive Code supports freely definable separate dark and light themes and uses the GitHub dark and light themes as the default. If you have another VS code / Shiki theme in mind that you'd like to use instead of |
I have a bit more high-level question (and I am also curious ^^). With these changes, we would be shifting away from the Was any thought or experimentation done regarding using |
I'm honestly not a big fan of the CSS variables theme as it's making it impossible to ensure an accessible color contrast ratio when adding annotations to code. Expressive Code puts an emphasis on accessibility by always checking the color contrast and tweaking the syntax highlighting colors when necessary. With CSS variables, it cannot know what the actual syntax token color is going to be, so we might end up with bad accessibility. Due to this, I even intentionally disabled the CSS variables theme in Expressive Code. |
Just had a look at Shikiji, and an approach like this definitely looks more promising than the CSS variables theme to me! However, themes in Expressive Code are more than just syntax highlighting. The themes provide a full spectrum of UI colors as well, and these will be used by plugins like frames to render editor tabs, terminal windows etc., all of which Shikiji doesn't address because it seems to be focused on syntax highlighting only. I think we can (and I will) explore approaches for more efficient multi-theming for sure, but this would take a considerable amount of time and should not be done in the scope of this PR in my opinion. |
I totally agree with you regarding the The PS: Definitely outside the scope of this PR to experiment with this, I agree. |
Sure thing! I love both Orta's and Anthony's work on this and think that a Shikiji-like approach might work even for UI theming in Expressive Code. Finding a way to get efficient multi-theme output is on my roadmap as well. Thank you for all the valuable input and context! |
Ok, so I couldn't get this out of my head and experimented with CSS variable-based approaches to multi-theming inspired by Shikiji - and it seems to work! One of the next Expressive Code releases will always generate a single output per code block, no matter how many themes you define. The config- & theme-based parts of the UI (everything you can see in This migration will take me a while though, so I think it's your decision whether the current version is good enough for Starlight to integrate it now and just upgrade the dependency later when the new rendering is available, or if you'd rather want to wait for the more efficient multi-theme rendering. I know how much we are focused on performance and minimal footprint (and I care a lot about that myself), but I also know how many devs are already waiting for Expressive Code features like text markers or the copy button. 😄 Probably not easy to decide - I'm fine with both options! |
Oh boy, this is all my fault. I'm so sorry. Altho, I find it excellent news to know that the discussion could lead to some improvements in that area and that their approach could potentially work in a way more complex setup like the one from Expressive Code. 🎉 Personally, and it's only my own opinion of course, I think it would be fine to pursue with the proposed changes in this PR and later, when it's ready, upgrade the dependency. This would mean people can benefit from the amazing Expressive Code features as soon as possible. When I mentioned the double rendering, I did that asking in a question if it could be a concern because I have no idea personally so maybe some other people will have a better idea about it. |
No worries at all! It's not your fault, you just provided great input that happened to successfully nerd-snipe me! 😄 |
A few more high-level comments:
|
A bit late to the party so feel free to disregard, but when we were doing some work on other UI components the Starlight design system has a pattern of interactive components having rounded corners and non-interactive having square corners. Here's a link to the Figma file in case you wanted to take a peek: https://www.figma.com/file/GrDkcguAR7tSWPFuLVDixq/Theme---Starlight-Docs?type=design&node-id=1%3A2&mode=design&t=ypLDqrL9TDbNrovJ-1 Regardless, I'm super excited to see this and I know myself (as well as some of our readers over at Tauri) are excited for it! 🥳 |
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.
Super excited for this. Making some notes although I know @hippotastic is working on some upstream changes that will need to be integrated here before we merge this, so appreciate everyone’s patience while waiting for this amazing PR!
Co-authored-by: Sarah Rainsberger <[email protected]>
Btw, I just updated to the latest version 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.
Last two comments and then I think I’ll… merge???
Co-authored-by: Chris Swithinbank <[email protected]>
Co-authored-by: Chris Swithinbank <[email protected]>
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.
Ladies, gentlemen, hippopotamuses…
I HEREBY DECLARE THIS PULL REQUEST READY TO MERGE 📣
Thank you for the hard work @hippotastic and thanks to everyone who reviewed and gave feedback!
What kind of changes does this PR include?
Description
astro-expressive-code
into StarlightexpressiveCode
config option & schema that allows configuring the integration.expressiveCodeI18nSchema
including all translatable strings, similar to the Pagefind schema.