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

feat: Adds print styles for Starlight docs pages #157

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

tony-sull
Copy link

What kind of changes does this PR include?

  • Changes to Starlight code
  • Something else!

Description

  • Adds print-specific styles for pages built with Starlight
  • Hides navigation elements like the sidebars, search, and mobile menu
  • Forces the light theme color palette when printing

@changeset-bot
Copy link

changeset-bot bot commented Jun 5, 2023

🦋 Changeset detected

Latest commit: 20cf394

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 Minor

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

@netlify
Copy link

netlify bot commented Jun 5, 2023

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 20cf394
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/6761c124bc992d0008d2227d
😎 Deploy Preview https://deploy-preview-157--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 Jun 5, 2023

size-limit report 📦

Path Size
/index.html 6.96 KB (+0.54% 🔺)
/_astro/*.js 21.19 KB (0%)
/_astro/*.css 13.75 KB (0%)

@delucis delucis added the 🌟 minor Change that triggers a minor release label Jun 8, 2023
@tony-sull tony-sull force-pushed the feat/print-stylesheet branch from 2289ff4 to f455c1c Compare June 9, 2023 14:59
@tony-sull tony-sull marked this pull request as ready for review June 9, 2023 15:13
@tony-sull tony-sull requested a review from delucis June 9, 2023 15:13
@tony-sull tony-sull force-pushed the feat/print-stylesheet branch from 57d6c69 to 819ea02 Compare June 19, 2023 15:56
@tony-sull
Copy link
Author

@delucis thoughts on whether this feature is worth merging or should I close it?

I'm still a bit torn on the increase in bundled CSS versus pulling all print styles out to a global print.css file. We could definitely move the styles out of layouts/components to avoid the bundle size increase, as long as the core layout doesn't change too much it really shouldn't be too risky since the changes are largely just hiding navigation elements.

@delucis
Copy link
Member

delucis commented Jun 19, 2023

I think my preference is likely for pulling this out to a separate global file to avoid extra downloads. (We’d need a ?url import I’d guess to pass that to the appropriately configured style tag.)

I am a bit torn because as you highlighted, that does come with extra maintenance complexity. Especially as this is exactly the kind of thing we’re likely to forget to check as we add stuff 😅 That said, most stuff is done pretty safely via print:hidden, so we should be OK with that approach?

(There’s a chance even doing that will fail the CI check here — it’s a bit of a rough tool at the moment, just globbing dist/*.css and measuring that gzipped, so even CSS that doesn’t actually get loaded is liable to get taken into account. Tried another approach and found it unreliable, but this is definitely on a list of tooling to improve.)

Let me know if you’re happy doing that or if you’d prefer me to tackle!

@delucis delucis added the 🌟 core Changes to Starlight’s main package label Jun 20, 2023
@tony-sull
Copy link
Author

@delucis Yep that's no problem, I'll refactor that this morning and pull the styles out into a global sheet 👍

@tony-sull
Copy link
Author

@delucis done! Everything is moved out to the separate print.css file

Looks like the HTML size-limit is failing by ~1kb, that should just be from the extra print: class names + the stylesheet <link>

@tony-sull
Copy link
Author

Best laid plans! It turns out there isn't currently a great way to get around the CSS being inlined there, I'm going to close this out for now as blocked.

@delucis, @bluwy, and I were catching up on Discord and it sounds like this may be worthy of a feature in Vite to be able to ?url import and make sure it's never inlined. My vote is still on ?no-really-i-want-a-url, but I'll leave that up to the Vite team to decide 😄

@delucis
Copy link
Member

delucis commented Dec 16, 2024

Will need to wait on withastro/astro#12758 to use the ?url&no-inline import query without type errors.

@github-actions github-actions bot added the 📚 docs Documentation website changes label Dec 17, 2024
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 📚 docs Documentation website changes 🌟 minor Change that triggers a minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants