click(l)" v-for="l in targets" :key="l">
{{ supportedLang[l] }}
@@ -11,9 +12,10 @@
import { Component, Vue } from 'vue-facing-decorator';
import { getLang, Lang, setLang, supportedLang } from "@/logic/config";
import { info } from "@/logic/utils";
+import ThemeButton from "@/components/ThemeButton.vue";
-@Component({ components: {} })
+@Component({ components: {ThemeButton} })
export default class LangButton extends Vue {
lang = getLang()
supportedLang = supportedLang
diff --git a/src/components/Loading.vue b/src/components/Loading.vue
index 497bd0f19..4670e3b3e 100644
--- a/src/components/Loading.vue
+++ b/src/components/Loading.vue
@@ -128,7 +128,7 @@ export default class Loading extends Vue {
color: rgba(166, 134, 89, 0.84);
}
-@media (prefers-color-scheme: dark) {
+[data-theme="dark"] {
.loadingMessage {
color: rgba(255, 235, 194, 0.84)
}
diff --git a/src/components/MarkdownTooltip.vue b/src/components/MarkdownTooltip.vue
index 8715fef19..980230af9 100644
--- a/src/components/MarkdownTooltip.vue
+++ b/src/components/MarkdownTooltip.vue
@@ -189,7 +189,7 @@ export default class MarkdownTooltip extends Vue
padding-left: 3px
padding-right: 8px
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
#MarkdownTooltip
background: #fffcff30
color: $color-text-dark-light
diff --git a/src/components/ProfileCard.vue b/src/components/ProfileCard.vue
index 19e9572db..3239753ce 100644
--- a/src/components/ProfileCard.vue
+++ b/src/components/ProfileCard.vue
@@ -485,7 +485,7 @@ div:has(.view-limit-alert)
width: 30px
height: 30px
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
#info
background-color: $color-bg-dark-6
diff --git a/src/components/RandomPerson.vue b/src/components/RandomPerson.vue
index 253225e4e..45695d959 100644
--- a/src/components/RandomPerson.vue
+++ b/src/components/RandomPerson.vue
@@ -54,7 +54,7 @@ export default class RandomPerson extends Vue {
font-size: 1rem
font-family: 'Hua', $font
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
.random
color: $color-text-dark-main
background-color: $color-bg-dark-6
diff --git a/src/components/SubmitPrompt.vue b/src/components/SubmitPrompt.vue
index 1eeb8d16b..a104495d7 100644
--- a/src/components/SubmitPrompt.vue
+++ b/src/components/SubmitPrompt.vue
@@ -95,7 +95,7 @@ export default class SubmitPrompt extends Vue
font-size: small
color: $color-text-light
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
#prompt
background: $color-bg-dark-5
diff --git a/src/components/ThemeButton.vue b/src/components/ThemeButton.vue
new file mode 100644
index 000000000..02d56859e
--- /dev/null
+++ b/src/components/ThemeButton.vue
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/css/global.sass b/src/css/global.sass
index ac0221297..9083c648f 100644
--- a/src/css/global.sass
+++ b/src/css/global.sass
@@ -186,7 +186,7 @@ svg.icon
.katex-html
display: none
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
.color-hightlight
color: $c-highlight-dark
diff --git a/src/css/markdown.sass b/src/css/markdown.sass
index 332b480f3..3929d5ac5 100644
--- a/src/css/markdown.sass
+++ b/src/css/markdown.sass
@@ -42,7 +42,7 @@
border-width: 1px
border-image: repeating-linear-gradient(45deg, #e94880, #e94880 10px, #f5aac5 10px, #f5aac5 20px) 1
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
.markdown-content
a
color: $color-text-dark-special
diff --git a/src/logic/theme.ts b/src/logic/theme.ts
new file mode 100644
index 000000000..0d81430d5
--- /dev/null
+++ b/src/logic/theme.ts
@@ -0,0 +1,22 @@
+export type Theme = 'dark' | 'light' | 'unset'
+
+export function getTheme(): Theme {
+ if (localStorage.getItem('theme')) {
+ return localStorage.getItem('theme') as Theme
+ }
+ if (window.matchMedia) {
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ return 'dark'
+ }
+ return 'light'
+ }
+ return 'unset'
+}
+
+export function setTheme(theme: Theme) {
+ localStorage.setItem('theme', theme)
+}
+
+export function applyTheme() {
+ document.documentElement.setAttribute('data-theme', getTheme())
+}
\ No newline at end of file
diff --git a/src/views/EditInfo.vue b/src/views/EditInfo.vue
index d7c7da0e6..8b98a546e 100644
--- a/src/views/EditInfo.vue
+++ b/src/views/EditInfo.vue
@@ -311,7 +311,7 @@ export default class EditInfo extends Vue
border-top-left-radius: 0
border-top-right-radius: 0
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
#EditInfo
background: $color-bg-dark-5
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 09b5b277f..3ad5dce4d 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -250,7 +250,7 @@ export default class Home extends Vue
height: $len
width: $len
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
.back, .front
border: 10px solid rgba(27, 27, 32, 0.8964) !important
outline: 2px solid $color-text-dark-main !important
diff --git a/src/views/ProfileComments.vue b/src/views/ProfileComments.vue
index dc1c72b7b..1c55a6c37 100644
--- a/src/views/ProfileComments.vue
+++ b/src/views/ProfileComments.vue
@@ -264,7 +264,7 @@ export default class ProfileComments extends Vue
color: $color-text-light
margin-right: 5px
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
.comment
.from
color: $color-text-dark-light !important
diff --git a/src/views/TdorComments.vue b/src/views/TdorComments.vue
index 474902e59..9f148e950 100644
--- a/src/views/TdorComments.vue
+++ b/src/views/TdorComments.vue
@@ -257,7 +257,7 @@ export default class TdorComments extends Vue {
box-shadow: 15px 15px 15px -5px rgba(166 134 89 / 0.3)
border-color: $color-text-special
-@media (prefers-color-scheme: dark)
+[data-theme="dark"]
.comment
.from
color: $color-text-dark-light