diff options
| author | Kian Kasad <kian@kasad.com> | 2021-03-19 06:12:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-19 18:42:49 +0530 |
| commit | e01b52193a9db952286ccf03b91d3f43f5312fed (patch) | |
| tree | fc006fb228ce99061b20798b1940828d0bf99475 | |
| parent | 706b5a1c949a8745ba7669cb2591083d771dbe46 (diff) | |
Use CSS inside noscript when JS is disabled to detect preferred color theme (#308)
- Makes auto theme work when JS is disabled
- Only applies if the 'theme' configuration parameter is set to 'auto' or is unset.
| -rw-r--r-- | layouts/partials/header.html | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 00953ec..0cdd189 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -44,7 +44,24 @@ .top-link { display: none; } - + {{- if (and (ne .Site.Params.defaultTheme "light") (ne .Site.Params.defaultTheme "dark")) }} + @media (prefers-color-scheme: dark) { + :root { + --theme: #1d1e20; + --entry: #2e2e33; + --primary: rgba(255, 255, 255, 0.84); + --secondary: rgba(255, 255, 255, 0.56); + --tertiary: rgba(255, 255, 255, 0.16); + --content: rgba(255, 255, 255, 0.74); + --hljs-bg: #2e2e33; + --code-bg: #37383e; + --border: #333; + } + .list { + background: var(--theme); + } + } + {{- end }} </style> </noscript> <header class="header"> |
