mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2024-12-22 08:06:29 +00:00
dark mode
This commit is contained in:
parent
c9dc5fadd1
commit
1a3c78d4bf
10
src/app.css
10
src/app.css
@ -15,9 +15,19 @@
|
|||||||
--clr-primary: hsl(219, 90%, 80%);
|
--clr-primary: hsl(219, 90%, 80%);
|
||||||
--clr-secondary: hsl(64, 93%, 51%);
|
--clr-secondary: hsl(64, 93%, 51%);
|
||||||
--clr-error: hsl(0, 73.9%, 65.5%);
|
--clr-error: hsl(0, 73.9%, 65.5%);
|
||||||
|
--clr-transparent-0: hsla(0, 0%, 0%, 0.1);
|
||||||
--animation: all 250ms ease;
|
--animation: all 250ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--clr-light: #010101;
|
||||||
|
--clr-dark: #ffffff;
|
||||||
|
--clr-primary: hsl(219, 90%, 30%);
|
||||||
|
--clr-transparent-0: hsla(0, 0%, 100%, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import 'highlight.js/styles/github.css'
|
|
||||||
import hljs from 'highlight.js/lib/core'
|
import hljs from 'highlight.js/lib/core'
|
||||||
import javascript from 'highlight.js/lib/languages/javascript'
|
import javascript from 'highlight.js/lib/languages/javascript'
|
||||||
import python from 'highlight.js/lib/languages/python'
|
import python from 'highlight.js/lib/languages/python'
|
||||||
@ -32,9 +31,10 @@
|
|||||||
.replace(' ', '-')
|
.replace(' ', '-')
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(async () => {
|
||||||
hljs.highlightAll()
|
hljs.highlightAll()
|
||||||
|
|
||||||
|
// Add anchor links to headers
|
||||||
const selector = [1, 2, 3, 4, 5, 6].map((i) => `div.adapter h${i}`).join(', ')
|
const selector = [1, 2, 3, 4, 5, 6].map((i) => `div.adapter h${i}`).join(', ')
|
||||||
const elements = window.document.querySelectorAll(selector)
|
const elements = window.document.querySelectorAll(selector)
|
||||||
elements.forEach((el) => {
|
elements.forEach((el) => {
|
||||||
@ -43,6 +43,14 @@
|
|||||||
el.innerHTML = `<a class="target-link" name="${hash}" href="${window.location.pathname}#${hash}">${el.innerHTML}</a>`
|
el.innerHTML = `<a class="target-link" name="${hash}" href="${window.location.pathname}#${hash}">${el.innerHTML}</a>`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function update(isDark: boolean) {
|
||||||
|
isDark ? await import('highlight.js/styles/github-dark.css') : await import('highlight.js/styles/github.css')
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = window.matchMedia('(prefers-color-scheme: dark)')
|
||||||
|
match.addEventListener('change', (e) => update(e.matches))
|
||||||
|
update(match.matches)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -89,12 +97,12 @@
|
|||||||
|
|
||||||
div :global(pre) {
|
div :global(pre) {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
background: #0000000d;
|
background: var(--clr-transparent-0);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
div :global(code) {
|
div :global(code) {
|
||||||
background: #00000012;
|
background: var(--clr-transparent-0);
|
||||||
padding: 0.25em;
|
padding: 0.25em;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user