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

Fixes code example colour contrast #2708

Merged
merged 4 commits into from
Jan 10, 2025
Merged

Fixes code example colour contrast #2708

merged 4 commits into from
Jan 10, 2025

Conversation

delucis
Copy link
Member

@delucis delucis commented Dec 16, 2024

Description

  • Addresses a colour contrast issue reported in Accessibility audit with several findings (serious and best practise) #2693
  • Expressive Code performs colour contrast correction automatically, but we had misconfigured a background colour setting, so Starlight’s default theme was not being properly taken into account in these calculations.
  • This PR fixes that and ensures code blocks have sufficient text contrast.
  • Shout out to @hippotastic for helping with the solution.

Copy link

changeset-bot bot commented Dec 16, 2024

🦋 Changeset detected

Latest commit: b322788

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

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

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Dec 16, 2024
Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit b322788
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/6781912c08fa700009ce1acb
😎 Deploy Preview https://deploy-preview-2708--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@astrobot-houston
Copy link
Collaborator

astrobot-houston commented Dec 16, 2024

size-limit report 📦

Path Size
/index.html 6.89 KB (0%)
/_astro/*.js 21.19 KB (0%)
/_astro/*.css 13.76 KB (+0.07% 🔺)

@hippotastic
Copy link
Contributor

hippotastic commented Dec 16, 2024

Just a heads up: The code block styles on this page seem to be broken for me on iOS Safari in the deploy preview, not sure why that is the case:

https://deploy-preview-2708--astro-starlight.netlify.app/environmental-impact/#caching

The live site looks good. I can't imagine this one-line change causing this, so there might be something else going on.

(Edit: The preview now also works after doing a rebuild with a cleared cache. Apparently this was a content collections caching issue unrelated to this particular change or EC. I'd be happy to let Astro know about any config changes requiring cache invalidation if an API is made available.)

@delucis
Copy link
Member Author

delucis commented Dec 16, 2024

Just a heads up: The code block styles on this page seem to be broken for me on iOS Safari in the deploy preview, not sure why that is the case:

deploy-preview-2708--astro-starlight.netlify.app/environmental-impact#caching

Oh that’s very odd… and I can reproduce the exact same behaviour in the dev server too. It appears that the Expressive Code styles are not loaded at all on that page:

Terminal logging showing a 404 request for an Expressive Code CSS file

@delucis
Copy link
Member Author

delucis commented Dec 16, 2024

Figured out this was a caching issue due to how the Astro 5 content collection implementation caches Markdown across builds. Rebuilding on Netlify with a clear cache fixed it.

This does make this change a bit riskier than it appears. Users might need to astro sync --force or manually remove the cache (e.g. via UI in deployment environments) to avoid issues when upgrading.

@delucis
Copy link
Member Author

delucis commented Dec 19, 2024

Would have loved to release this as a patch, but I think it will be safer in our next minor. At that time we can bump the astro peer dependency to 5.1.0 to include withastro/astro#12767 which should help a bit with CC caching issues (plus forcing an Astro version bump will ensure the cache is flushed).

@delucis delucis added the 🌟 minor Change that triggers a minor release label Dec 19, 2024
@delucis delucis added this to the v0.31 milestone Jan 9, 2025
Copy link
Contributor

@hippotastic hippotastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I checked the contrast in various pages, including tricky areas like marked lines including comments that had issues in the live site, and now the contrast levels are accessible everywhere.

@delucis delucis merged commit 442c819 into main Jan 10, 2025
15 checks passed
@delucis delucis deleted the chris/ec-contrast branch January 10, 2025 21:34
@astrobot-houston astrobot-houston mentioned this pull request Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package 🌟 minor Change that triggers a minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants