refactor: remove theme toggle functionality and related styles

This commit is contained in:
Adrian Altner 2026-04-22 18:23:06 +02:00
parent 3152e8f72b
commit 981c81a865
4 changed files with 2 additions and 112 deletions

View file

@ -1,8 +1,8 @@
name: Deploy name: Deploy
on: on:
push: schedule:
branches: [main] - cron: '0 6 * * *'
workflow_dispatch: workflow_dispatch:
jobs: jobs:

View file

@ -60,20 +60,6 @@ const switchHref = await resolveSwitchHref();
<HeaderLink href={tagsHref}>{t(locale, 'nav.tags')}</HeaderLink> <HeaderLink href={tagsHref}>{t(locale, 'nav.tags')}</HeaderLink>
</div> </div>
<div class="toolbar"> <div class="toolbar">
<button class="theme-toggle" type="button" aria-label="Toggle theme">
<span class="theme-toggle__thumb" aria-hidden="true"></span>
<span class="theme-toggle__icon theme-toggle__icon--sun" aria-hidden="true">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="4"></circle>
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"></path>
</svg>
</span>
<span class="theme-toggle__icon theme-toggle__icon--moon" aria-hidden="true">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
</span>
</button>
<a <a
class={`lang-toggle lang-toggle--${locale}`} class={`lang-toggle lang-toggle--${locale}`}
href={switchHref} href={switchHref}
@ -109,16 +95,6 @@ const switchHref = await resolveSwitchHref();
window.setTimeout(() => navigate(href), 280); window.setTimeout(() => navigate(href), 280);
}); });
} }
function wireThemeToggle() {
const btn = document.querySelector<HTMLButtonElement>('.theme-toggle');
if (!btn || btn.dataset.wired) return;
btn.dataset.wired = '1';
btn.addEventListener('click', () => {
const next = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
document.documentElement.dataset.theme = next;
localStorage.setItem('theme', next);
});
}
function wireMenuToggle() { function wireMenuToggle() {
const btn = document.querySelector<HTMLButtonElement>('.menu-toggle'); const btn = document.querySelector<HTMLButtonElement>('.menu-toggle');
const menu = document.getElementById('mobile-menu'); const menu = document.getElementById('mobile-menu');
@ -162,11 +138,9 @@ const switchHref = await resolveSwitchHref();
document.addEventListener('astro:after-swap', close); document.addEventListener('astro:after-swap', close);
} }
wireLangToggle(); wireLangToggle();
wireThemeToggle();
wireMenuToggle(); wireMenuToggle();
document.addEventListener('astro:page-load', () => { document.addEventListener('astro:page-load', () => {
wireLangToggle(); wireLangToggle();
wireThemeToggle();
wireMenuToggle(); wireMenuToggle();
}); });
</script> </script>
@ -293,63 +267,6 @@ const switchHref = await resolveSwitchHref();
align-items: center; align-items: center;
gap: 0.6em; gap: 0.6em;
} }
.theme-toggle {
position: relative;
display: inline-flex;
align-items: stretch;
padding: 3px;
margin: 0;
border: 0;
background: rgba(var(--gray-light), 0.7);
border-radius: 999px;
cursor: pointer;
line-height: 1;
user-select: none;
font: inherit;
}
.theme-toggle:hover {
background: rgba(var(--gray-light), 1);
}
.theme-toggle__thumb {
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
width: calc(50% - 3px);
border-radius: 999px;
background: var(--accent);
box-shadow: 0 1px 3px rgba(var(--black), 0.18);
}
:global(:root[data-theme-ready]) .theme-toggle__thumb {
transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
:global(:root[data-theme='dark']) .theme-toggle__thumb {
transform: translateX(100%);
}
.theme-toggle__icon {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
width: 1.8em;
height: 1.8em;
font-size: 0.9em;
color: rgb(var(--gray));
}
:global(:root[data-theme-ready]) .theme-toggle__icon {
transition: color 280ms ease;
}
:global(:root:not([data-theme='dark'])) .theme-toggle__icon--sun,
:global(:root[data-theme='dark']) .theme-toggle__icon--moon {
color: white;
}
@media (prefers-reduced-motion: reduce) {
.theme-toggle__thumb,
.theme-toggle__icon {
transition: none;
}
}
.menu-toggle { .menu-toggle {
display: none; display: none;
margin-left: 0.8em; margin-left: 0.8em;

View file

@ -32,19 +32,6 @@ const {
<html lang={locale}> <html lang={locale}>
<head> <head>
<BaseHead title={title} description={description} image={image} locale={locale} /> <BaseHead title={title} description={description} image={image} locale={locale} />
<script is:inline>
(() => {
const root = document.documentElement;
const stored = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = stored === 'dark' || stored === 'light' ? stored : prefersDark ? 'dark' : 'light';
root.dataset.theme = theme;
// Enable theme transitions after initial render
requestAnimationFrame(() =>
requestAnimationFrame(() => root.setAttribute('data-theme-ready', '')),
);
})();
</script>
<slot name="head" /> <slot name="head" />
</head> </head>
<body class={bodyClass}> <body class={bodyClass}>

View file

@ -18,22 +18,8 @@
0 16px 32px rgba(var(--gray), 33%); 0 16px 32px rgba(var(--gray), 33%);
color-scheme: light; color-scheme: light;
} }
:root[data-theme='dark'] {
--accent: #8c96ff;
--accent-dark: #c2c8ff;
--black: 230, 233, 240;
--gray: 150, 160, 190;
--gray-light: 38, 42, 56;
--gray-dark: 220, 225, 235;
--surface: 17, 20, 28;
--gray-gradient: rgba(var(--gray-light), 50%), rgb(var(--surface));
color-scheme: dark;
}
html { html {
background: rgb(var(--surface)); background: rgb(var(--surface));
transition:
background-color 300ms ease,
color 300ms ease;
} }
body { body {
font-family: var(--font-atkinson); font-family: var(--font-atkinson);