diff --git a/package-lock.json b/package-lock.json index 40534813..021ff55f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 92957b1f..c919ef1c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index 3cd22024..3dbd6040 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -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') } })(); diff --git a/src/assets/styles/partials/vars.css b/src/assets/styles/partials/vars.css index b566a7c0..f6f786fe 100644 --- a/src/assets/styles/partials/vars.css +++ b/src/assets/styles/partials/vars.css @@ -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);