Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Theming tweaks (#1294)

Matt Roberts4351985b08ea
diff --git a/app/pkg/web/testdata/basic.html b/app/pkg/web/testdata/basic.html
index d8fcd7e9d..aae0b44a8 100755
--- a/app/pkg/web/testdata/basic.html
+++ b/app/pkg/web/testdata/basic.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/canonical.html b/app/pkg/web/testdata/canonical.html
index 48d9f279e..84b6fa920 100755
--- a/app/pkg/web/testdata/canonical.html
+++ b/app/pkg/web/testdata/canonical.html
@@ -52,6 +52,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/chunk.html b/app/pkg/web/testdata/chunk.html
index c3552af05..0e98c649e 100644
--- a/app/pkg/web/testdata/chunk.html
+++ b/app/pkg/web/testdata/chunk.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/home.html b/app/pkg/web/testdata/home.html
index 42939753d..7938fd47b 100755
--- a/app/pkg/web/testdata/home.html
+++ b/app/pkg/web/testdata/home.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/home_ssr.html b/app/pkg/web/testdata/home_ssr.html
index 74bf656ef..cc6d11ed6 100755
--- a/app/pkg/web/testdata/home_ssr.html
+++ b/app/pkg/web/testdata/home_ssr.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/oauth.html b/app/pkg/web/testdata/oauth.html
index 4c174ab19..cacce36ec 100755
--- a/app/pkg/web/testdata/oauth.html
+++ b/app/pkg/web/testdata/oauth.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/tenant.html b/app/pkg/web/testdata/tenant.html
index 2c33b7fa2..804145184 100755
--- a/app/pkg/web/testdata/tenant.html
+++ b/app/pkg/web/testdata/tenant.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/app/pkg/web/testdata/user.html b/app/pkg/web/testdata/user.html
index f81f08685..f19f7ecd1 100755
--- a/app/pkg/web/testdata/user.html
+++ b/app/pkg/web/testdata/user.html
@@ -50,6 +50,26 @@
+ <script type="text/javascript" nonce="CONTEXT_ID">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
diff --git a/public/assets/styles/utility/text.scss b/public/assets/styles/utility/text.scss
index 8e74daf96..b4b260ba6 100644
--- a/public/assets/styles/utility/text.scss
+++ b/public/assets/styles/utility/text.scss
@@ -75,7 +75,7 @@ pre:last-child {
}
.text-link {
- color: var(--colors-blue-600);
+ color: var(--colors-primary-base);
}
.nowrap {
diff --git a/public/assets/styles/variables/_dark-colors.scss b/public/assets/styles/variables/_dark-colors.scss
index 9362d26fd..7485c12d7 100644
--- a/public/assets/styles/variables/_dark-colors.scss
+++ b/public/assets/styles/variables/_dark-colors.scss
@@ -5,10 +5,10 @@ $dark-colors: (
"300": #474747,
"400": #545454,
"500": #616161,
- "600": #6d6d6d,
- "700": #7a7a7a,
- "800": #a1a1a1,
- "900": #d3d3d3,
+ "600": #838383,
+ "700": #929292,
+ "800": #c1c1c1,
+ "900": #fefefe,
"50": #1a1a1a,
),
"green": (
@@ -60,9 +60,9 @@ $dark-colors: (
"50": #fef2f2,
),
"primary": (
- "light": var(--primary-color-light, #7a8efb),
- "base": var(--primary-color, #4d85ff),
- "dark": var(--primary-color-dark, #3b6ed9),
+ "light": var(--primary-color-light, #9eacfc),
+ "base": var(--primary-color, #7aa8ff),
+ "dark": var(--primary-color-dark, #6893e3),
),
"white": #1a1a1a,
"black": #d3d3d3,
diff --git a/public/components/ThemeSwitcher.tsx b/public/components/ThemeSwitcher.tsx
index 13a01e678..6fac8348c 100644
--- a/public/components/ThemeSwitcher.tsx
+++ b/public/components/ThemeSwitcher.tsx
@@ -4,11 +4,13 @@ import React, { useEffect, useState } from "react"
import { Icon } from "./common"
import "./ThemeSwitcher.scss"
+type themeType = "light" | "dark"
+
export const ThemeSwitcher = () => {
- const [currentTheme, setCurrentTheme] = useState(localStorage.getItem("theme") || "light")
+ // Lazy initialization of the theme state
+ const [currentTheme, setCurrentTheme] = useState<themeType>((localStorage.getItem("theme") as themeType) || "light")
const toggleTheme = () => {
- const currentTheme = localStorage.getItem("theme") || "light"
const newTheme = currentTheme === "light" ? "dark" : "light"
setCurrentTheme(newTheme)
}
diff --git a/public/pages/Home/components/ListPosts.tsx b/public/pages/Home/components/ListPosts.tsx
index a3fec8b52..90f2c2170 100644
--- a/public/pages/Home/components/ListPosts.tsx
+++ b/public/pages/Home/components/ListPosts.tsx
@@ -32,7 +32,7 @@ const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) =>
</HStack>
)}
</HStack>
- <Markdown className="text-gray-700" maxLength={300} text={props.post.description} style="plainText" />
+ <Markdown className="c-posts-container__postdescription" maxLength={300} text={props.post.description} style="plainText" />
{props.tags.length >= 1 && (
<HStack spacing={0} className="gap-2 flex-wrap">
{props.tags.map((tag) => (
diff --git a/views/base.html b/views/base.html
index b0499d4be..d7c76f4dd 100644
--- a/views/base.html
+++ b/views/base.html
@@ -49,6 +49,26 @@
</script>
{{ end }}
+ <script type="text/javascript" nonce="{{ .public.contextID }}">
+ ;(function () {
+ const params = new URLSearchParams(window.location.search)
+ let theme = "light"
+ if ((params.has("theme") && params.get("theme") === "light") || params.get("theme") === "dark") {
+ theme = params.get("theme")
+ localStorage.setItem("theme", theme)
+ params.delete("theme")
+ const newUrl = `${window.location.pathname}?${params.toString()}`
+ window.history.replaceState({}, "", newUrl)
+ } else {
+ theme = localStorage.getItem("theme") || "light"
+ }
+
+ if (theme == "light" || theme == "dark") {
+ document.body.setAttribute("data-theme", theme)
+ }
+ })()
+ </script>
+
{{template "end-of-body" .}}
{{ if .public.tenant }}
{{ if .public.tenant.CustomCSS }}