@immich/ui 0.8.0 → 0.9.0

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.
@@ -3,7 +3,8 @@
3
3
  import CardHeader from '../Card/CardHeader.svelte';
4
4
  import Icon from '../Icon/Icon.svelte';
5
5
  import Text from '../Text/Text.svelte';
6
- import type { Color } from '../../types.js';
6
+ import CloseButton from '../CloseButton/CloseButton.svelte';
7
+ import type { Color, Size } from '../../types.js';
7
8
  import { cleanClass } from '../../utils.js';
8
9
  import {
9
10
  mdiAlertOutline,
@@ -15,13 +16,55 @@
15
16
 
16
17
  type Props = {
17
18
  color?: Color;
19
+ size?: Size;
18
20
  icon?: string | false;
19
21
  title?: string;
20
22
  class?: string;
23
+ duration?: number;
24
+ closable?: boolean;
25
+ controlled?: boolean;
26
+ onClose?: () => void;
21
27
  children?: Snippet;
22
28
  };
23
29
 
24
- const { color = 'info', icon: iconOverride, title, class: className, children }: Props = $props();
30
+ const {
31
+ color = 'primary',
32
+ icon: iconOverride,
33
+ size = 'large',
34
+ title,
35
+ class: className,
36
+ duration,
37
+ controlled,
38
+ closable,
39
+ onClose,
40
+ children,
41
+ }: Props = $props();
42
+
43
+ let open = $state(true);
44
+
45
+ const iconSizes: Record<Size, string> = {
46
+ tiny: '1em',
47
+ small: '1.25em',
48
+ medium: '1.5em',
49
+ large: '1.75em',
50
+ giant: '1.85em',
51
+ };
52
+
53
+ const handleClose = () => {
54
+ if (!open) {
55
+ return;
56
+ }
57
+
58
+ if (!controlled) {
59
+ open = false;
60
+ }
61
+
62
+ onClose?.();
63
+ };
64
+
65
+ if (duration) {
66
+ setTimeout(handleClose, duration);
67
+ }
25
68
 
26
69
  const icons: Partial<Record<Color, string>> = {
27
70
  success: mdiCheckCircleOutline,
@@ -34,23 +77,32 @@
34
77
  );
35
78
  </script>
36
79
 
37
- <Card {color} variant="subtle" class={cleanClass(className)}>
38
- <CardHeader>
39
- <div class={cleanClass('flex gap-2')}>
40
- {#if icon}
41
- <div>
42
- <Icon {icon} size="1.5em" class="h-7" />
43
- </div>
44
- {/if}
80
+ {#if open}
81
+ <Card {color} variant="subtle" class={cleanClass(className)}>
82
+ <CardHeader>
83
+ <div class="flex justify-between">
84
+ <div class={cleanClass('flex gap-2')}>
85
+ {#if icon}
86
+ <div>
87
+ <Icon {icon} size={iconSizes[size]} />
88
+ </div>
89
+ {/if}
45
90
 
46
- <div class="flex flex-col gap-2">
47
- {#if title}
48
- <Text size="large" fontWeight={children ? 'bold' : undefined}>{title}</Text>
49
- {/if}
50
- {#if children}
51
- {@render children()}
91
+ <div class="flex flex-col gap-2">
92
+ {#if title}
93
+ <Text {size} fontWeight={children ? 'bold' : undefined}>{title}</Text>
94
+ {/if}
95
+ {#if children}
96
+ {@render children()}
97
+ {/if}
98
+ </div>
99
+ </div>
100
+ {#if closable || onClose}
101
+ <div>
102
+ <CloseButton onclick={handleClose} />
103
+ </div>
52
104
  {/if}
53
105
  </div>
54
- </div>
55
- </CardHeader>
56
- </Card>
106
+ </CardHeader>
107
+ </Card>
108
+ {/if}
@@ -1,10 +1,15 @@
1
- import type { Color } from '../../types.js';
1
+ import type { Color, Size } from '../../types.js';
2
2
  import type { Snippet } from 'svelte';
3
3
  declare const Alert: import("svelte").Component<{
4
4
  color?: Color;
5
+ size?: Size;
5
6
  icon?: string | false;
6
7
  title?: string;
7
8
  class?: string;
9
+ duration?: number;
10
+ closable?: boolean;
11
+ controlled?: boolean;
12
+ onClose?: () => void;
8
13
  children?: Snippet;
9
14
  }, {}, "">;
10
15
  export default Alert;
@@ -44,9 +44,9 @@
44
44
  },
45
45
  subtleColor: {
46
46
  primary: 'bg-primary/25 dark:bg-primary/25',
47
- secondary: 'bg-dark/15 text-dark',
47
+ secondary: 'bg-dark/5 dark:bg-dark/25 text-dark',
48
48
  success: 'bg-success/15 dark:bg-success/30',
49
- danger: 'bg-danger/25 dark:bg-danger/50',
49
+ danger: 'bg-danger/15 dark:bg-danger/50',
50
50
  warning: 'bg-warning/25 dark:bg-warning/50',
51
51
  info: 'bg-info/25 dark:bg-info/50',
52
52
  },
@@ -3,7 +3,7 @@
3
3
  import type { CloseButtonProps } from '../../types.js';
4
4
  import { mdiClose } from '@mdi/js';
5
5
 
6
- const { size = 'medium', variant = 'ghost' }: CloseButtonProps = $props();
6
+ const { size = 'medium', variant = 'ghost', ...restProps }: CloseButtonProps = $props();
7
7
  </script>
8
8
 
9
- <IconButton icon={mdiClose} color="secondary" shape="round" {variant} {size} />
9
+ <IconButton {...restProps} icon={mdiClose} shape="round" {variant} {size} color="secondary" />
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
- import type { Color, Size } from '../../types.js';
2
+ import type { Size, TextColor } from '../../types.js';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { tv } from 'tailwind-variants';
5
5
 
6
6
  type Props = {
7
- color?: Color | 'muted';
7
+ color?: TextColor;
8
8
  size?: Size;
9
9
  variant?: 'filled';
10
10
  children: Snippet;
@@ -1,7 +1,7 @@
1
- import type { Color, Size } from '../../types.js';
1
+ import type { Size, TextColor } from '../../types.js';
2
2
  import type { Snippet } from 'svelte';
3
3
  declare const Code: import("svelte").Component<{
4
- color?: Color | "muted";
4
+ color?: TextColor;
5
5
  size?: Size;
6
6
  variant?: "filled";
7
7
  children: Snippet;
@@ -2,17 +2,17 @@
2
2
  import Text from '../Text/Text.svelte';
3
3
  import { ChildKey } from '../../constants.js';
4
4
  import Child from '../../internal/Child.svelte';
5
- import type { Color } from '../../types.js';
5
+ import type { TextColor } from '../../types.js';
6
6
  import { cleanClass } from '../../utils.js';
7
7
  import type { Snippet } from 'svelte';
8
8
 
9
9
  type Props = {
10
- color?: Color;
10
+ color?: TextColor;
11
11
  class?: string;
12
12
  children?: Snippet;
13
13
  };
14
14
 
15
- let { class: className, children, color }: Props = $props();
15
+ let { class: className, children, color = 'muted' }: Props = $props();
16
16
  </script>
17
17
 
18
18
  <Child for={ChildKey.Field} as={ChildKey.HelperText}>
@@ -1,7 +1,7 @@
1
- import type { Color } from '../../types.js';
1
+ import type { TextColor } from '../../types.js';
2
2
  import type { Snippet } from 'svelte';
3
3
  declare const HelperText: import("svelte").Component<{
4
- color?: Color;
4
+ color?: TextColor;
5
5
  class?: string;
6
6
  children?: Snippet;
7
7
  }, {}, "">;
@@ -1,12 +1,12 @@
1
1
  <script lang="ts">
2
- import type { Color, HeadingSize } from '../../types.js';
2
+ import type { HeadingColor, HeadingSize } from '../../types.js';
3
3
  import { cleanClass } from '../../utils.js';
4
4
  import type { Snippet } from 'svelte';
5
5
  import { tv } from 'tailwind-variants';
6
6
 
7
7
  type Props = {
8
8
  size: HeadingSize;
9
- color?: Color | 'muted';
9
+ color?: HeadingColor;
10
10
  class?: string;
11
11
 
12
12
  children: Snippet;
@@ -1,8 +1,8 @@
1
- import type { Color, HeadingSize } from '../../types.js';
1
+ import type { HeadingColor, HeadingSize } from '../../types.js';
2
2
  import type { Snippet } from 'svelte';
3
3
  declare const Heading: import("svelte").Component<{
4
4
  size: HeadingSize;
5
- color?: Color | "muted";
5
+ color?: HeadingColor;
6
6
  class?: string;
7
7
  children: Snippet;
8
8
  }, {}, "">;
@@ -1,11 +1,11 @@
1
1
  <script lang="ts">
2
- import type { Color, Size } from '../../types.js';
2
+ import type { Size, TextColor } from '../../types.js';
3
3
  import { cleanClass } from '../../utils.js';
4
4
  import type { Snippet } from 'svelte';
5
5
  import { tv } from 'tailwind-variants';
6
6
 
7
7
  type Props = {
8
- color?: Color | 'muted';
8
+ color?: TextColor;
9
9
  class?: string;
10
10
  size?: Size;
11
11
  children: Snippet;
@@ -1,7 +1,7 @@
1
- import type { Color, Size } from '../../types.js';
1
+ import type { Size, TextColor } from '../../types.js';
2
2
  import type { Snippet } from 'svelte';
3
3
  declare const Text: import("svelte").Component<{
4
- color?: Color | "muted";
4
+ color?: TextColor;
5
5
  class?: string;
6
6
  size?: Size;
7
7
  children: Snippet;
package/dist/types.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAnchorAttributes, HTMLButtonAttributes, HTMLInputAttributes } from 'svelte/elements';
3
3
  export type Color = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
4
+ export type TextColor = Color | 'muted';
5
+ export type HeadingColor = TextColor;
4
6
  export type Size = 'tiny' | 'small' | 'medium' | 'large' | 'giant';
5
7
  export type HeadingSize = Size | 'title';
6
8
  export type Shape = 'rectangle' | 'semi-round' | 'round';
@@ -10,20 +12,6 @@ export declare enum Theme {
10
12
  Light = "light",
11
13
  Dark = "dark"
12
14
  }
13
- type ButtonOrAnchor = ({
14
- href?: never;
15
- } & HTMLButtonAttributes) | ({
16
- href: string;
17
- } & HTMLAnchorAttributes);
18
- export type CloseButtonProps = {
19
- size?: Size;
20
- variant?: Variants;
21
- };
22
- type ButtonBaseProps = CloseButtonProps & {
23
- class?: string;
24
- color?: Color;
25
- shape?: Shape;
26
- } & ButtonOrAnchor;
27
15
  export type IconProps = {
28
16
  icon: string;
29
17
  title?: string;
@@ -38,11 +26,32 @@ export type IconProps = {
38
26
  strokeWidth?: number;
39
27
  strokeColor?: string;
40
28
  };
41
- export type IconButtonProps = ButtonBaseProps & IconProps;
42
- export type ButtonProps = ButtonBaseProps & {
29
+ type ButtonOrAnchor = ({
30
+ href?: never;
31
+ } & HTMLButtonAttributes) | ({
32
+ href: string;
33
+ } & HTMLAnchorAttributes);
34
+ type ButtonBase = {
35
+ size?: Size;
36
+ variant?: Variants;
37
+ class?: string;
38
+ color?: Color;
39
+ shape?: Shape;
40
+ };
41
+ export type ButtonProps = ButtonBase & {
43
42
  fullWidth?: boolean;
44
43
  loading?: boolean;
45
- };
44
+ } & ButtonOrAnchor;
45
+ export type CloseButtonProps = {
46
+ size?: Size;
47
+ variant?: Variants;
48
+ class?: string;
49
+ } & ButtonOrAnchor;
50
+ export type IconButtonProps = ButtonBase & {
51
+ icon: string;
52
+ flipped?: boolean;
53
+ flopped?: boolean;
54
+ } & ButtonOrAnchor;
46
55
  type StackBaseProps = {
47
56
  class?: string;
48
57
  children: Snippet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immich/ui",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "license": "GNU Affero General Public License version 3",
5
5
  "scripts": {
6
6
  "create": "node scripts/create.js",