2022-10-26 11:10:48 -05:00
|
|
|
<script lang="ts">
|
2024-01-07 01:15:25 +01:00
|
|
|
import { moonPath, moonViewBox, sunPath, sunViewBox } from '$lib/assets/svg-paths';
|
2024-09-09 10:29:23 -04:00
|
|
|
import CircleIconButton, { type Padding } from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
2025-04-29 17:44:09 -04:00
|
|
|
import { themeManager } from '$lib/managers/theme-manager.svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-04-29 21:17:22 +00:00
|
|
|
|
2025-04-29 17:44:09 -04:00
|
|
|
let icon = $derived(themeManager.isDark ? sunPath : moonPath);
|
|
|
|
|
let viewBox = $derived(themeManager.isDark ? sunViewBox : moonViewBox);
|
2024-09-09 10:29:23 -04:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
padding?: Padding;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { padding = '3' }: Props = $props();
|
2022-10-26 11:10:48 -05:00
|
|
|
</script>
|
|
|
|
|
|
2025-04-29 17:44:09 -04:00
|
|
|
{#if !themeManager.theme.system}
|
2024-08-25 19:50:54 -04:00
|
|
|
<CircleIconButton
|
|
|
|
|
title={$t('toggle_theme')}
|
|
|
|
|
{icon}
|
|
|
|
|
{viewBox}
|
|
|
|
|
role="switch"
|
2025-04-29 17:44:09 -04:00
|
|
|
aria-checked={themeManager.isDark ? 'true' : 'false'}
|
|
|
|
|
onclick={() => themeManager.toggleTheme()}
|
2024-09-09 10:29:23 -04:00
|
|
|
{padding}
|
2024-08-25 19:50:54 -04:00
|
|
|
/>
|
2024-01-07 01:15:25 +01:00
|
|
|
{/if}
|