|
| 1 | +<script module lang="ts"> |
| 2 | + import {msg} from 'svelte-i18n-lingui'; |
| 3 | +
|
| 4 | + export const themes = [msg`green`, msg`blue`, msg`rose`, msg`orange`, msg`violet`, msg`stone`]; |
| 5 | +</script> |
| 6 | + |
1 | 7 | <script lang="ts"> |
2 | 8 | import {Button, type ButtonProps, XButton} from '$lib/components/ui/button'; |
3 | 9 | import {Icon} from '$lib/components/ui/icon'; |
4 | 10 | import {Label} from '$lib/components/ui/label/index.js'; |
5 | 11 | import * as Popover from '$lib/components/ui/popover'; |
6 | 12 | import {cn} from '$lib/utils'; |
7 | 13 | import {mode, resetMode, setMode, setTheme, theme, userPrefersMode} from 'mode-watcher'; |
8 | | - import {t, msg} from 'svelte-i18n-lingui'; |
9 | | - import {mergeProps} from 'bits-ui'; |
| 14 | + import {t} from 'svelte-i18n-lingui'; |
10 | 15 |
|
11 | | - const themes = [msg`green`, msg`blue`, msg`rose`, msg`orange`, msg`violet`, msg`stone`]; |
12 | 16 | let { |
13 | | - buttonProps = {}, |
| 17 | + variant, |
14 | 18 | }: { |
15 | | - buttonProps?: Partial<ButtonProps>; |
| 19 | + variant?: ButtonProps['variant'] & ('default' | 'ghost'); |
16 | 20 | } = $props(); |
| 21 | +
|
| 22 | + const triggerClass = $derived(variant === 'ghost' ? 'text-primary' : undefined); |
17 | 23 | </script> |
18 | 24 |
|
19 | 25 | <Popover.Root> |
20 | 26 | <Popover.Trigger> |
21 | 27 | {#snippet child({props})} |
22 | | - <Button variant="ghost" size="icon" {...mergeProps(props, buttonProps)}> |
| 28 | + <Button {variant} size="icon" {...props}> |
23 | 29 | <Icon |
24 | 30 | icon="i-mdi-white-balance-sunny" |
25 | | - class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 text-primary" |
| 31 | + class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 {triggerClass}" |
26 | 32 | /> |
27 | 33 | <Icon |
28 | 34 | icon="i-mdi-weather-night" |
29 | | - class="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 text-primary" |
| 35 | + class="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 {triggerClass}" |
30 | 36 | /> |
31 | 37 | <span class="sr-only">{$t`Choose theme`}</span> |
32 | 38 | </Button> |
|
0 commit comments