Sink/app/components/SwitchTheme.vue
wudi 7cadbfe2b1 refactor: Migrate project files and directories to the app directory using the new compatibilityVersion: 4 feature
- Moved `app.config.ts` to the `app` directory
- Migrated `.vue` files and other assets to the `app` directory
- Updated import paths to reflect the new file locations
2025-03-24 11:05:59 +08:00

47 lines
1.2 KiB
Vue

<script setup>
import { Laptop, Moon, Sun } from 'lucide-vue-next'
const colorMode = useColorMode()
</script>
<template>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button variant="ghost">
<Sun
class="absolute w-5 h-5 transition-all scale-100 dark:scale-0"
/>
<Moon
class="w-5 h-5 transition-all scale-0 dark:scale-100"
/>
<span class="sr-only">{{ $t('theme.toggle') }}</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
class="min-w-min"
>
<DropdownMenuItem
class="cursor-pointer"
@click="colorMode.preference = 'light'"
>
<Sun class="w-4 h-4 mr-1" />
{{ $t('theme.light') }}
</DropdownMenuItem>
<DropdownMenuItem
class="cursor-pointer"
@click="colorMode.preference = 'dark'"
>
<Moon class="w-4 h-4 mr-1" />
{{ $t('theme.dark') }}
</DropdownMenuItem>
<DropdownMenuItem
class="cursor-pointer"
@click="colorMode.preference = 'system'"
>
<Laptop class="w-4 h-4 mr-1" />
{{ $t('theme.system') }}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</template>