@immich/ui 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Form/Input.svelte +1 -1
- package/dist/components/IconButton/IconButton.svelte +1 -1
- package/dist/components/Switch/Switch.svelte +32 -38
- package/dist/components/Switch/Switch.svelte.d.ts +3 -5
- package/dist/internal/Button.svelte +12 -2
- package/dist/services/theme.svelte.d.ts +1 -0
- package/dist/services/theme.svelte.js +7 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import Label from '../Label/Label.svelte';
|
|
4
4
|
import type { Color } from '../../types.js';
|
|
5
5
|
import { cleanClass, generateId } from '../../utils.js';
|
|
6
|
-
import type
|
|
6
|
+
import { Switch, type WithoutChildrenOrChild } from 'bits-ui';
|
|
7
7
|
import { tv } from 'tailwind-variants';
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
@@ -11,16 +11,14 @@
|
|
|
11
11
|
color?: Color;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
class?: string;
|
|
14
|
-
|
|
15
|
-
inputSize?: HTMLInputAttributes['size'];
|
|
16
|
-
} & Omit<HTMLInputAttributes, 'size'>;
|
|
14
|
+
} & WithoutChildrenOrChild<Switch.RootProps>;
|
|
17
15
|
|
|
18
16
|
let {
|
|
17
|
+
id = generateId(),
|
|
19
18
|
checked = $bindable(false),
|
|
20
|
-
|
|
19
|
+
ref = $bindable(null),
|
|
21
20
|
color = 'primary',
|
|
22
|
-
|
|
23
|
-
inputSize,
|
|
21
|
+
class: className,
|
|
24
22
|
...restProps
|
|
25
23
|
}: Props = $props();
|
|
26
24
|
|
|
@@ -28,8 +26,6 @@
|
|
|
28
26
|
|
|
29
27
|
const enabled = $derived(checked && !disabled);
|
|
30
28
|
|
|
31
|
-
const handleToggle = (event: Event) => onToggle?.((event.target as HTMLInputElement).checked);
|
|
32
|
-
|
|
33
29
|
const wrapper = tv({
|
|
34
30
|
base: 'relative flex flex-col justify-center',
|
|
35
31
|
variants: {
|
|
@@ -45,7 +41,7 @@
|
|
|
45
41
|
variants: {
|
|
46
42
|
fillColor: {
|
|
47
43
|
default: 'bg-gray-300 dark:bg-gray-400',
|
|
48
|
-
primary: 'bg-primary
|
|
44
|
+
primary: 'bg-primary',
|
|
49
45
|
secondary: 'bg-dark/50',
|
|
50
46
|
success: 'bg-success/50',
|
|
51
47
|
danger: 'bg-danger/50',
|
|
@@ -64,7 +60,7 @@
|
|
|
64
60
|
},
|
|
65
61
|
fillColor: {
|
|
66
62
|
default: 'bg-gray-400 dark:bg-gray-500',
|
|
67
|
-
primary: 'bg-
|
|
63
|
+
primary: 'bg-[#4250af]',
|
|
68
64
|
secondary: 'bg-dark',
|
|
69
65
|
success: 'bg-success',
|
|
70
66
|
danger: 'bg-danger',
|
|
@@ -74,34 +70,32 @@
|
|
|
74
70
|
},
|
|
75
71
|
});
|
|
76
72
|
|
|
77
|
-
const id = generateId();
|
|
78
73
|
const inputId = `input-${id}`;
|
|
79
74
|
const labelId = `label-${id}`;
|
|
80
75
|
</script>
|
|
81
76
|
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
</div>
|
|
77
|
+
<Switch.Root
|
|
78
|
+
bind:checked
|
|
79
|
+
bind:ref
|
|
80
|
+
id={inputId}
|
|
81
|
+
{disabled}
|
|
82
|
+
{required}
|
|
83
|
+
class={cleanClass(label && 'w-full', className)}
|
|
84
|
+
aria-readonly={readOnly}
|
|
85
|
+
aria-labelledby={labelId}
|
|
86
|
+
{...restProps}
|
|
87
|
+
>
|
|
88
|
+
<Switch.Thumb>
|
|
89
|
+
{#snippet child()}
|
|
90
|
+
<div class={cleanClass(label && 'flex justify-between gap-1')}>
|
|
91
|
+
{#if label}
|
|
92
|
+
<Label id={labelId} for={inputId} {label} {...labelProps} />
|
|
93
|
+
{/if}
|
|
94
|
+
<span class={wrapper({ disabled })}>
|
|
95
|
+
<span class={bar({ fillColor: enabled ? color : 'default' })}> </span>
|
|
96
|
+
<span class={dot({ checked: enabled, fillColor: enabled ? color : 'default' })}></span>
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
{/snippet}
|
|
100
|
+
</Switch.Thumb>
|
|
101
|
+
</Switch.Root>
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Color } from '../../types.js';
|
|
2
|
-
import type
|
|
2
|
+
import { Switch, type WithoutChildrenOrChild } from 'bits-ui';
|
|
3
3
|
type Props = {
|
|
4
4
|
checked?: boolean;
|
|
5
5
|
color?: Color;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
class?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} & Omit<HTMLInputAttributes, 'size'>;
|
|
11
|
-
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
8
|
+
} & WithoutChildrenOrChild<Switch.RootProps>;
|
|
9
|
+
declare const Switch: import("svelte").Component<Props, {}, "checked" | "ref">;
|
|
12
10
|
type Switch = ReturnType<typeof Switch>;
|
|
13
11
|
export default Switch;
|
|
@@ -129,15 +129,25 @@
|
|
|
129
129
|
),
|
|
130
130
|
),
|
|
131
131
|
);
|
|
132
|
+
|
|
133
|
+
const iconSizes = {
|
|
134
|
+
tiny: 'h-4 w-4',
|
|
135
|
+
small: 'h-4 w-4',
|
|
136
|
+
medium: 'h-4 w-4',
|
|
137
|
+
large: 'h-6 w-6',
|
|
138
|
+
giant: 'h-8 w-8',
|
|
139
|
+
};
|
|
132
140
|
</script>
|
|
133
141
|
|
|
134
142
|
{#snippet content()}
|
|
135
143
|
{#if leadingIcon && !loading}
|
|
136
|
-
<
|
|
144
|
+
<div>
|
|
145
|
+
<Icon size="100%" class={iconSizes[size]} icon={leadingIcon} aria-hidden />
|
|
146
|
+
</div>
|
|
137
147
|
{/if}
|
|
138
148
|
{@render children?.()}
|
|
139
149
|
{#if trailingIcon}
|
|
140
|
-
<Icon size="
|
|
150
|
+
<Icon size="100%" class={iconSizes[size]} icon={trailingIcon} aria-hidden />
|
|
141
151
|
{/if}
|
|
142
152
|
{/snippet}
|
|
143
153
|
|
|
@@ -5,7 +5,7 @@ const defaultOptions = {
|
|
|
5
5
|
darkClass: 'dark',
|
|
6
6
|
selector: 'body',
|
|
7
7
|
};
|
|
8
|
-
let options =
|
|
8
|
+
let options = defaultOptions;
|
|
9
9
|
export const setThemeOptions = (newOptions) => (options = { ...defaultOptions, ...newOptions });
|
|
10
10
|
const defaultTheme = { value: Theme.Dark };
|
|
11
11
|
const { state, sync: syncToLocalStorage } = preference({
|
|
@@ -56,4 +56,9 @@ const syncToDom = () => {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
export const initializeTheme = (options) => {
|
|
60
|
+
if (options) {
|
|
61
|
+
setThemeOptions(options);
|
|
62
|
+
}
|
|
63
|
+
syncToDom();
|
|
64
|
+
};
|