Skip to content

Commit

Permalink
fix: theme switcher color (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Jan 14, 2025
1 parent 74f58a4 commit 7927688
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/lib/components/ThemeSwitcher/ThemeSwitcher.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<script lang="ts">
import IconButton from '$lib/components/IconButton/IconButton.svelte';
import { theme } from '$lib/services/theme.svelte.js';
import { Theme, type Size, type Variants } from '$lib/types.js';
import { Theme, type Color, type Size, type Variants } from '$lib/types.js';
import { cleanClass } from '$lib/utils.js';
import { mdiWeatherNight, mdiWeatherSunny } from '@mdi/js';
type Props = {
size?: Size;
class?: string;
color?: Color;
variant?: Variants;
onChange?: (theme: Theme) => void;
};
const { variant = 'ghost', size, class: className, onChange }: Props = $props();
const {
color = 'primary',
variant = 'ghost',
size,
class: className,
onChange,
}: Props = $props();
const handleToggleTheme = () => {
theme.value = theme.value === Theme.Dark ? Theme.Light : Theme.Dark;
Expand All @@ -24,7 +31,7 @@

<IconButton
shape="round"
color="primary"
{color}
{size}
{variant}
icon={themeIcon}
Expand Down
3 changes: 3 additions & 0 deletions src/routes/components/theme-switcher/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import ComponentPage from '$docs/components/ComponentPage.svelte';
import BasicExample from './BasicExample.svelte';
import basicExample from './BasicExample.svelte?raw';
import ColorExample from './ColorExample.svelte';
import colorExample from './ColorExample.svelte?raw';
import SizeExample from './SizeExample.svelte';
import sizeExample from './SizeExample.svelte?raw';
import VariantExample from './VariantExample.svelte';
Expand All @@ -14,6 +16,7 @@
examples={[
{ title: 'Basic', code: basicExample, component: BasicExample },
{ title: 'Size', code: sizeExample, component: SizeExample },
{ title: 'Color', code: colorExample, component: ColorExample },
{ title: 'Variant', code: variantExample, component: VariantExample },
]}
/>
Expand Down
12 changes: 12 additions & 0 deletions src/routes/components/theme-switcher/ColorExample.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import { HStack, ThemeSwitcher } from '@immich/ui';
</script>

<HStack>
<ThemeSwitcher color="primary" />
<ThemeSwitcher color="secondary" />
<ThemeSwitcher color="success" />
<ThemeSwitcher color="warning" />
<ThemeSwitcher color="danger" />
<ThemeSwitcher color="info" />
</HStack>
6 changes: 3 additions & 3 deletions src/routes/components/theme-switcher/SizeExample.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Stack, ThemeSwitcher } from '@immich/ui';
import { HStack, ThemeSwitcher } from '@immich/ui';
</script>

<Stack>
<HStack>
<ThemeSwitcher size="tiny" />
<ThemeSwitcher size="small" />
<ThemeSwitcher size="medium" />
<ThemeSwitcher size="large" />
<ThemeSwitcher size="giant" />
</Stack>
</HStack>

0 comments on commit 7927688

Please sign in to comment.