fix: theming bug
This commit is contained in:
parent
1c01154395
commit
119f3ce524
4 changed files with 13 additions and 12 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -10,7 +10,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@cdransf/api-text": "^1.1.0",
|
||||
"@cdransf/theme-toggle": "^1.2.2",
|
||||
"@cdransf/theme-toggle": "^1.2.3",
|
||||
"@daviddarnes/mastodon-post": "^1.1.1",
|
||||
"@remy/webmention": "^1.5.0",
|
||||
"@zachleat/pagefind-search": "^1.0.3",
|
||||
|
@ -1235,9 +1235,9 @@
|
|||
"integrity": "sha512-gPHWl6PWM4oXNgHbTZ5quj6c9B6DxgeCp4IX1vx4I+5A+pQhKvsO59JaXpEW8Fgdey3rWwgJq2TIkO5zspBdZg=="
|
||||
},
|
||||
"node_modules/@cdransf/theme-toggle": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@cdransf/theme-toggle/-/theme-toggle-1.2.2.tgz",
|
||||
"integrity": "sha512-EPfNRs4sd3DFPWeylzQG8zTn5zhKL9xdeHr68GuDSiWcz3+kEMZrUwkQ9BvALSzaZC0E51dP0tvnYx2V6U8lYg=="
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@cdransf/theme-toggle/-/theme-toggle-1.2.3.tgz",
|
||||
"integrity": "sha512-K2NniEup/OFgSH+cqG2plY5iPFBevu7mMrz10HL1KzcEulA8AxPyPDcuOAC0Hdt7OpWAIzAk0hB0wvI7g8KW3A=="
|
||||
},
|
||||
"node_modules/@daviddarnes/mastodon-post": {
|
||||
"version": "1.1.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "6.9.4",
|
||||
"version": "6.9.5",
|
||||
"description": "The source for my personal site. Built using 11ty and hosted on Netlify.",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
@ -22,7 +22,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@cdransf/api-text": "^1.1.0",
|
||||
"@cdransf/theme-toggle": "^1.2.2",
|
||||
"@cdransf/theme-toggle": "^1.2.3",
|
||||
"@daviddarnes/mastodon-post": "^1.1.1",
|
||||
"@remy/webmention": "^1.5.0",
|
||||
"@zachleat/pagefind-search": "^1.0.3",
|
||||
|
|
|
@ -90,15 +90,16 @@
|
|||
(() => {
|
||||
const currentTheme = sessionStorage?.getItem('theme');
|
||||
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
const root = document.getElementsByTagName('html')[0];
|
||||
if (!currentTheme) sessionStorage?.setItem('theme', (prefersDarkScheme ? 'dark' : 'light'))
|
||||
if (currentTheme === 'dark') {
|
||||
document.body.classList.add('theme__dark')
|
||||
root.classList.add('theme__dark')
|
||||
} else if (currentTheme === 'light') {
|
||||
document.body.classList.add('theme__light')
|
||||
root.classList.add('theme__light')
|
||||
} else if (prefersDarkScheme) {
|
||||
document.body.classList.add('theme__dark')
|
||||
root.classList.add('theme__dark')
|
||||
} else if (!prefersDarkScheme) {
|
||||
document.body.classList.add('theme__light')
|
||||
root.classList.add('theme__light')
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
}
|
||||
|
||||
/* light theme */
|
||||
:root body.theme__light {
|
||||
:root.theme__light {
|
||||
--text-color: var(--color-darkest);
|
||||
--background-color: var(--color-lightest);
|
||||
--text-color-inverted: var(--color-lightest);
|
||||
|
@ -133,7 +133,7 @@
|
|||
}
|
||||
|
||||
/* dark theme */
|
||||
:root body.theme__dark {
|
||||
:root.theme__dark {
|
||||
--text-color: var(--color-lightest);
|
||||
--background-color: var(--color-darkest);
|
||||
--text-color-inverted: var(--color-darkest);
|
||||
|
|
Reference in a new issue