@balikjs/mobile 0.0.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/README.md +33 -0
- package/dist/mobile.js +3062 -0
- package/dist/styles.css +1 -0
- package/package.json +49 -0
- package/src/Alert/Alert.jsx +67 -0
- package/src/Alert/Alert.module.css +87 -0
- package/src/Alert/index.js +1 -0
- package/src/Avatar/Avatar.jsx +77 -0
- package/src/Avatar/Avatar.module.css +74 -0
- package/src/Avatar/index.js +1 -0
- package/src/Badge/Badge.jsx +83 -0
- package/src/Badge/Badge.module.css +141 -0
- package/src/Badge/index.js +1 -0
- package/src/BottomNavigation/BottomNavigation.jsx +61 -0
- package/src/BottomNavigation/BottomNavigation.module.css +53 -0
- package/src/BottomNavigation/index.js +1 -0
- package/src/BottomSheet/BottomSheet.jsx +51 -0
- package/src/BottomSheet/BottomSheet.module.css +56 -0
- package/src/BottomSheet/index.js +1 -0
- package/src/Button/Button.jsx +77 -0
- package/src/Button/Button.module.css +124 -0
- package/src/Button/index.js +1 -0
- package/src/Card/Card.jsx +31 -0
- package/src/Card/Card.module.css +4 -0
- package/src/Card/index.js +1 -0
- package/src/Checkbox/Checkbox.jsx +64 -0
- package/src/Checkbox/Checkbox.module.css +146 -0
- package/src/Checkbox/index.js +1 -0
- package/src/Clipboard/Clipboard.jsx +82 -0
- package/src/Clipboard/Clipboard.module.css +126 -0
- package/src/Clipboard/index.js +1 -0
- package/src/CloseButton/CloseButton.jsx +51 -0
- package/src/CloseButton/CloseButton.module.css +94 -0
- package/src/Confirm/Confirm.jsx +52 -0
- package/src/Confirm/Confirm.module.css +5 -0
- package/src/Confirm/index.js +1 -0
- package/src/Dialog/Dialog.jsx +63 -0
- package/src/Dialog/Dialog.module.css +111 -0
- package/src/Dialog/index.js +1 -0
- package/src/Divider/Divider.jsx +38 -0
- package/src/Divider/Divider.module.css +16 -0
- package/src/Divider/index.js +1 -0
- package/src/Drawer/Drawer.jsx +55 -0
- package/src/Drawer/Drawer.module.css +68 -0
- package/src/Drawer/index.js +1 -0
- package/src/Empty/Empty.jsx +35 -0
- package/src/Empty/Empty.module.css +17 -0
- package/src/Empty/index.js +1 -0
- package/src/Fab/Fab.jsx +91 -0
- package/src/Fab/Fab.module.css +94 -0
- package/src/Fab/index.js +1 -0
- package/src/Input/Input.jsx +53 -0
- package/src/Input/Input.module.css +97 -0
- package/src/Input/index.js +1 -0
- package/src/Link/Link.jsx +31 -0
- package/src/Link/Link.module.css +18 -0
- package/src/Link/index.js +1 -0
- package/src/Popover/Popover.jsx +162 -0
- package/src/Popover/Popover.module.css +63 -0
- package/src/Popover/index.js +1 -0
- package/src/RadioGroup/Radio.jsx +52 -0
- package/src/RadioGroup/Radio.module.css +133 -0
- package/src/RadioGroup/RadioGroup.jsx +36 -0
- package/src/RadioGroup/RadioGroup.module.css +23 -0
- package/src/RadioGroup/index.js +2 -0
- package/src/SearchInput/SearchInput.jsx +89 -0
- package/src/SearchInput/SearchInput.module.css +169 -0
- package/src/SearchInput/index.js +1 -0
- package/src/Select/Select.jsx +101 -0
- package/src/Select/Select.module.css +174 -0
- package/src/Select/index.js +1 -0
- package/src/SelectPc/Select.jsx +88 -0
- package/src/SelectPc/SelectPc.module.css +132 -0
- package/src/SelectPc/index.js +1 -0
- package/src/Skeleton/Skeleton.jsx +55 -0
- package/src/Skeleton/Skeleton.module.css +33 -0
- package/src/Skeleton/index.js +1 -0
- package/src/Slider/Slider.jsx +50 -0
- package/src/Slider/Slider.module.css +77 -0
- package/src/Slider/index.js +1 -0
- package/src/Spinner/Spinner.jsx +45 -0
- package/src/Spinner/Spinner.module.css +35 -0
- package/src/Spinner/index.js +1 -0
- package/src/Switch/Switch.jsx +51 -0
- package/src/Switch/Switch.module.css +156 -0
- package/src/Switch/index.js +1 -0
- package/src/Tabs/Tabs.jsx +75 -0
- package/src/Tabs/Tabs.module.css +45 -0
- package/src/Tabs/index.js +1 -0
- package/src/Tag/Tag.jsx +74 -0
- package/src/Tag/Tag.module.css +128 -0
- package/src/Tag/index.js +1 -0
- package/src/Textarea/Textarea.jsx +52 -0
- package/src/Textarea/Textarea.module.css +89 -0
- package/src/Textarea/index.js +1 -0
- package/src/Toast/Toast.jsx +169 -0
- package/src/Toast/Toast.module.css +152 -0
- package/src/Toast/index.js +1 -0
- package/src/Tooltip/Tooltip.jsx +42 -0
- package/src/Tooltip/Tooltip.module.css +41 -0
- package/src/Tooltip/index.js +1 -0
- package/src/index.js +34 -0
- package/src/styles/index.css +90 -0
- package/src/styles/tokens.css +227 -0
package/src/Tag/Tag.jsx
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { splitProps, mergeProps } from 'solid-js'
|
|
2
|
+
import { CloseButton } from '../CloseButton/CloseButton.jsx'
|
|
3
|
+
import styles from './Tag.module.css'
|
|
4
|
+
|
|
5
|
+
const variants = {
|
|
6
|
+
solid: styles.solid,
|
|
7
|
+
outline: styles.outline,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const intents = {
|
|
11
|
+
default: styles.intentDefault,
|
|
12
|
+
success: styles.intentSuccess,
|
|
13
|
+
warning: styles.intentWarning,
|
|
14
|
+
danger: styles.intentDanger,
|
|
15
|
+
info: styles.intentInfo,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const sizes = {
|
|
19
|
+
xs: styles.sizeXs,
|
|
20
|
+
sm: styles.sizeSm,
|
|
21
|
+
md: styles.sizeMd,
|
|
22
|
+
lg: styles.sizeLg,
|
|
23
|
+
xl: styles.sizeXl,
|
|
24
|
+
'2xl': styles.size2xl,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const DEFAULT_PROPS = {
|
|
28
|
+
variant: 'solid',
|
|
29
|
+
intent: 'default',
|
|
30
|
+
size: 'sm',
|
|
31
|
+
closable: false,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {import('solid-js').JSX.HTMLAttributes<HTMLSpanElement> & {
|
|
36
|
+
* variant?: 'solid' | 'outline'
|
|
37
|
+
* intent?: 'default' | 'success' | 'warning' | 'danger' | 'info'
|
|
38
|
+
* size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
|
|
39
|
+
* closable?: boolean
|
|
40
|
+
* onClose?: () => void
|
|
41
|
+
* class?: string
|
|
42
|
+
* children?: import('solid-js').JSX.Element
|
|
43
|
+
* }} props
|
|
44
|
+
*/
|
|
45
|
+
export function Tag(props) {
|
|
46
|
+
const [local, rest] = splitProps(
|
|
47
|
+
mergeProps(DEFAULT_PROPS, props),
|
|
48
|
+
['variant', 'intent', 'size', 'closable', 'onClose', 'class', 'children'],
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<span
|
|
53
|
+
{...rest}
|
|
54
|
+
class={[
|
|
55
|
+
'balik-tag',
|
|
56
|
+
`balik-tag--${local.variant}`,
|
|
57
|
+
`balik-tag--${local.intent}`,
|
|
58
|
+
`balik-tag--${local.size}`,
|
|
59
|
+
styles.base,
|
|
60
|
+
variants[local.variant],
|
|
61
|
+
intents[local.intent],
|
|
62
|
+
sizes[local.size],
|
|
63
|
+
local.class,
|
|
64
|
+
]
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join(' ')}
|
|
67
|
+
>
|
|
68
|
+
{local.children}
|
|
69
|
+
{local.closable && (
|
|
70
|
+
<CloseButton size="xs" rounded class={styles.close} onClick={(e) => { e.stopPropagation(); local.onClose?.() }} />
|
|
71
|
+
)}
|
|
72
|
+
</span>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
.base {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 4px;
|
|
5
|
+
white-space: nowrap;
|
|
6
|
+
user-select: none;
|
|
7
|
+
border-radius: var(--b-radius-round);
|
|
8
|
+
font-family: inherit;
|
|
9
|
+
line-height: 1;
|
|
10
|
+
transition: background-color var(--b-transition-fast),
|
|
11
|
+
color var(--b-transition-fast),
|
|
12
|
+
border-color var(--b-transition-fast);
|
|
13
|
+
|
|
14
|
+
--_current-bg: var(--base-edge);
|
|
15
|
+
--_current-fg: var(--base-edge);
|
|
16
|
+
--_current-border: var(--base-edge);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.solid {
|
|
20
|
+
background-color: var(--_current-bg);
|
|
21
|
+
color: var(--base-bg);
|
|
22
|
+
border: 1px solid transparent;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.outline {
|
|
26
|
+
background-color: transparent;
|
|
27
|
+
color: var(--_current-fg);
|
|
28
|
+
border: 1px solid var(--_current-border);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.intentDefault {
|
|
32
|
+
--_current-bg: color-mix(in oklch, var(--base-fg) 10%, var(--base-bg));
|
|
33
|
+
--_current-fg: var(--base-fg);
|
|
34
|
+
--_current-border: var(--base-edge);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.intentSuccess {
|
|
38
|
+
--_current-bg: var(--color-success);
|
|
39
|
+
--_current-fg: var(--color-success);
|
|
40
|
+
--_current-border: var(--color-success);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.intentWarning {
|
|
44
|
+
--_current-bg: var(--color-warning);
|
|
45
|
+
--_current-fg: var(--color-warning);
|
|
46
|
+
--_current-border: var(--color-warning);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.intentDanger {
|
|
50
|
+
--_current-bg: var(--color-danger);
|
|
51
|
+
--_current-fg: var(--color-danger);
|
|
52
|
+
--_current-border: var(--color-danger);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.intentInfo {
|
|
56
|
+
--_current-bg: var(--color-info);
|
|
57
|
+
--_current-fg: var(--color-info);
|
|
58
|
+
--_current-border: var(--color-info);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.close {
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
padding: 0;
|
|
66
|
+
margin: 0;
|
|
67
|
+
margin-right: -2px;
|
|
68
|
+
border: none;
|
|
69
|
+
background: none;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
border-radius: var(--b-radius-round);
|
|
72
|
+
opacity: 0.6;
|
|
73
|
+
transition: opacity var(--b-transition-fast);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.close:hover {
|
|
77
|
+
opacity: 1;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.solid .close {
|
|
81
|
+
color: inherit;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.outline .close {
|
|
85
|
+
color: currentColor;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.sizeXs {
|
|
89
|
+
height: var(--b-comp-secondary-height-xs);
|
|
90
|
+
min-width: calc(2 * var(--b-comp-secondary-height-xs));
|
|
91
|
+
padding: 0 6px;
|
|
92
|
+
font-size: 10px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.sizeSm {
|
|
96
|
+
height: var(--b-comp-secondary-height-sm);
|
|
97
|
+
min-width: calc(2 * var(--b-comp-secondary-height-sm));
|
|
98
|
+
padding: 0 8px;
|
|
99
|
+
font-size: 11px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.sizeMd {
|
|
103
|
+
height: var(--b-comp-secondary-height-md);
|
|
104
|
+
min-width: calc(2 * var(--b-comp-secondary-height-md));
|
|
105
|
+
padding: 0 10px;
|
|
106
|
+
font-size: 12px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.sizeLg {
|
|
110
|
+
height: var(--b-comp-secondary-height-lg);
|
|
111
|
+
min-width: calc(2 * var(--b-comp-secondary-height-lg));
|
|
112
|
+
padding: 0 12px;
|
|
113
|
+
font-size: 13px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.sizeXl {
|
|
117
|
+
height: var(--b-comp-secondary-height-xl);
|
|
118
|
+
min-width: calc(2 * var(--b-comp-secondary-height-xl));
|
|
119
|
+
padding: 0 14px;
|
|
120
|
+
font-size: 14px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.size2xl {
|
|
124
|
+
height: var(--b-comp-secondary-height-2xl);
|
|
125
|
+
min-width: calc(2 * var(--b-comp-secondary-height-2xl));
|
|
126
|
+
padding: 0 18px;
|
|
127
|
+
font-size: 16px;
|
|
128
|
+
}
|
package/src/Tag/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tag } from './Tag.jsx'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { splitProps, mergeProps } from 'solid-js'
|
|
2
|
+
import { ark } from '@ark-ui/solid/factory'
|
|
3
|
+
import styles from './Textarea.module.css'
|
|
4
|
+
|
|
5
|
+
const variants = {
|
|
6
|
+
solid: styles.solid,
|
|
7
|
+
outline: styles.outline,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const sizes = {
|
|
11
|
+
xs: styles.sizeXs,
|
|
12
|
+
sm: styles.sizeSm,
|
|
13
|
+
md: styles.sizeMd,
|
|
14
|
+
lg: styles.sizeLg,
|
|
15
|
+
xl: styles.sizeXl,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const DEFAULT_PROPS = {
|
|
19
|
+
variant: 'outline',
|
|
20
|
+
size: 'md',
|
|
21
|
+
disabled: false,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {import('solid-js').JSX.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
26
|
+
* variant?: 'solid' | 'outline'
|
|
27
|
+
* size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
28
|
+
* }} props
|
|
29
|
+
*/
|
|
30
|
+
export function Textarea(props) {
|
|
31
|
+
const [local, rest] = splitProps(
|
|
32
|
+
mergeProps(DEFAULT_PROPS, props),
|
|
33
|
+
['variant', 'size', 'class'],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ark.textarea
|
|
38
|
+
{...rest}
|
|
39
|
+
class={[
|
|
40
|
+
'balik-textarea',
|
|
41
|
+
`balik-textarea--${local.variant}`,
|
|
42
|
+
`balik-textarea--${local.size}`,
|
|
43
|
+
styles.base,
|
|
44
|
+
variants[local.variant],
|
|
45
|
+
sizes[local.size],
|
|
46
|
+
local.class,
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join(' ')}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.base {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-height: var(--_min-height);
|
|
5
|
+
border-width: 1px;
|
|
6
|
+
border-style: solid;
|
|
7
|
+
border-color: var(--_border-color, transparent);
|
|
8
|
+
border-radius: var(--_border-radius);
|
|
9
|
+
font-family: inherit;
|
|
10
|
+
outline: none;
|
|
11
|
+
box-shadow: none;
|
|
12
|
+
appearance: none;
|
|
13
|
+
touch-action: manipulation;
|
|
14
|
+
transition: background-color var(--b-transition-fast),
|
|
15
|
+
border-color var(--b-transition-fast),
|
|
16
|
+
color var(--b-transition-fast);
|
|
17
|
+
resize: vertical;
|
|
18
|
+
|
|
19
|
+
--_current-intent: var(--base-edge);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.base::placeholder {
|
|
23
|
+
color: var(--color-disabled-fg);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.base:disabled {
|
|
27
|
+
background-color: var(--color-disabled-bg);
|
|
28
|
+
border-color: var(--color-disabled-border);
|
|
29
|
+
color: var(--color-disabled-fg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.solid {
|
|
33
|
+
--_border-color: transparent;
|
|
34
|
+
background-color: color-mix(in oklch, var(--base-fg) 2%, var(--base-bg));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.solid:focus {
|
|
38
|
+
background-color: var(--color-focus-bg);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.outline {
|
|
42
|
+
--_border-color: var(--_current-intent);
|
|
43
|
+
background-color: var(--base-bg);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.outline:focus {
|
|
47
|
+
background-color: var(--color-focus-bg);
|
|
48
|
+
border-color: var(--color-focus-border);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.sizeXs {
|
|
52
|
+
--_min-height: 72px;
|
|
53
|
+
padding: var(--b-comp-padding-y-xs) var(--b-comp-padding-x-xs);
|
|
54
|
+
font-size: var(--b-comp-font-size-xs);
|
|
55
|
+
line-height: var(--b-comp-line-height-xs);
|
|
56
|
+
--_border-radius: var(--b-radius-l1-xs);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sizeSm {
|
|
60
|
+
--_min-height: 80px;
|
|
61
|
+
padding: var(--b-comp-padding-y-sm) var(--b-comp-padding-x-sm);
|
|
62
|
+
font-size: var(--b-comp-font-size-sm);
|
|
63
|
+
line-height: var(--b-comp-line-height-sm);
|
|
64
|
+
--_border-radius: var(--b-radius-l1-sm);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sizeMd {
|
|
68
|
+
--_min-height: 88px;
|
|
69
|
+
padding: var(--b-comp-padding-y-md) var(--b-comp-padding-x-md);
|
|
70
|
+
font-size: var(--b-comp-font-size-md);
|
|
71
|
+
line-height: var(--b-comp-line-height-md);
|
|
72
|
+
--_border-radius: var(--b-radius-l1-md);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sizeLg {
|
|
76
|
+
--_min-height: 96px;
|
|
77
|
+
padding: var(--b-comp-padding-y-lg) var(--b-comp-padding-x-lg);
|
|
78
|
+
font-size: var(--b-comp-font-size-lg);
|
|
79
|
+
line-height: var(--b-comp-line-height-lg);
|
|
80
|
+
--_border-radius: var(--b-radius-l1-lg);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sizeXl {
|
|
84
|
+
--_min-height: 112px;
|
|
85
|
+
padding: var(--b-comp-padding-y-xl) var(--b-comp-padding-x-xl);
|
|
86
|
+
font-size: var(--b-comp-font-size-xl);
|
|
87
|
+
line-height: var(--b-comp-line-height-xl);
|
|
88
|
+
--_border-radius: var(--b-radius-l1-xl);
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from './Textarea.jsx'
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { createStore } from 'solid-js/store'
|
|
2
|
+
import { onCleanup, createEffect, For, splitProps, mergeProps } from 'solid-js'
|
|
3
|
+
import { CircleCheck, TriangleAlert, XCircle, Info } from 'lucide-solid'
|
|
4
|
+
import { CloseButton } from '../CloseButton/CloseButton.jsx'
|
|
5
|
+
import styles from './Toast.module.css'
|
|
6
|
+
|
|
7
|
+
const positions = {
|
|
8
|
+
'top-left': styles.positionTopLeft,
|
|
9
|
+
'top-center': styles.positionTopCenter,
|
|
10
|
+
'top-right': styles.positionTopRight,
|
|
11
|
+
'bottom-left': styles.positionBottomLeft,
|
|
12
|
+
'bottom-center': styles.positionBottomCenter,
|
|
13
|
+
'bottom-right': styles.positionBottomRight,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const intents = {
|
|
17
|
+
info: styles.intentInfo,
|
|
18
|
+
success: styles.intentSuccess,
|
|
19
|
+
warning: styles.intentWarning,
|
|
20
|
+
danger: styles.intentDanger,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const intentIcons = {
|
|
24
|
+
success: () => <CircleCheck size={20} aria-hidden="true" />,
|
|
25
|
+
warning: () => <TriangleAlert size={20} aria-hidden="true" />,
|
|
26
|
+
danger: () => <XCircle size={20} aria-hidden="true" />,
|
|
27
|
+
info: () => <Info size={20} aria-hidden="true" />,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let nextId = 0
|
|
31
|
+
const [toasts, setToasts] = createStore([])
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {string | {
|
|
35
|
+
* title: string
|
|
36
|
+
* description?: string
|
|
37
|
+
* intent?: 'info' | 'success' | 'warning' | 'danger'
|
|
38
|
+
* duration?: number
|
|
39
|
+
* }} payload
|
|
40
|
+
*/
|
|
41
|
+
export function toast(payload) {
|
|
42
|
+
const config = typeof payload === 'string' ? { title: payload } : payload
|
|
43
|
+
|
|
44
|
+
const id = ++nextId
|
|
45
|
+
const duration = config.duration ?? 5000
|
|
46
|
+
|
|
47
|
+
setToasts([...toasts, {
|
|
48
|
+
id,
|
|
49
|
+
title: config.title,
|
|
50
|
+
description: config.description ?? '',
|
|
51
|
+
intent: config.intent ?? 'info',
|
|
52
|
+
duration,
|
|
53
|
+
state: 'enter',
|
|
54
|
+
}])
|
|
55
|
+
|
|
56
|
+
if (duration > 0) {
|
|
57
|
+
setTimeout(() => dismiss(id), duration)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return id
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function dismiss(id) {
|
|
64
|
+
setToasts(toast => toast.id === id, 'state', 'exit')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function remove(id) {
|
|
68
|
+
setToasts(toasts => toasts.filter(t => t.id !== id))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const REGION_DEFAULT_PROPS = {
|
|
72
|
+
position: 'top-right',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {{
|
|
77
|
+
* position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'
|
|
78
|
+
* class?: string
|
|
79
|
+
* }} props
|
|
80
|
+
*/
|
|
81
|
+
export function Toast(props) {
|
|
82
|
+
const [local, rest] = splitProps(
|
|
83
|
+
mergeProps(REGION_DEFAULT_PROPS, props),
|
|
84
|
+
['position', 'class'],
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<section
|
|
89
|
+
{...rest}
|
|
90
|
+
aria-live="polite"
|
|
91
|
+
aria-label="Notifications"
|
|
92
|
+
class={[
|
|
93
|
+
'balik-toast-region',
|
|
94
|
+
styles.region,
|
|
95
|
+
positions[local.position],
|
|
96
|
+
local.class,
|
|
97
|
+
]
|
|
98
|
+
.filter(Boolean)
|
|
99
|
+
.join(' ')}
|
|
100
|
+
>
|
|
101
|
+
<For each={toasts}>
|
|
102
|
+
{(item) => (
|
|
103
|
+
<ToastItem
|
|
104
|
+
id={item.id}
|
|
105
|
+
title={item.title}
|
|
106
|
+
description={item.description}
|
|
107
|
+
intent={item.intent}
|
|
108
|
+
state={item.state}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
</For>
|
|
112
|
+
</section>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @param {{
|
|
118
|
+
* id: number
|
|
119
|
+
* title: string
|
|
120
|
+
* description: string
|
|
121
|
+
* intent: string
|
|
122
|
+
* state: string
|
|
123
|
+
* }} props
|
|
124
|
+
*/
|
|
125
|
+
function ToastItem(props) {
|
|
126
|
+
const [local] = splitProps(props, ['id', 'title', 'description', 'intent', 'state'])
|
|
127
|
+
|
|
128
|
+
const onTransitionEnd = (e) => {
|
|
129
|
+
if (e.target === e.currentTarget && local.state === 'exit') {
|
|
130
|
+
remove(local.id)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
createEffect(() => {
|
|
135
|
+
if (local.state === 'enter') {
|
|
136
|
+
const raf = requestAnimationFrame(() => {
|
|
137
|
+
setToasts(toast => toast.id === local.id, 'state', 'visible')
|
|
138
|
+
})
|
|
139
|
+
onCleanup(() => cancelAnimationFrame(raf))
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div
|
|
145
|
+
role="status"
|
|
146
|
+
class={[
|
|
147
|
+
'balik-toast',
|
|
148
|
+
styles.item,
|
|
149
|
+
intents[local.intent],
|
|
150
|
+
local.state === 'exit' && styles.itemExit,
|
|
151
|
+
local.state === 'visible' && styles.itemVisible,
|
|
152
|
+
]
|
|
153
|
+
.filter(Boolean)
|
|
154
|
+
.join(' ')}
|
|
155
|
+
onTransitionEnd={onTransitionEnd}
|
|
156
|
+
>
|
|
157
|
+
<span class={styles.icon}>
|
|
158
|
+
{intentIcons[local.intent]()}
|
|
159
|
+
</span>
|
|
160
|
+
<div class={styles.body}>
|
|
161
|
+
<p class={styles.title}>{local.title}</p>
|
|
162
|
+
{local.description && (
|
|
163
|
+
<p class={styles.description}>{local.description}</p>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
<CloseButton size="xs" class={styles.close} onClick={() => dismiss(local.id)} />
|
|
167
|
+
</div>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
.region {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: var(--b-z-index-toast);
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: var(--b-spacing-sm);
|
|
7
|
+
max-width: 420px;
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: var(--b-spacing-md);
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.positionTopLeft {
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
align-items: flex-start;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.positionTopCenter {
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 50%;
|
|
22
|
+
transform: translateX(-50%);
|
|
23
|
+
align-items: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.positionTopRight {
|
|
27
|
+
top: 0;
|
|
28
|
+
right: 0;
|
|
29
|
+
align-items: flex-end;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.positionBottomLeft {
|
|
33
|
+
bottom: 0;
|
|
34
|
+
left: 0;
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
flex-direction: column-reverse;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.positionBottomCenter {
|
|
40
|
+
bottom: 0;
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translateX(-50%);
|
|
43
|
+
align-items: center;
|
|
44
|
+
flex-direction: column-reverse;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.positionBottomRight {
|
|
48
|
+
bottom: 0;
|
|
49
|
+
right: 0;
|
|
50
|
+
align-items: flex-end;
|
|
51
|
+
flex-direction: column-reverse;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.item {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: flex-start;
|
|
57
|
+
gap: var(--b-spacing-sm);
|
|
58
|
+
width: 100%;
|
|
59
|
+
max-width: 380px;
|
|
60
|
+
padding: var(--b-container-padding-sm) var(--b-container-padding-md);
|
|
61
|
+
background-color: var(--base-bg);
|
|
62
|
+
border-radius: var(--b-radius-l2-sm);
|
|
63
|
+
box-shadow: var(--b-shadow-md);
|
|
64
|
+
pointer-events: auto;
|
|
65
|
+
opacity: 0;
|
|
66
|
+
transform: translateY(calc(var(--_toast-dir, -1) * -8px)) scale(0.96);
|
|
67
|
+
transition:
|
|
68
|
+
opacity var(--b-transition-normal),
|
|
69
|
+
transform var(--b-transition-normal);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.itemVisible {
|
|
73
|
+
opacity: 1;
|
|
74
|
+
transform: translateY(0) scale(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.itemExit {
|
|
78
|
+
opacity: 0;
|
|
79
|
+
transform: translateY(calc(var(--_toast-dir, -1) * -8px)) scale(0.96);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.icon {
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
width: 20px;
|
|
85
|
+
height: 20px;
|
|
86
|
+
margin-top: 1px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.icon svg {
|
|
90
|
+
display: block;
|
|
91
|
+
width: 100%;
|
|
92
|
+
height: 100%;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.body {
|
|
96
|
+
flex: 1;
|
|
97
|
+
min-width: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.title {
|
|
101
|
+
margin: 0;
|
|
102
|
+
font-size: var(--b-comp-font-size-md);
|
|
103
|
+
line-height: var(--b-comp-line-height-md);
|
|
104
|
+
color: var(--base-fg);
|
|
105
|
+
word-break: break-word;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.description {
|
|
109
|
+
margin: var(--b-spacing-xxs) 0 0;
|
|
110
|
+
font-size: var(--b-comp-font-size-sm);
|
|
111
|
+
line-height: var(--b-comp-line-height-sm);
|
|
112
|
+
color: color-mix(in oklch, var(--base-fg) 65%, transparent);
|
|
113
|
+
word-break: break-word;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.close {
|
|
117
|
+
flex-shrink: 0;
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
width: 24px;
|
|
122
|
+
height: 24px;
|
|
123
|
+
margin: -2px -6px 0 0;
|
|
124
|
+
padding: 0;
|
|
125
|
+
border: none;
|
|
126
|
+
border-radius: var(--b-radius-l1-sm);
|
|
127
|
+
background: transparent;
|
|
128
|
+
color: color-mix(in oklch, var(--base-fg) 40%, transparent);
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.close svg {
|
|
133
|
+
display: block;
|
|
134
|
+
width: 16px;
|
|
135
|
+
height: 16px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.intentSuccess .icon {
|
|
139
|
+
color: var(--color-success);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.intentWarning .icon {
|
|
143
|
+
color: var(--color-warning);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.intentDanger .icon {
|
|
147
|
+
color: var(--color-danger);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.intentInfo .icon {
|
|
151
|
+
color: var(--color-info);
|
|
152
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Toast, toast } from './Toast.jsx'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { splitProps, mergeProps } from 'solid-js'
|
|
2
|
+
import { Portal } from 'solid-js/web'
|
|
3
|
+
import { Tooltip as ArkTooltip } from '@ark-ui/solid'
|
|
4
|
+
import styles from './Tooltip.module.css'
|
|
5
|
+
|
|
6
|
+
const DEFAULT_PROPS = {
|
|
7
|
+
openDelay: 300,
|
|
8
|
+
closeDelay: 100,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {import('@ark-ui/solid').TooltipRootProps & {
|
|
13
|
+
* content: string
|
|
14
|
+
* class?: string
|
|
15
|
+
* }} props
|
|
16
|
+
*/
|
|
17
|
+
export function Tooltip(props) {
|
|
18
|
+
const [local, rest] = splitProps(
|
|
19
|
+
mergeProps(DEFAULT_PROPS, props),
|
|
20
|
+
['content', 'class', 'children'],
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ArkTooltip.Root {...rest} openDelay={local.openDelay} closeDelay={local.closeDelay}>
|
|
25
|
+
<ArkTooltip.Trigger as="div" class={styles.trigger}>
|
|
26
|
+
{local.children}
|
|
27
|
+
</ArkTooltip.Trigger>
|
|
28
|
+
<Portal mount={document.body}>
|
|
29
|
+
<ArkTooltip.Positioner class={styles.positioner}>
|
|
30
|
+
<ArkTooltip.Content class={styles.content}>
|
|
31
|
+
<ArkTooltip.Arrow class={styles.arrow}>
|
|
32
|
+
<ArkTooltip.ArrowTip class={styles.arrowTip} />
|
|
33
|
+
</ArkTooltip.Arrow>
|
|
34
|
+
{local.content}
|
|
35
|
+
</ArkTooltip.Content>
|
|
36
|
+
</ArkTooltip.Positioner>
|
|
37
|
+
</Portal>
|
|
38
|
+
</ArkTooltip.Root>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Tooltip.Original = ArkTooltip
|