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

[docs]: Fix code block dark mode #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions docs/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,28 @@
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />
<meta name="theme-color" content="#000000" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&family=Poppins:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>

<script>try{document.documentElement.setAttribute('data-theme',localStorage.getItem('theme'));}catch(e){}</script>
<script>
try {
let currentTheme = localStorage.getItem("theme");
if (currentTheme === null) {
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
currentTheme = "black";
} else {
currentTheme = "light";
}
}
document.documentElement.setAttribute("data-theme", currentTheme);

localStorage.setItem("theme", currentTheme);
} catch (e) {}
</script>
%sveltekit.head%
</head>
<body>
Expand Down
40 changes: 40 additions & 0 deletions docs/static/one-light.prism.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
* --syntax-cursor-line: hsla(230, 8%, 24%, 0.05);
*/

/* Prefer color scheme: dark */
@media (prefers-color-scheme: dark) {
pre[class*="language-"],
code[class*="language-"] {
color: hsl(219, 13.5%, 71%);
background: hsl(204.1 38.4% 10.6%);
}

code[class*="language-"]::selection,
code[class*="language-"] *::selection,
pre[class*="language-"] *::selection {
background: hsl(230 6% 32%);
color: inherit;
}

.token.punctuation {
color: hsl(219, 13.5%, 71%);
}
}

code[class*="language-"],
pre[class*="language-"] {
background: hsl(230, 1%, 98%);
Expand Down Expand Up @@ -426,3 +446,23 @@ pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection {
.prism-previewer-easing.prism-previewer-easing circle {
fill: transparent;
}

/* Manual toggle Dark mode */
html[data-theme="black"] pre[class*="language-"],
html[data-theme="black"] code[class*="language-"] {
color: hsl(219, 13.5%, 71%);
background: hsl(204.1 38.4% 10.6%);
}

/* Dark mode Selection */
html[data-theme="black"] code[class*="language-"]::selection,
html[data-theme="black"] code[class*="language-"] *::selection,
html[data-theme="black"] pre[class*="language-"] *::selection {
background: hsl(230 6% 32%);
color: inherit;
}

/* Dark mode Code blocks */
html[data-theme="black"] .token.punctuation {
color: hsl(219, 13.5%, 71%);
}
Loading