static,internal: dark mode bug fixes
- Fixed cookie parsing regex.
- Fixed icon css selector.
- Added cache busting param to css hrefs.
Change-Id: I345478eea85974e78d4649954880e3a422b20ce3
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/338271
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/middleware/secureheaders.go b/internal/middleware/secureheaders.go
index ac528c4..fbe4ffd 100644
--- a/internal/middleware/secureheaders.go
+++ b/internal/middleware/secureheaders.go
@@ -17,7 +17,7 @@
"'sha256-CoGrkqEM1Kjjf5b1bpcnDLl8ZZLAsVX+BoAzZ5+AOmc='",
"'sha256-Rex7jo7NdAFHm6IM8u1LgCIn9Gr9p2QZ0bf6ZkK618g='",
"'sha256-karKh1IrXOF1g+uoSxK+k9BuciCwYY/ytGuQVUiRzcM='",
- "'sha256-Wf3ZjOwjQb2z6NEAB3ff/dlNAx2IfCbBwKKEsuR3Ny8='",
+ "'sha256-mxm3e8M0u3nPPBmLIBgGuMvGUIL5LGv+HzV3bLAIBgw='",
// From static/frontend/search/search.tmpl
"'sha256-GZ+7ZnhhodcQDG6v/lrrpA8KWVHdCpgG0cxpOJdxYwU='",
// From static/frontend/styleguide/styleguide.tmpl
diff --git a/static/frontend/frontend.tmpl b/static/frontend/frontend.tmpl
index 0e6685e..d93e6f9 100644
--- a/static/frontend/frontend.tmpl
+++ b/static/frontend/frontend.tmpl
@@ -13,7 +13,7 @@
</script>
<script>
(function() {
- const theme = document.cookie.match(/prefers-color-scheme=(.+)/)?.[1]
+ const theme = document.cookie.match(/prefers-color-scheme=(light|dark|auto)/)?.[1]
if (theme) {
document.querySelector('html').setAttribute('data-theme', theme);
}
@@ -29,9 +29,9 @@
<link rel="shortcut icon" href="/static/shared/icon/favicon.ico">
<!-- Only load the css reset for non-legacy pages -->
{{if not .UseSiteWrapper}}
- <link href="/static/shared/reset.css" rel="stylesheet">
+ <link href="/static/shared/reset.css?version={{.AppVersionLabel}}" rel="stylesheet">
{{end}}
- <link href="/static/frontend/frontend.css" rel="stylesheet">
+ <link href="/static/frontend/frontend.css?version={{.AppVersionLabel}}" rel="stylesheet">
{{block "title" .}}
<title>pkg.go.dev</title>
{{end}}
diff --git a/static/shared/icon/icon.css b/static/shared/icon/icon.css
index 7d66f7a..cf22562 100644
--- a/static/shared/icon/icon.css
+++ b/static/shared/icon/icon.css
@@ -28,7 +28,7 @@
contrast(88%);
}
@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .go-Icon:root:not(.go-Icon--accented) {
+ :root:not([data-theme='light']) .go-Icon:not(.go-Icon--accented) {
filter: brightness(0) saturate(100%) invert(100%) sepia(97%) saturate(13%) hue-rotate(245deg)
brightness(103%) contrast(107%);
}