www: docs: feat: add dark mode (#2820)

- Added CSS vars for dark/light colors.
- Added dark/light theme toggle as Island

Fixes #2648

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
David Monaghan
2025-02-04 11:58:05 +01:00
committed by GitHub
co-authored by Marvin Hagemeister
parent adf8b87a03
commit b1f2a989a5
16 changed files with 320 additions and 46 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ html[data-theme="dark"] {
--docsearch-container-background: rgba(9, 10, 17, 0.8);
--docsearch-modal-background: #15172a;
--docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40,0 3px 8px 0 #000309;
--docsearch-searchbox-background: #090a11;
--docsearch-searchbox-background: #2b2d3c;
--docsearch-searchbox-focus-background: #000;
--docsearch-hit-color: #bec3c9;
--docsearch-hit-shadow: none;
+45 -14
View File
@@ -3,10 +3,12 @@
--color-prettylights-syntax-comment: #6e7781;
--color-prettylights-syntax-constant: #0550ae;
--color-prettylights-syntax-entity: #8250df;
--color-prettylights-syntax-storage-modifier-import: #24292f;
--color-prettylights-syntax-storage-modifier-import: var(
--foreground-secondary
);
--color-prettylights-syntax-entity-tag: #22863a;
--color-prettylights-syntax-keyword: #cf222e;
--color-prettylights-syntax-string: #0a3069;
--color-prettylights-syntax-string: var(--color-prettylights-syntax-constant);
--color-prettylights-syntax-variable: #953800;
--color-prettylights-syntax-string-regexp: #116329;
--color-prettylights-syntax-markup-deleted-text: #82071e;
@@ -14,16 +16,37 @@
--color-prettylights-syntax-markup-inserted-text: #116329;
--color-prettylights-syntax-markup-inserted-bg: #dafbe1;
--color-prettylights-syntax-constant-other-reference-link: #0a3069;
--color-fg-default: #24292f;
--color-fg-muted: #57606a;
--color-canvas-default: #fff;
--color-canvas-subtle: #f6f8fa;
--color-border-default: #d0d7de;
--color-border-muted: #d8dee4;
--color-fg-default: hsla(var(--foreground-secondary));
--color-fg-muted: hsla(var(--foreground-tertiary));
--color-canvas-default: hsla(var(--background-primary));
--color-canvas-subtle: hsla(var(--background-secondary));
--color-border-default: hsla(var(--foreground-secondary), 0.3);
--color-border-muted: hsla(var(--foreground-secondary), 0.1);
--color-neutral-muted: rgba(175, 184, 193, 0.2);
--color-accent-fg: #0969da;
--color-accent-emphasis: #0969da;
--color-danger-fg: #cf222e;
--warn-border: #ff9100;
--warn-bg: #f0900525;
--warn-text: var(--color-fg-default);
}
html[data-theme="dark"] {
--color-accent-fg: #3d96ff;
--color-prettylights-syntax-keyword: #ee5b65;
--color-prettylights-syntax-entity: #b291f0;
--color-prettylights-syntax-constant: #448ce5;
--color-prettylights-syntax-entity-tag: #7cb78a;
--color-prettylights-syntax-variable: #d18253;
--color-prettylights-syntax-markup-deleted-text: #ffebe9;
--color-prettylights-syntax-markup-deleted-bg: #82071e;
--color-prettylights-syntax-markup-inserted-text: #dafbe1;
--color-prettylights-syntax-markup-inserted-bg: #116329;
--warn-border: #ff9100;
--warn-bg: #f0900525;
--warn-text: var(--color-fg-default);
}
.markdown-body {
@@ -84,7 +107,7 @@
padding: 0;
}
.markdown-body blockquote {
color: var(--color-fg-muted);
color: var(--color-fg-default);
border-left: 0.25em solid var(--color-border-default);
padding: 0 1em;
}
@@ -620,8 +643,9 @@
margin-bottom: 0.25rem;
}
.markdown-body blockquote.warn {
border-color: #ff9100;
background: #f0900525;
border-color: var(--warn-border);
background: var(--warn-bg);
color: var(--warn-text);
}
.markdown-body .admonition .fenced-code {
@@ -649,12 +673,18 @@
background-color: rgb(238, 249, 253);
border-color: rgb(25 146 184);
}
.dark .markdown-body .admonition.info {
background-color: hsla(var(--info), 0.1);
color: hsla(var(--foreground-primary));
}
.markdown-body .admonition.warn .admonition-header {
color: #dd6f04;
}
.markdown-body .admonition.warn {
background-color: #f0900525;
border-color: #ff9100;
color: var(--warn-text);
background-color: var(--warn-bg);
border-color: var(--warn-border);
}
@media screen and (min-width: 768px) {
@@ -703,6 +733,7 @@ ol.nested li:before {
-moz-font-feature-settings: "kern" 1, "tnum" 1;
content: counters(item, ".") ". ";
counter-increment: item;
counter-increment: item;
}
.markdown-body ul {
@@ -747,7 +778,7 @@ ol.nested li:before {
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
padding: 0.5rem;
background: #eaeef1;
background: hsla(var(--background-tertiary));
display: flex;
align-items: center;
justify-content: space-between;
+46
View File
@@ -2,6 +2,44 @@
@tailwind components;
@tailwind utilities;
/* Light and dark theme variables */
.light {
--fresh: 50deg, 100%, 56%;
--fresh-green: 142deg, 71%, 29%;
--background-primary: 215deg, 100%, 100%;
--background-secondary: 210deg, 29%, 97%;
--background-tertiary: 207deg, 33%, 95%;
--foreground-primary: 0deg, 0%, 9%;
--foreground-secondary: 0deg, 0%, 23%;
--foreground-tertiary: 0deg, 0%, 32%;
--foreground-quaternary: 0deg, 0%, 42%;
--info: 194deg, 76%, 41%;
}
.dark {
--fresh: 50deg, 100%, 56%;
--fresh-green: 142deg, 71%, 29%;
--background-primary: 216deg, 27.8%, 7.1%;
--background-secondary: 216deg, 27.7%, 12%;
--background-tertiary: 216deg, 27.7%, 22%;
--foreground-primary: 215deg, 17%, 99%;
--foreground-secondary: 215deg, 17%, 71%;
--foreground-tertiary: 215deg, 17%, 20%;
--foreground-quaternary: 215deg, 17%, 10%;
--info: 194deg, 76%, 41%;
color: var(--foreground-primary);
background-color: var(--background-primary);
}
/* Scrollbar colors that look good on light and dark theme */
* {
scrollbar-color: hsla(0deg, 0%, 50%, 0.5) hsla(0deg, 0%, 50%, 0.1) !important;
}
@font-face {
font-family: Fixel;
font-style: normal;
@@ -58,3 +96,11 @@ h5,
h6 {
font-weight: 750;
}
hr {
@apply border-foreground-secondary/10;
}
.dark-mode-toggle-button img {
@apply fill-foreground-primary;
}