-
-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds print styles for Starlight docs pages (#157)
Co-authored-by: Tony Sullivan <tony.f.sullivan@outlook.com> Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> Co-authored-by: bluwy <34116392+bluwy@users.noreply.github.com>
- Loading branch information
1 parent
f20dbd2
commit 23bf960
Showing
13 changed files
with
206 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrojs/starlight": minor | ||
--- | ||
|
||
Adds a print stylesheet to improve the appearance of Starlight docs pages when printed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
@media print { | ||
/** | ||
This is increased in specificity so it works even when injected into pages before regular styles. | ||
TODO: Just use `:root` once we move to @layer. | ||
Same goes for the use of `!important` in this file. | ||
*/ | ||
:root[data-theme]:is(:root) { | ||
/* Colours — force light mode when printing */ | ||
--sl-color-white: hsl(224, 10%, 10%); | ||
--sl-color-gray-1: hsl(224, 14%, 16%); | ||
--sl-color-gray-2: hsl(224, 10%, 23%); | ||
--sl-color-gray-3: hsl(224, 7%, 36%); | ||
--sl-color-gray-4: hsl(224, 6%, 56%); | ||
--sl-color-gray-5: hsl(224, 6%, 77%); | ||
--sl-color-gray-6: hsl(224, 20%, 94%); | ||
--sl-color-gray-7: hsl(224, 19%, 97%); | ||
--sl-color-black: hsl(0, 0%, 100%); | ||
|
||
--sl-color-orange-high: hsl(var(--sl-hue-orange), 80%, 25%); | ||
--sl-color-orange: hsl(var(--sl-hue-orange), 90%, 60%); | ||
--sl-color-orange-low: hsl(var(--sl-hue-orange), 90%, 88%); | ||
--sl-color-green-high: hsl(var(--sl-hue-green), 80%, 22%); | ||
--sl-color-green: hsl(var(--sl-hue-green), 90%, 46%); | ||
--sl-color-green-low: hsl(var(--sl-hue-green), 85%, 90%); | ||
--sl-color-blue-high: hsl(var(--sl-hue-blue), 80%, 30%); | ||
--sl-color-blue: hsl(var(--sl-hue-blue), 90%, 60%); | ||
--sl-color-blue-low: hsl(var(--sl-hue-blue), 88%, 90%); | ||
--sl-color-purple-high: hsl(var(--sl-hue-purple), 90%, 30%); | ||
--sl-color-purple: hsl(var(--sl-hue-purple), 90%, 60%); | ||
--sl-color-purple-low: hsl(var(--sl-hue-purple), 80%, 90%); | ||
--sl-color-red-high: hsl(var(--sl-hue-red), 80%, 30%); | ||
--sl-color-red: hsl(var(--sl-hue-red), 90%, 60%); | ||
--sl-color-red-low: hsl(var(--sl-hue-red), 80%, 90%); | ||
|
||
--sl-color-accent-high: hsl(234, 80%, 30%); | ||
--sl-color-accent: hsl(234, 90%, 60%); | ||
--sl-color-accent-low: hsl(234, 88%, 90%); | ||
|
||
--sl-color-text-accent: var(--sl-color-accent); | ||
--sl-color-text-invert: var(--sl-color-black); | ||
--sl-color-bg-nav: var(--sl-color-gray-7); | ||
--sl-color-bg-sidebar: var(--sl-color-bg); | ||
--sl-color-bg-inline-code: var(--sl-color-gray-6); | ||
--sl-color-bg-accent: var(--sl-color-accent); | ||
--sl-color-hairline-light: var(--sl-color-gray-6); | ||
--sl-color-hairline-shade: var(--sl-color-gray-6); | ||
|
||
--sl-color-backdrop-overlay: hsla(225, 9%, 36%, 0.66); | ||
|
||
/* Disable shadows when printing. */ | ||
--sl-shadow-sm: none; | ||
--sl-shadow-md: none; | ||
--sl-shadow-lg: none; | ||
} | ||
|
||
/* Utility classes for controlling element visibility when printing. */ | ||
.print\:hidden { | ||
display: none !important; | ||
} | ||
.print\:flex { | ||
display: flex !important; | ||
} | ||
.print\:block { | ||
display: block !important; | ||
} | ||
|
||
/* Page layout tweaks. */ | ||
main { | ||
padding-bottom: 0 !important; | ||
} | ||
main > .content-panel { | ||
padding-block-start: 0 !important; | ||
} | ||
.content-panel + .content-panel { | ||
border: 0 !important; | ||
} | ||
/* components/PageFrame.astro */ | ||
.page > header { | ||
position: relative !important; | ||
} | ||
.page > .main-frame { | ||
padding-top: 0; | ||
padding-inline-start: 0; | ||
} | ||
/* components/TwoColumnContent.astro */ | ||
.main-pane { | ||
--sl-sidebar-width: 0px !important; | ||
--sl-content-width: 100% !important; | ||
} | ||
/* components/Banner.astro */ | ||
.sl-banner { | ||
--sl-color-banner-text: var(--sl-color-white) !important; | ||
background-color: transparent !important; | ||
} | ||
|
||
/* components/MarkdownContent.astro */ | ||
.sl-markdown-content :is(h1, h2, h3, h4, h5, h6) { | ||
break-after: avoid; | ||
} | ||
.sl-markdown-content :is(p, li) { | ||
orphans: 2; | ||
widows: 2; | ||
} | ||
.sl-markdown-content pre { | ||
overflow-x: hidden !important; | ||
white-space: pre-wrap !important; | ||
} | ||
.sl-markdown-content .expressive-code, | ||
.sl-markdown-content figure, | ||
.sl-markdown-content pre { | ||
break-inside: avoid; | ||
} | ||
.expressive-code .frame.is-terminal .header::before { | ||
/* Ensure terminal frame dots are visible even if backgrounds are disabled. */ | ||
box-shadow: inset 99rem 99rem var(--sl-color-gray-5); | ||
} | ||
.expressive-code .frame.has-title:not(.is-terminal) .header { | ||
/* Divide title bar and code without relying on background colors. */ | ||
background: transparent !important; | ||
border-bottom: 1px solid var(--sl-color-gray-6) !important; | ||
} | ||
.expressive-code .frame.has-title:not(.is-terminal) .title { | ||
/* Hide title tab background color. */ | ||
background: transparent !important; | ||
} | ||
.expressive-code .frame.has-title:not(.is-terminal) .title::after { | ||
/* Remove title tab highlight. */ | ||
border-top: 0 !important; | ||
} | ||
.expressive-code .copy { | ||
/* Ensure Expressive Code copy button is hidden when printing from touch devices. */ | ||
display: none !important; | ||
} | ||
/* Inline code */ | ||
.sl-markdown-content code:not(:where(.not-content *)) { | ||
background-color: transparent !important; | ||
padding: 0 !important; | ||
margin-block: unset !important; | ||
font-size: 0.9375em !important; | ||
} | ||
|
||
/* user-components/Badge.astro */ | ||
.sl-badge { | ||
background: transparent !important; | ||
color: var(--sl-color-white) !important; | ||
} | ||
|
||
/* user-components/FileTree.astro */ | ||
starlight-file-tree { | ||
break-inside: avoid; | ||
} | ||
starlight-file-tree .highlight { | ||
outline: 3px solid var(--sl-color-accent-low); | ||
color: var(--sl-color-text) !important; | ||
background-color: transparent !important; | ||
} | ||
|
||
/* user-components/Aside.astro */ | ||
.starlight-aside { | ||
break-inside: avoid; | ||
} | ||
|
||
/* user-components/LinkButton.astro */ | ||
.sl-link-button.primary { | ||
background: transparent !important; | ||
border-color: var(--sl-color-white) !important; | ||
color: var(--sl-color-white) !important; | ||
} | ||
|
||
/* user-components/Tabs.astro */ | ||
starlight-tabs { | ||
break-inside: avoid; | ||
} | ||
|
||
/* user-components/Steps.astro */ | ||
.sl-steps > li::after { | ||
/* Ensure steps guidelines are visible when background colors are disabled. */ | ||
box-shadow: inset 99rem 99rem var(--sl-color-hairline-light); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters