2024-03-17 14:58:49 +01:00
|
|
|
---
|
|
|
|
|
import ThemeIcon from './ThemeIcon.astro';
|
|
|
|
|
---
|
2024-08-23 10:58:17 +02:00
|
|
|
<script type="module" client:load>
|
|
|
|
|
const updateSvgColorForTheme = () => {
|
|
|
|
|
const isDark = document.documentElement.classList.contains('dark');
|
|
|
|
|
const svgPath = document.getElementById('themePath');
|
|
|
|
|
if (svgPath) {
|
|
|
|
|
svgPath.setAttribute('stroke', isDark ? '#cdd6f4' : '#3B2C29');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateSvgColorForTheme();
|
2024-03-17 14:58:49 +01:00
|
|
|
|
2024-08-23 10:58:17 +02:00
|
|
|
const themeToggle = document.getElementById('themeToggle');
|
|
|
|
|
if (themeToggle) {
|
|
|
|
|
themeToggle.addEventListener('click', updateSvgColorForTheme);
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2024-03-17 14:58:49 +01:00
|
|
|
<header class="flex justify-between items-center py-5">
|
|
|
|
|
<div>
|
|
|
|
|
<a class="text-l font-semibold" href="/blog">
|
2024-08-23 10:58:17 +02:00
|
|
|
<svg id="themeSvg" class="w-6 h-6" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
|
|
|
<path id="themePath" stroke="#3B2C29" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 19-7-7 7-7"/>
|
2024-03-17 14:58:49 +01:00
|
|
|
</svg>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<ThemeIcon />
|
|
|
|
|
</header>
|