33 lines
1.6 KiB
Vue
33 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import { Sun, Moon } from 'lucide-vue-next';
|
|
import { useTheme } from '../composables/useTheme';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
const props = withDefaults(defineProps<{ floating?: boolean }>(), {
|
|
floating: false,
|
|
});
|
|
|
|
const { t } = useI18n();
|
|
const { appliedTheme, toggleLightDark } = useTheme();
|
|
|
|
const isDarkTheme = computed(() => appliedTheme.value === 'dark');
|
|
const buttonClass = computed(() =>
|
|
props.floating
|
|
? 'fixed bottom-5 right-5 z-[70] h-11 w-11 rounded-full bg-white/90 dark:bg-slate-900/90 backdrop-blur-md shadow-lg border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-xl flex items-center justify-center transition-all'
|
|
: 'h-8 w-8 md:h-9 md:w-9 rounded-full bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-md flex items-center justify-center transition-all'
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<button
|
|
@click="toggleLightDark"
|
|
:class="buttonClass"
|
|
:title="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
|
|
:aria-label="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
|
|
>
|
|
<Sun v-if="isDarkTheme" class="w-4 h-4 md:w-5 md:h-5" />
|
|
<Moon v-else class="w-4 h-4 md:w-5 md:h-5" />
|
|
</button>
|
|
</template>
|