set theme swap to have a better color for light theme
This commit is contained in:
@@ -1,12 +1,23 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
const htmlElement = document.querySelector("html")
|
||||||
|
const lightMode = htmlElement?.dataset.theme
|
||||||
|
const darkMode = "coffee"
|
||||||
|
|
||||||
const isDark = ref(JSON.parse(localStorage.getItem('is-dark') ?? 'false'))
|
const isInitiallyDark = JSON.parse(localStorage.getItem("is-dark") ?? "false")
|
||||||
const toggle = (isChecked: boolean) => {
|
|
||||||
localStorage.setItem('is-dark', isChecked ? 'true' : 'false')
|
if (htmlElement) {
|
||||||
|
htmlElement.dataset.theme = isInitiallyDark ? darkMode : lightMode
|
||||||
}
|
}
|
||||||
|
|
||||||
const darkMode = 'coffee'
|
const toggle = (isChecked: boolean) => {
|
||||||
|
localStorage.setItem("is-dark", isChecked ? "true" : "false")
|
||||||
|
|
||||||
|
if (!htmlElement) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
htmlElement.dataset.theme = isChecked ? darkMode : lightMode
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -14,9 +25,9 @@ const darkMode = 'coffee'
|
|||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
:value="darkMode"
|
:value="darkMode"
|
||||||
:checked="isDark"
|
:checked="isInitiallyDark"
|
||||||
class="theme-controller"
|
class="theme-controller"
|
||||||
@click="() => toggle(!isDark)"
|
@click="(e) => toggle((e.target as HTMLInputElement)?.checked)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
--light-link: lighten(#445fb9, 45%);
|
--light-link: lighten(#445fb9, 45%);
|
||||||
--background-color: #ffffff;
|
--background-color: #ffffff;
|
||||||
--note-width: 620px;
|
--note-width: 620px;
|
||||||
|
--color-contrast-content: var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="valentine"] {
|
||||||
|
--color-contrast-content: var(--color-success-content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@plugin "@tailwindcss/typography";
|
@plugin "@tailwindcss/typography";
|
||||||
@@ -33,7 +38,6 @@
|
|||||||
color utility to any element that depends on these defaults.
|
color utility to any element that depends on these defaults.
|
||||||
*/
|
*/
|
||||||
@layer base {
|
@layer base {
|
||||||
|
|
||||||
*,
|
*,
|
||||||
::after,
|
::after,
|
||||||
::before,
|
::before,
|
||||||
@@ -55,7 +59,6 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 769px) {
|
@media screen and (min-width: 769px) {
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
@@ -120,7 +123,6 @@ a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@@ -154,7 +156,7 @@ pre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.markdown-alert-title svg path {
|
.markdown-alert-title svg path {
|
||||||
fill: var(--color-base-content)
|
fill: var(--color-base-content);
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
|
|||||||
@@ -1,59 +1,59 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
const dotenv = require('dotenv')
|
const dotenv = require("dotenv")
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
const defaultTitleStyles = Array.from(
|
const defaultTitleStyles = Array.from(
|
||||||
{ length: 6 },
|
{ length: 6 },
|
||||||
(_, k) => `h${k + 1}`
|
(_, k) => `h${k + 1}`,
|
||||||
).reduce(
|
).reduce(
|
||||||
(acc, heading) => ({
|
(acc, heading) => ({
|
||||||
...acc,
|
...acc,
|
||||||
[heading]: {
|
[heading]: {
|
||||||
'margin-top': '0',
|
"margin-top": "0",
|
||||||
'margin-bottom': '0.5em'
|
"margin-bottom": "0.5em",
|
||||||
}
|
},
|
||||||
}),
|
}),
|
||||||
{}
|
{},
|
||||||
)
|
)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: ['./src/**/*.{vue,js,ts}'],
|
content: ["./src/**/*.{vue,js,ts}"],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
typography: () => ({
|
typography: () => ({
|
||||||
DEFAULT: {
|
DEFAULT: {
|
||||||
css: {
|
css: {
|
||||||
'font-size': '13pt',
|
"font-size": "13pt",
|
||||||
'font-family': '"Courier Prime", monospace',
|
"font-family": '"Courier Prime", monospace',
|
||||||
...defaultTitleStyles,
|
...defaultTitleStyles,
|
||||||
p: {
|
p: {
|
||||||
'margin-top': '0.8em',
|
"margin-top": "0.8em",
|
||||||
'margin-bottom': '0.8em',
|
"margin-bottom": "0.8em",
|
||||||
'text-align': 'justify'
|
"text-align": "justify",
|
||||||
},
|
},
|
||||||
img: {
|
img: {
|
||||||
'margin-top': 0,
|
"margin-top": 0,
|
||||||
'margin-bottom': 0,
|
"margin-bottom": 0,
|
||||||
'border-radius': '1rem'
|
"border-radius": "1rem",
|
||||||
},
|
},
|
||||||
a: {
|
a: {
|
||||||
'text-decoration': 'none',
|
"text-decoration": "none",
|
||||||
color: 'var(--color-success)'
|
color: "var(--color-contrast-content)",
|
||||||
},
|
},
|
||||||
'a.btn-primary': {
|
"a.btn-primary": {
|
||||||
color: 'var(--color-secondary-content)'
|
color: "var(--color-secondary-content)",
|
||||||
},
|
},
|
||||||
'a:hover': {
|
"a:hover": {
|
||||||
'text-decoration': 'underline'
|
"text-decoration": "underline",
|
||||||
},
|
},
|
||||||
li: {
|
li: {
|
||||||
'margin-top': 0,
|
"margin-top": 0,
|
||||||
'margin-bottom': 0
|
"margin-bottom": 0,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
}),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user