feat: Dark mode svg
This commit is contained in:
parent
33ebd62026
commit
8d0fb521d4
4959
src/lib/Cover.svelte
4959
src/lib/Cover.svelte
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 329 KiB After Width: | Height: | Size: 148 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 340 KiB |
|
@ -3,7 +3,7 @@
|
|||
import { derived } from 'svelte/store'
|
||||
import { routes } from "$lib/sitemap.ts"
|
||||
import { Separator } from "$lib/components/ui/separator/index.js";
|
||||
import { theme, getThemeObject } from '$lib/theme'
|
||||
import { theme, setTheme, getThemeObject } from '$lib/theme'
|
||||
import { Rss } from "lucide-svelte";
|
||||
import ThemeSwitch from "$lib/components/ThemeSwitch.svelte"
|
||||
import Cover from "$lib/Cover.svelte"
|
||||
|
@ -13,9 +13,25 @@
|
|||
|
||||
let button_blog;
|
||||
|
||||
function toggleTheme() {
|
||||
theme.update((currentTheme) => {
|
||||
const newTheme = currentTheme === 'tokiwa' ? 'star' : 'tokiwa'
|
||||
|
||||
document.documentElement.setAttribute('color-scheme', newTheme)
|
||||
localStorage.setItem('color-scheme', newTheme)
|
||||
|
||||
if (newTheme === "tokiwa") {
|
||||
document.documentElement.classList.remove('dark');
|
||||
} else {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
setTheme(newTheme);
|
||||
return newTheme
|
||||
})
|
||||
}
|
||||
onMount(() => {
|
||||
let entity_blog = document.getElementById("visor");
|
||||
let link_about = document.getElementById("link-about");
|
||||
let entity_switch = document.getElementById("switch");
|
||||
entity_switch.addEventListener("click", toggleTheme);
|
||||
});
|
||||
function onScroll() {
|
||||
if (scrollHeight > 1) {
|
||||
|
@ -48,18 +64,16 @@
|
|||
};
|
||||
const iconLinks: [string, string][] = Object.entries(metadata.links).map(
|
||||
([key, link]) => [iconMap[key], link]);
|
||||
|
||||
const frontCover = derived(
|
||||
theme,
|
||||
($theme) => getThemeObject($theme, metadata.frontCover)
|
||||
)
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{metadata.name}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div id="cover" style="opacity: {1 - progress}">
|
||||
<div
|
||||
id="cover"
|
||||
style="opacity: {1 - progress}; --grid-line: #999; --grid-cell: #707078"
|
||||
>
|
||||
<Cover />
|
||||
</div>
|
||||
|
||||
|
@ -116,9 +130,9 @@
|
|||
<style>
|
||||
#cover {
|
||||
background:
|
||||
repeating-linear-gradient(129deg, transparent, #aaa 1px, #aaa 2px, transparent 1px, transparent 60px),
|
||||
repeating-linear-gradient(11deg, transparent, #aaa 1px, #aaa 2px, transparent 1px, transparent 40px),
|
||||
#707078
|
||||
repeating-linear-gradient(129deg, transparent, var(--grid-line) 1px, var(--grid-line) 2px, transparent 1px, transparent 60px),
|
||||
repeating-linear-gradient(11deg, transparent, var(--grid-line) 1px, var(--grid-line) 2px, transparent 1px, transparent 40px),
|
||||
var(--grid-cell)
|
||||
;
|
||||
/*
|
||||
position: absolute;
|
||||
|
@ -126,6 +140,16 @@
|
|||
background-position: center center; */
|
||||
z-index: -10;
|
||||
overscroll-behaviour: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
:global(.dark #cover) {
|
||||
background:
|
||||
repeating-linear-gradient(129deg, transparent, var(--grid-line) 1px, var(--grid-line) 2px, transparent 1px, transparent 60px),
|
||||
repeating-linear-gradient(11deg, transparent, var(--grid-line) 1px, var(--grid-line) 2px, transparent 1px, transparent 40px),
|
||||
black
|
||||
;
|
||||
}
|
||||
:global(#cover > svg) {
|
||||
max-width: 100svw;
|
||||
|
@ -152,9 +176,24 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
:global(.dark .shadow) {
|
||||
visibility: hidden;
|
||||
}
|
||||
:global(svg .shadow) {
|
||||
pointer-events: none;
|
||||
}
|
||||
:global(#switch-right) {
|
||||
visibility: hidden;
|
||||
}
|
||||
:global(#switch-left) {
|
||||
visibility: visible;
|
||||
}
|
||||
:global(.dark #switch-right) {
|
||||
visibility: visible;
|
||||
}
|
||||
:global(.dark #switch-left) {
|
||||
visibility: hidden;
|
||||
}
|
||||
.nav-link {
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue