@manafishrov/ui 1.3.12 → 1.4.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@manafishrov/ui",
4
- "version": "1.3.12",
4
+ "version": "1.4.1",
5
5
  "description": "Styled component library for Manafish interfaces ",
6
6
  "license": "AGPL-3.0-or-later",
7
7
  "repository": {
@@ -8,11 +8,11 @@ import { type Component, type Accessor, Show } from 'solid-js';
8
8
  import { Portal } from 'solid-js/web';
9
9
  import { cn } from 'tailwind-variants';
10
10
  import CheckCircleIcon from '~icons/material-symbols/check-circle';
11
- import CloseIcon from '~icons/material-symbols/close';
12
11
  import ErrorIcon from '~icons/material-symbols/error';
13
12
  import InfoIcon from '~icons/material-symbols/info';
14
13
  import WarningIcon from '~icons/material-symbols/warning';
15
14
 
15
+ import { buttonVariants } from '@/components/Button';
16
16
  import { Spinner } from '@/components/Spinner';
17
17
 
18
18
  export const toast = createToaster({
@@ -21,44 +21,51 @@ export const toast = createToaster({
21
21
  gap: 16,
22
22
  });
23
23
 
24
+ const ToastIcon: Component<{ type: ToastOptions['type'] }> = (props) => (
25
+ <>
26
+ {props.type === 'success' && (
27
+ <CheckCircleIcon class={cn('size-4 shrink-0')} aria-hidden='true' />
28
+ )}
29
+ {props.type === 'info' && <InfoIcon class={cn('size-4 shrink-0')} aria-hidden='true' />}
30
+ {props.type === 'warning' && <WarningIcon class={cn('size-4 shrink-0')} aria-hidden='true' />}
31
+ {props.type === 'error' && <ErrorIcon class={cn('size-4 shrink-0')} aria-hidden='true' />}
32
+ {props.type === 'loading' && <Spinner class={cn('size-4 text-muted-foreground')} />}
33
+ </>
34
+ );
35
+
24
36
  const ToastItem: Component<{ toast: Accessor<ToastOptions> }> = (props) => (
25
37
  <Toast.Root
26
38
  class={cn(
27
- 'group gap-3 p-4 pr-10 shadow-lg min-w-72 pointer-events-auto relative flex w-full items-center rounded-lg border bg-popover',
28
- 'data-[state=open]:sm:slide-in-from-bottom-full data-[state=open]:animate-in data-[state=open]:slide-in-from-top-full',
39
+ 'group gap-2 px-4 py-3.5 shadow-lg min-w-80 ease-in-out pointer-events-auto relative flex w-full items-center rounded-xl border bg-popover',
29
40
  'border-border text-popover-foreground',
30
41
  )}
31
42
  >
32
- <Show when={props.toast().type === 'success'}>
33
- <CheckCircleIcon class={cn('size-5 text-green-500 shrink-0')} aria-hidden='true' />
34
- </Show>
35
- <Show when={props.toast().type === 'info'}>
36
- <InfoIcon class={cn('size-5 text-blue-500 shrink-0')} aria-hidden='true' />
37
- </Show>
38
- <Show when={props.toast().type === 'warning'}>
39
- <WarningIcon class={cn('size-5 text-amber-500 shrink-0')} aria-hidden='true' />
40
- </Show>
41
- <Show when={props.toast().type === 'error'}>
42
- <ErrorIcon class={cn('size-5 text-red-500 shrink-0')} aria-hidden='true' />
43
- </Show>
44
- <Show when={props.toast().type === 'loading'}>
45
- <Spinner class={cn('size-5 text-muted-foreground')} />
46
- </Show>
47
- <div class='gap-1 grid'>
43
+ <ToastIcon type={props.toast().type} />
44
+ <div class='min-w-0 gap-1 grid flex-1'>
48
45
  <Show when={props.toast().title}>
49
46
  <Toast.Title class='text-sm font-semibold tracking-tight leading-none'>
50
47
  {props.toast().title}
51
48
  </Toast.Title>
52
49
  </Show>
53
- <Show when={props.toast().description} fallback={<div aria-hidden='true' class='h-5' />}>
54
- <Toast.Description class='text-sm opacity-90'>
50
+ <Show when={props.toast().description}>
51
+ <Toast.Description class='text-sm text-muted-foreground'>
55
52
  {props.toast().description}
56
53
  </Toast.Description>
57
54
  </Show>
58
55
  </div>
59
- <Toast.CloseTrigger class='top-2 right-2 p-1 absolute cursor-pointer rounded-md text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 hover:text-foreground focus:opacity-100 focus:outline-none'>
60
- <CloseIcon class='size-4' />
61
- </Toast.CloseTrigger>
56
+ <Show when={props.toast().action}>
57
+ {(action) => (
58
+ <Toast.ActionTrigger
59
+ class={buttonVariants({
60
+ class: 'shrink-0',
61
+ size: 'sm',
62
+ variant: 'secondary',
63
+ })}
64
+ >
65
+ {action().label}
66
+ </Toast.ActionTrigger>
67
+ )}
68
+ </Show>
62
69
  </Toast.Root>
63
70
  );
64
71
 
@@ -4,7 +4,7 @@
4
4
  z-index: var(--z-index);
5
5
  height: var(--height);
6
6
  opacity: var(--opacity);
7
- will-change: translate, opacity, scale, height;
7
+ will-change: translate, opacity, scale;
8
8
  transition:
9
9
  translate 400ms,
10
10
  scale 400ms,
@@ -12,12 +12,12 @@
12
12
  height 400ms,
13
13
  box-shadow 200ms;
14
14
  transition-timing-function: cubic-bezier(0.21, 1.02, 0.73, 1);
15
- }
16
15
 
17
- [data-scope='toast'][data-part='root'][data-state='closed'] {
18
- transition:
19
- translate 400ms,
20
- scale 400ms,
21
- opacity 200ms;
22
- transition-timing-function: cubic-bezier(0.06, 0.71, 0.55, 1);
16
+ &[data-state='closed'] {
17
+ transition:
18
+ translate 400ms,
19
+ scale 400ms,
20
+ opacity 200ms;
21
+ transition-timing-function: cubic-bezier(0.06, 0.71, 0.55, 1);
22
+ }
23
23
  }