@immich/ui 0.17.1 → 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.
@@ -69,7 +69,7 @@
69
69
  <Label id={labelId} for={inputId} {label} {...labelProps} />
70
70
  {/if}
71
71
 
72
- <div class="relative mt-1.5 w-full">
72
+ <div class={cleanClass('relative w-full', label && 'mt-1.5')}>
73
73
  <input
74
74
  id={inputId}
75
75
  aria-labelledby={label && labelId}
@@ -16,5 +16,5 @@
16
16
  </script>
17
17
 
18
18
  <Button icon {...buttonProps} title={buttonTitle} aria-label={ariaLabel}>
19
- <Icon {icon} {flipped} {flopped} size="45%" aria-hidden />
19
+ <Icon {icon} {flipped} {flopped} size="60%" aria-hidden />
20
20
  </Button>
@@ -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 { HTMLInputAttributes } from 'svelte/elements';
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
- onToggle?: ((checked: boolean) => void) | undefined;
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
- class: className,
19
+ ref = $bindable(null),
21
20
  color = 'primary',
22
- onToggle = undefined,
23
- inputSize,
21
+ class: className,
24
22
  ...restProps
25
23
  }: Props = $props();
26
24
 
@@ -28,11 +26,6 @@
28
26
 
29
27
  const enabled = $derived(checked && !disabled);
30
28
 
31
- const handleToggle = () => {
32
- checked = !checked;
33
- onToggle?.(checked);
34
- };
35
-
36
29
  const wrapper = tv({
37
30
  base: 'relative flex flex-col justify-center',
38
31
  variants: {
@@ -48,7 +41,7 @@
48
41
  variants: {
49
42
  fillColor: {
50
43
  default: 'bg-gray-300 dark:bg-gray-400',
51
- primary: 'bg-primary/60',
44
+ primary: 'bg-primary',
52
45
  secondary: 'bg-dark/50',
53
46
  success: 'bg-success/50',
54
47
  danger: 'bg-danger/50',
@@ -67,7 +60,7 @@
67
60
  },
68
61
  fillColor: {
69
62
  default: 'bg-gray-400 dark:bg-gray-500',
70
- primary: 'bg-primary',
63
+ primary: 'bg-[#4250af]',
71
64
  secondary: 'bg-dark',
72
65
  success: 'bg-success',
73
66
  danger: 'bg-danger',
@@ -77,37 +70,32 @@
77
70
  },
78
71
  });
79
72
 
80
- const id = generateId();
81
73
  const inputId = `input-${id}`;
82
74
  const labelId = `label-${id}`;
83
75
  </script>
84
76
 
85
- <button
86
- class={cleanClass('flex justify-between gap-1', label && 'w-full')}
77
+ <Switch.Root
78
+ bind:checked
79
+ bind:ref
80
+ id={inputId}
87
81
  {disabled}
88
- onclick={handleToggle}
82
+ {required}
83
+ class={cleanClass(label && 'w-full', className)}
84
+ aria-readonly={readOnly}
85
+ aria-labelledby={labelId}
86
+ {...restProps}
89
87
  >
90
- {#if label}
91
- <Label id={labelId} for={inputId} {label} {...labelProps} />
92
- {/if}
93
-
94
- <span class={cleanClass(wrapper({ disabled }), className)}>
95
- <input
96
- id={inputId}
97
- aria-labelledby={label && labelId}
98
- class="hidden"
99
- type="checkbox"
100
- bind:checked
101
- {required}
102
- aria-required={required}
103
- {disabled}
104
- aria-disabled={disabled}
105
- readonly={readOnly}
106
- aria-readonly={readOnly}
107
- size={inputSize}
108
- {...restProps}
109
- />
110
- <span class={bar({ fillColor: enabled ? color : 'default' })}> </span>
111
- <span class={dot({ checked: enabled, fillColor: enabled ? color : 'default' })}></span>
112
- </span>
113
- </button>
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 { HTMLInputAttributes } from 'svelte/elements';
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
- onToggle?: ((checked: boolean) => void) | undefined;
9
- inputSize?: HTMLInputAttributes['size'];
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
- <Icon size="1.15rem" icon={leadingIcon} aria-hidden />
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="1.15rem" icon={trailingIcon} aria-hidden />
150
+ <Icon size="100%" class={iconSizes[size]} icon={trailingIcon} aria-hidden />
141
151
  {/if}
142
152
  {/snippet}
143
153
 
@@ -14,4 +14,5 @@ type ThemePreference = {
14
14
  };
15
15
  export declare const theme: ThemePreference;
16
16
  export declare const onThemeChange: () => void;
17
+ export declare const initializeTheme: (options?: ThemeOptions) => void;
17
18
  export {};
@@ -5,7 +5,7 @@ const defaultOptions = {
5
5
  darkClass: 'dark',
6
6
  selector: 'body',
7
7
  };
8
- let options = $state(defaultOptions);
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
- syncToDom();
59
+ export const initializeTheme = (options) => {
60
+ if (options) {
61
+ setThemeOptions(options);
62
+ }
63
+ syncToDom();
64
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immich/ui",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "license": "GNU Affero General Public License version 3",
5
5
  "scripts": {
6
6
  "create": "node scripts/create.js",