@hanzogui/demos 4.4.0 → 8.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/dist/cjs/AccordionDemo.native.js.map +1 -1
- package/dist/cjs/AddThemeDemo.native.js.map +1 -1
- package/dist/cjs/AlertDialogDemo.native.js.map +1 -1
- package/dist/cjs/AnimationsDelayDemo.native.js.map +1 -1
- package/dist/cjs/AnimationsDemo.native.js.map +1 -1
- package/dist/cjs/AnimationsEnterDemo.native.js.map +1 -1
- package/dist/cjs/AnimationsHoverDemo.native.js.map +1 -1
- package/dist/cjs/AnimationsPresenceDemo.native.js.map +1 -1
- package/dist/cjs/AnimationsTimingDemo.native.js.map +1 -1
- package/dist/cjs/AvatarDemo.native.js.map +1 -1
- package/dist/cjs/BoxShadowTokenDemo.native.js.map +1 -1
- package/dist/cjs/BuildAButtonDemo.native.js.map +1 -1
- package/dist/cjs/ButtonDemo.native.js.map +1 -1
- package/dist/cjs/CardDemo.native.js.map +1 -1
- package/dist/cjs/CheckboxDemo.native.js.map +1 -1
- package/dist/cjs/CheckboxHeadlessDemo.native.js.map +1 -1
- package/dist/cjs/CheckboxUnstyledDemo.native.js.map +1 -1
- package/dist/cjs/ColorsDemo.native.js.map +1 -1
- package/dist/cjs/ContextMenuDemo.native.js.map +1 -1
- package/dist/cjs/DialogDemo.native.js.map +1 -1
- package/dist/cjs/FormsDemo.native.js.map +1 -1
- package/dist/cjs/Grid.native.js.map +1 -1
- package/dist/cjs/GroupDemo.native.js.map +1 -1
- package/dist/cjs/HeadingsDemo.native.js.map +1 -1
- package/dist/cjs/ImageDemo.native.js.map +1 -1
- package/dist/cjs/InputsDemo.native.js.map +1 -1
- package/dist/cjs/LabelDemo.native.js.map +1 -1
- package/dist/cjs/LinearGradientDemo.native.js.map +1 -1
- package/dist/cjs/ListItemDemo.cjs +8 -0
- package/dist/cjs/ListItemDemo.native.js +8 -0
- package/dist/cjs/ListItemDemo.native.js.map +1 -1
- package/dist/cjs/LucideIconsDemo.native.js.map +1 -1
- package/dist/cjs/MenuDemo.native.js.map +1 -1
- package/dist/cjs/NewInputsDemo.native.js.map +1 -1
- package/dist/cjs/PopoverDemo.native.js.map +1 -1
- package/dist/cjs/ProgressDemo.native.js.map +1 -1
- package/dist/cjs/RadioGroupDemo.native.js.map +1 -1
- package/dist/cjs/RadioGroupHeadlessDemo.native.js.map +1 -1
- package/dist/cjs/RadioGroupUnstyledDemo.native.js.map +1 -1
- package/dist/cjs/ReplaceThemeDemo.native.js.map +1 -1
- package/dist/cjs/ScrollViewDemo.native.js.map +1 -1
- package/dist/cjs/SelectDemo.cjs +1 -1
- package/dist/cjs/SelectDemo.native.js +1 -1
- package/dist/cjs/SelectDemo.native.js.map +1 -1
- package/dist/cjs/SeparatorDemo.native.js.map +1 -1
- package/dist/cjs/ShapesDemo.native.js.map +1 -1
- package/dist/cjs/SheetDemo.native.js.map +1 -1
- package/dist/cjs/SliderDemo.native.js.map +1 -1
- package/dist/cjs/SpinnerDemo.native.js.map +1 -1
- package/dist/cjs/StacksDemo.native.js.map +1 -1
- package/dist/cjs/SwitchDemo.native.js.map +1 -1
- package/dist/cjs/SwitchHeadlessDemo.native.js.map +1 -1
- package/dist/cjs/SwitchUnstyledDemo.native.js.map +1 -1
- package/dist/cjs/TabsAdvancedDemo.cjs +8 -8
- package/dist/cjs/TabsAdvancedDemo.native.js +8 -8
- package/dist/cjs/TabsAdvancedDemo.native.js.map +1 -1
- package/dist/cjs/TabsDemo.native.js.map +1 -1
- package/dist/cjs/TabsHeadlessDemo.native.js.map +1 -1
- package/dist/cjs/TextDemo.native.js.map +1 -1
- package/dist/cjs/ThemeBuilderDemo.native.js.map +1 -1
- package/dist/cjs/ThemeInverseDemo.native.js.map +1 -1
- package/dist/cjs/ToastDemo.cjs +190 -113
- package/dist/cjs/ToastDemo.native.js +201 -117
- package/dist/cjs/ToastDemo.native.js.map +1 -1
- package/dist/cjs/ToastDuplicateDemo.cjs +30 -43
- package/dist/cjs/ToastDuplicateDemo.native.js +31 -48
- package/dist/cjs/ToastDuplicateDemo.native.js.map +1 -1
- package/dist/cjs/ToastV1Demo.cjs +155 -0
- package/dist/cjs/ToastV1Demo.native.js +166 -0
- package/dist/cjs/ToastV1Demo.native.js.map +1 -0
- package/dist/cjs/ToggleGroupDemo.native.js.map +1 -1
- package/dist/cjs/TokensDemo.native.js.map +1 -1
- package/dist/cjs/TooltipDemo.native.js.map +1 -1
- package/dist/cjs/UpdateThemeDemo.native.js.map +1 -1
- package/dist/cjs/WebNativeImageDemo.native.js.map +1 -1
- package/dist/cjs/{gui.config.cjs → hanzogui.config.cjs} +5 -5
- package/dist/cjs/{gui.config.native.js → hanzogui.config.native.js} +6 -6
- package/dist/cjs/hanzogui.config.native.js.map +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useOnIntersecting.native.js.map +1 -1
- package/dist/esm/AnimationsPresenceDemo.mjs.map +1 -1
- package/dist/esm/AnimationsPresenceDemo.native.js.map +1 -1
- package/dist/esm/ListItemDemo.mjs +8 -0
- package/dist/esm/ListItemDemo.mjs.map +1 -1
- package/dist/esm/ListItemDemo.native.js +8 -0
- package/dist/esm/ListItemDemo.native.js.map +1 -1
- package/dist/esm/SelectDemo.mjs +1 -1
- package/dist/esm/SelectDemo.mjs.map +1 -1
- package/dist/esm/SelectDemo.native.js +1 -1
- package/dist/esm/SelectDemo.native.js.map +1 -1
- package/dist/esm/TabsAdvancedDemo.mjs +8 -8
- package/dist/esm/TabsAdvancedDemo.mjs.map +1 -1
- package/dist/esm/TabsAdvancedDemo.native.js +8 -8
- package/dist/esm/TabsAdvancedDemo.native.js.map +1 -1
- package/dist/esm/ToastDemo.mjs +190 -102
- package/dist/esm/ToastDemo.mjs.map +1 -1
- package/dist/esm/ToastDemo.native.js +202 -107
- package/dist/esm/ToastDemo.native.js.map +1 -1
- package/dist/esm/ToastDuplicateDemo.mjs +30 -32
- package/dist/esm/ToastDuplicateDemo.mjs.map +1 -1
- package/dist/esm/ToastDuplicateDemo.native.js +31 -37
- package/dist/esm/ToastDuplicateDemo.native.js.map +1 -1
- package/dist/esm/ToastV1Demo.mjs +119 -0
- package/dist/esm/ToastV1Demo.mjs.map +1 -0
- package/dist/esm/ToastV1Demo.native.js +127 -0
- package/dist/esm/ToastV1Demo.native.js.map +1 -0
- package/dist/esm/TooltipDemo.mjs.map +1 -1
- package/dist/esm/TooltipDemo.native.js.map +1 -1
- package/dist/esm/hanzogui.config.mjs +6 -0
- package/dist/esm/hanzogui.config.mjs.map +1 -0
- package/dist/esm/hanzogui.config.native.js +6 -0
- package/dist/esm/hanzogui.config.native.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +40 -17
- package/src/ListItemDemo.tsx +26 -5
- package/src/MenuDemo.tsx +1 -1
- package/src/SelectDemo.tsx +2 -11
- package/src/TabsAdvancedDemo.tsx +13 -11
- package/src/ToastDemo.tsx +208 -93
- package/src/ToastDuplicateDemo.tsx +38 -28
- package/src/ToastV1Demo.tsx +121 -0
- package/src/TooltipDemo.tsx +1 -9
- package/src/{gui.config.ts → hanzogui.config.ts} +1 -1
- package/src/index.tsx +3 -2
- package/LICENSE +0 -21
- package/dist/cjs/gui.config.native.js.map +0 -1
- package/dist/esm/gui.config.mjs +0 -6
- package/dist/esm/gui.config.mjs.map +0 -1
- package/dist/esm/gui.config.native.js +0 -6
- package/dist/esm/gui.config.native.js.map +0 -1
package/src/ToastDemo.tsx
CHANGED
|
@@ -1,121 +1,236 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { isWeb } from '@hanzo/gui'
|
|
2
|
+
import {
|
|
3
|
+
Toast,
|
|
4
|
+
toast,
|
|
5
|
+
useToastItem,
|
|
6
|
+
type ToastPosition,
|
|
7
|
+
type ToastT,
|
|
8
|
+
} from '@hanzogui/toast/v2'
|
|
9
|
+
import {
|
|
10
|
+
ArrowDown,
|
|
11
|
+
ArrowDownLeft,
|
|
12
|
+
ArrowDownRight,
|
|
13
|
+
ArrowUp,
|
|
14
|
+
ArrowUpLeft,
|
|
15
|
+
ArrowUpRight,
|
|
16
|
+
} from '@hanzogui/lucide-icons-2'
|
|
17
|
+
import { useRef, useState } from 'react'
|
|
18
|
+
import { Button, Label, SizableText, Slider, XStack, YStack } from '@hanzo/gui'
|
|
4
19
|
|
|
5
|
-
/**
|
|
6
|
-
* IMPORTANT NOTE: if you're copy-pasting this demo into your code, make sure to add:
|
|
7
|
-
* - <ToastProvider> at the root
|
|
8
|
-
* - <ToastViewport /> where you want to show the toasts
|
|
9
|
-
*/
|
|
10
20
|
export const ToastDemo = () => {
|
|
11
|
-
const [
|
|
21
|
+
const [position, setPosition] = useState<ToastPosition>('bottom-right')
|
|
22
|
+
const [gap, setGap] = useState(14)
|
|
23
|
+
const [visibleToasts, setVisibleToasts] = useState(4)
|
|
24
|
+
const [duration, setDuration] = useState(4000)
|
|
25
|
+
const count = useRef(0)
|
|
26
|
+
|
|
27
|
+
const showToast = (newPosition: ToastPosition) => {
|
|
28
|
+
setPosition(newPosition)
|
|
29
|
+
count.current++
|
|
30
|
+
toast(`Toast #${count.current}`, {
|
|
31
|
+
description: 'Swipe to dismiss or wait for auto-close.',
|
|
32
|
+
})
|
|
33
|
+
}
|
|
12
34
|
|
|
13
35
|
return (
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
36
|
+
<Toast
|
|
37
|
+
position={position}
|
|
38
|
+
gap={Math.round(gap)}
|
|
39
|
+
visibleToasts={visibleToasts}
|
|
40
|
+
duration={duration}
|
|
41
|
+
>
|
|
42
|
+
<Toast.Viewport offset={16}>
|
|
43
|
+
<Toast.List
|
|
44
|
+
renderItem={({ toast: t, index }) => (
|
|
45
|
+
<Toast.Item key={t.id} toast={t} index={index} testID="toast-item">
|
|
46
|
+
<ToastContent toast={t} />
|
|
47
|
+
</Toast.Item>
|
|
48
|
+
)}
|
|
49
|
+
/>
|
|
50
|
+
</Toast.Viewport>
|
|
51
|
+
|
|
52
|
+
<YStack gap="$3" self="center" width={280}>
|
|
53
|
+
{/* Position buttons */}
|
|
54
|
+
<YStack gap="$2" self="center">
|
|
55
|
+
<XStack gap="$2">
|
|
56
|
+
<PositionButton
|
|
57
|
+
position="top-left"
|
|
58
|
+
current={position}
|
|
59
|
+
onPress={showToast}
|
|
60
|
+
Icon={ArrowUpLeft}
|
|
61
|
+
/>
|
|
62
|
+
<PositionButton
|
|
63
|
+
position="top-center"
|
|
64
|
+
current={position}
|
|
65
|
+
onPress={showToast}
|
|
66
|
+
Icon={ArrowUp}
|
|
67
|
+
/>
|
|
68
|
+
<PositionButton
|
|
69
|
+
position="top-right"
|
|
70
|
+
current={position}
|
|
71
|
+
onPress={showToast}
|
|
72
|
+
Icon={ArrowUpRight}
|
|
73
|
+
testID="toast-top-right-button"
|
|
74
|
+
/>
|
|
75
|
+
</XStack>
|
|
76
|
+
<XStack gap="$2">
|
|
77
|
+
<PositionButton
|
|
78
|
+
position="bottom-left"
|
|
79
|
+
current={position}
|
|
80
|
+
onPress={showToast}
|
|
81
|
+
Icon={ArrowDownLeft}
|
|
82
|
+
/>
|
|
83
|
+
<PositionButton
|
|
84
|
+
position="bottom-center"
|
|
85
|
+
current={position}
|
|
86
|
+
onPress={showToast}
|
|
87
|
+
Icon={ArrowDown}
|
|
88
|
+
/>
|
|
89
|
+
<PositionButton
|
|
90
|
+
position="bottom-right"
|
|
91
|
+
current={position}
|
|
92
|
+
onPress={showToast}
|
|
93
|
+
Icon={ArrowDownRight}
|
|
94
|
+
testID="toast-show-button"
|
|
95
|
+
/>
|
|
96
|
+
</XStack>
|
|
97
|
+
</YStack>
|
|
17
98
|
|
|
18
|
-
|
|
19
|
-
|
|
99
|
+
{/* Controls */}
|
|
100
|
+
<YStack gap="$1" paddingTop="$1">
|
|
101
|
+
<DemoSlider
|
|
102
|
+
label="Gap"
|
|
103
|
+
value={gap}
|
|
104
|
+
min={0}
|
|
105
|
+
max={30}
|
|
106
|
+
step={0.1}
|
|
107
|
+
onChange={setGap}
|
|
108
|
+
/>
|
|
109
|
+
<DemoSlider
|
|
110
|
+
label="Visible"
|
|
111
|
+
value={visibleToasts}
|
|
112
|
+
min={1}
|
|
113
|
+
max={8}
|
|
114
|
+
step={1}
|
|
115
|
+
onChange={setVisibleToasts}
|
|
116
|
+
/>
|
|
117
|
+
<DemoSlider
|
|
118
|
+
label="Duration"
|
|
119
|
+
value={duration}
|
|
120
|
+
min={1000}
|
|
121
|
+
max={10000}
|
|
122
|
+
step={100}
|
|
123
|
+
onChange={setDuration}
|
|
124
|
+
format={(v) => `${(v / 1000).toFixed(1)}s`}
|
|
125
|
+
/>
|
|
126
|
+
</YStack>
|
|
127
|
+
</YStack>
|
|
128
|
+
</Toast>
|
|
20
129
|
)
|
|
21
130
|
}
|
|
22
131
|
|
|
23
|
-
|
|
24
|
-
const
|
|
132
|
+
function ToastContent({ toast: t }: { toast: ToastT }) {
|
|
133
|
+
const { handleClose } = useToastItem()
|
|
25
134
|
|
|
26
|
-
|
|
135
|
+
const title = typeof t.title === 'function' ? t.title() : t.title
|
|
136
|
+
const description =
|
|
137
|
+
typeof t.description === 'function' ? t.description() : t.description
|
|
27
138
|
|
|
28
139
|
return (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<XStack gap="$5" items="center" justify="space-between">
|
|
43
|
-
<YStack gap="$0.5" flex={1}>
|
|
44
|
-
<Toast.Title>{currentToast.title}</Toast.Title>
|
|
45
|
-
{!!currentToast.message && (
|
|
46
|
-
<Toast.Description>{currentToast.message}</Toast.Description>
|
|
140
|
+
<>
|
|
141
|
+
<XStack gap="$3" alignItems="flex-start">
|
|
142
|
+
<Toast.Icon />
|
|
143
|
+
<YStack flex={1} gap="$0.5">
|
|
144
|
+
{title && (
|
|
145
|
+
<Toast.Title fontWeight="600" size="$3">
|
|
146
|
+
{title}
|
|
147
|
+
</Toast.Title>
|
|
148
|
+
)}
|
|
149
|
+
{description && (
|
|
150
|
+
<Toast.Description color="$color9" size="$2">
|
|
151
|
+
{description}
|
|
152
|
+
</Toast.Description>
|
|
47
153
|
)}
|
|
48
154
|
</YStack>
|
|
49
|
-
<Toast.Action asChild altText="Dismiss toast">
|
|
50
|
-
<Button size="$2">Dismiss</Button>
|
|
51
|
-
</Toast.Action>
|
|
52
155
|
</XStack>
|
|
53
|
-
|
|
156
|
+
|
|
157
|
+
{isWeb && (
|
|
158
|
+
<Toast.Close
|
|
159
|
+
testID="toast-close-button"
|
|
160
|
+
position="absolute"
|
|
161
|
+
top={-6}
|
|
162
|
+
left={-6}
|
|
163
|
+
zIndex={1}
|
|
164
|
+
/>
|
|
165
|
+
)}
|
|
166
|
+
</>
|
|
54
167
|
)
|
|
55
168
|
}
|
|
56
169
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
170
|
+
function DemoSlider({
|
|
171
|
+
label,
|
|
172
|
+
value,
|
|
173
|
+
min,
|
|
174
|
+
max,
|
|
175
|
+
step,
|
|
176
|
+
onChange,
|
|
177
|
+
format,
|
|
178
|
+
}: {
|
|
179
|
+
label: string
|
|
180
|
+
value: number
|
|
181
|
+
min: number
|
|
182
|
+
max: number
|
|
183
|
+
step?: number
|
|
184
|
+
onChange: (v: number) => void
|
|
185
|
+
format?: (v: number) => string
|
|
186
|
+
}) {
|
|
60
187
|
return (
|
|
61
|
-
<XStack gap="$2"
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</Button>
|
|
73
|
-
<Button
|
|
74
|
-
onPress={() => {
|
|
75
|
-
toast.hide()
|
|
76
|
-
}}
|
|
188
|
+
<XStack gap="$2" alignItems="center">
|
|
189
|
+
<Label size="$2" width={55}>
|
|
190
|
+
{label}
|
|
191
|
+
</Label>
|
|
192
|
+
<Slider
|
|
193
|
+
flex={1}
|
|
194
|
+
value={[value]}
|
|
195
|
+
min={min}
|
|
196
|
+
max={max}
|
|
197
|
+
step={step}
|
|
198
|
+
onValueChange={([v]) => onChange(v)}
|
|
77
199
|
>
|
|
78
|
-
|
|
79
|
-
|
|
200
|
+
<Slider.Track>
|
|
201
|
+
<Slider.TrackActive />
|
|
202
|
+
</Slider.Track>
|
|
203
|
+
<Slider.Thumb theme="accent" size={16} borderRadius={100} index={0} />
|
|
204
|
+
</Slider>
|
|
205
|
+
<SizableText userSelect="none" size="$2" width={35} textAlign="right">
|
|
206
|
+
{format ? format(value) : Math.round(value)}
|
|
207
|
+
</SizableText>
|
|
80
208
|
</XStack>
|
|
81
209
|
)
|
|
82
210
|
}
|
|
83
211
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
212
|
+
const PositionButton = ({
|
|
213
|
+
position,
|
|
214
|
+
current,
|
|
215
|
+
onPress,
|
|
216
|
+
Icon,
|
|
217
|
+
testID,
|
|
87
218
|
}: {
|
|
88
|
-
|
|
89
|
-
|
|
219
|
+
position: ToastPosition
|
|
220
|
+
current: ToastPosition
|
|
221
|
+
onPress: (p: ToastPosition) => void
|
|
222
|
+
Icon: any
|
|
223
|
+
testID?: string
|
|
90
224
|
}) => {
|
|
91
|
-
|
|
92
|
-
<XStack gap="$3">
|
|
93
|
-
<Label size="$1" onPress={() => setNative(false)}>
|
|
94
|
-
Custom
|
|
95
|
-
</Label>
|
|
96
|
-
<Switch
|
|
97
|
-
theme="surface2"
|
|
98
|
-
id="native-toggle"
|
|
99
|
-
size="$1"
|
|
100
|
-
checked={!!native}
|
|
101
|
-
onCheckedChange={(val) => setNative(val)}
|
|
102
|
-
>
|
|
103
|
-
<Switch.Thumb
|
|
104
|
-
theme="accent"
|
|
105
|
-
transition={[
|
|
106
|
-
'quickest',
|
|
107
|
-
{
|
|
108
|
-
transform: {
|
|
109
|
-
overshootClamping: true,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
]}
|
|
113
|
-
/>
|
|
114
|
-
</Switch>
|
|
225
|
+
const isActive = position === current
|
|
115
226
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
227
|
+
return (
|
|
228
|
+
<Button
|
|
229
|
+
icon={Icon}
|
|
230
|
+
circular
|
|
231
|
+
theme={isActive ? 'accent' : undefined}
|
|
232
|
+
onPress={() => onPress(position)}
|
|
233
|
+
testID={testID}
|
|
234
|
+
/>
|
|
120
235
|
)
|
|
121
236
|
}
|
|
@@ -1,47 +1,57 @@
|
|
|
1
1
|
import { CheckCircle2 } from '@hanzogui/lucide-icons-2'
|
|
2
|
-
import { Toast } from '@hanzogui/toast'
|
|
3
|
-
import React from 'react'
|
|
2
|
+
import { Toast, toast, useToasts } from '@hanzogui/toast/v2'
|
|
4
3
|
import { Button, XStack, YStack } from '@hanzo/gui'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* IMPORTANT NOTE: if you're copy-pasting this demo into your code, make sure to add the
|
|
6
|
+
* IMPORTANT NOTE: if you're copy-pasting this demo into your code, make sure to add the Toast wrapper as well.
|
|
8
7
|
*/
|
|
9
8
|
export const ToastDuplicateDemo = () => {
|
|
10
|
-
const [savedCount, setSavedCount] = React.useState(0)
|
|
11
|
-
|
|
12
9
|
return (
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
duration={4000}
|
|
26
|
-
enterStyle={{ opacity: 0, scale: 0.5, y: -25 }}
|
|
27
|
-
exitStyle={{ opacity: 0, scale: 1, y: -20 }}
|
|
28
|
-
y={0}
|
|
29
|
-
opacity={1}
|
|
30
|
-
scale={1}
|
|
31
|
-
transition="100ms"
|
|
10
|
+
<Toast>
|
|
11
|
+
<Toast.Viewport>
|
|
12
|
+
<ToastList />
|
|
13
|
+
</Toast.Viewport>
|
|
14
|
+
|
|
15
|
+
<YStack items="center">
|
|
16
|
+
<Button
|
|
17
|
+
onPress={() => {
|
|
18
|
+
toast('Successfully saved!', {
|
|
19
|
+
description: "Don't worry... We've got your data.",
|
|
20
|
+
})
|
|
21
|
+
}}
|
|
32
22
|
>
|
|
23
|
+
Show toast
|
|
24
|
+
</Button>
|
|
25
|
+
</YStack>
|
|
26
|
+
</Toast>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ToastList = () => {
|
|
31
|
+
const { toasts } = useToasts()
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
{toasts.map((t, index) => (
|
|
36
|
+
<Toast.Item key={t.id} toast={t} index={index}>
|
|
33
37
|
<XStack gap="$4" items="center">
|
|
34
38
|
<YStack>
|
|
35
39
|
<CheckCircle2 />
|
|
36
40
|
</YStack>
|
|
37
41
|
|
|
38
42
|
<YStack>
|
|
39
|
-
<Toast.Title>
|
|
40
|
-
|
|
43
|
+
<Toast.Title>
|
|
44
|
+
{typeof t.title === 'function' ? t.title() : t.title}
|
|
45
|
+
</Toast.Title>
|
|
46
|
+
{t.description && (
|
|
47
|
+
<Toast.Description>
|
|
48
|
+
{typeof t.description === 'function' ? t.description() : t.description}
|
|
49
|
+
</Toast.Description>
|
|
50
|
+
)}
|
|
41
51
|
</YStack>
|
|
42
52
|
</XStack>
|
|
43
|
-
</Toast>
|
|
53
|
+
</Toast.Item>
|
|
44
54
|
))}
|
|
45
|
-
|
|
55
|
+
</>
|
|
46
56
|
)
|
|
47
57
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Toast, useToastController, useToastState } from '@hanzogui/toast'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Button, Label, Switch, XStack, YStack } from '@hanzo/gui'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* IMPORTANT NOTE: if you're copy-pasting this demo into your code, make sure to add:
|
|
7
|
+
* - <ToastProvider> at the root
|
|
8
|
+
* - <ToastViewport /> where you want to show the toasts
|
|
9
|
+
*/
|
|
10
|
+
export const ToastV1Demo = () => {
|
|
11
|
+
const [native, setNative] = React.useState(false)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<YStack gap="$4" items="center">
|
|
15
|
+
<ToastControl native={native} />
|
|
16
|
+
<CurrentToast />
|
|
17
|
+
|
|
18
|
+
<NativeOptions native={native} setNative={setNative} />
|
|
19
|
+
</YStack>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CurrentToast = () => {
|
|
24
|
+
const currentToast = useToastState()
|
|
25
|
+
|
|
26
|
+
if (!currentToast || currentToast.isHandledNatively) return null
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Toast
|
|
30
|
+
key={currentToast.id}
|
|
31
|
+
duration={currentToast.duration}
|
|
32
|
+
viewportName={currentToast.viewportName}
|
|
33
|
+
enterStyle={{ opacity: 0, scale: 0.95, y: -80 }}
|
|
34
|
+
exitStyle={{ opacity: 0, scale: 0.95, y: -80 }}
|
|
35
|
+
opacity={1}
|
|
36
|
+
scale={1}
|
|
37
|
+
y={-50}
|
|
38
|
+
transition="quicker"
|
|
39
|
+
bg="$color2"
|
|
40
|
+
boxShadow="0px 2px 4px rgba(0,0,0,0.12), 0px 8px 24px rgba(0,0,0,0.08)"
|
|
41
|
+
>
|
|
42
|
+
<XStack gap="$5" items="center" justify="space-between">
|
|
43
|
+
<YStack gap="$0.5" flex={1}>
|
|
44
|
+
<Toast.Title>{currentToast.title}</Toast.Title>
|
|
45
|
+
{!!currentToast.message && (
|
|
46
|
+
<Toast.Description>{currentToast.message}</Toast.Description>
|
|
47
|
+
)}
|
|
48
|
+
</YStack>
|
|
49
|
+
<Toast.Action asChild altText="Dismiss toast">
|
|
50
|
+
<Button size="$2">Dismiss</Button>
|
|
51
|
+
</Toast.Action>
|
|
52
|
+
</XStack>
|
|
53
|
+
</Toast>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ToastControl = ({ native }: { native: boolean }) => {
|
|
58
|
+
const toast = useToastController()
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<XStack gap="$2" justify="center">
|
|
62
|
+
<Button
|
|
63
|
+
onPress={() => {
|
|
64
|
+
toast.show('Successfully saved!', {
|
|
65
|
+
message: "Don't worry, we've got your data.",
|
|
66
|
+
native,
|
|
67
|
+
demo: true,
|
|
68
|
+
})
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
Show
|
|
72
|
+
</Button>
|
|
73
|
+
<Button
|
|
74
|
+
onPress={() => {
|
|
75
|
+
toast.hide()
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
Hide
|
|
79
|
+
</Button>
|
|
80
|
+
</XStack>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const NativeOptions = ({
|
|
85
|
+
native,
|
|
86
|
+
setNative,
|
|
87
|
+
}: {
|
|
88
|
+
native: boolean
|
|
89
|
+
setNative: (native: boolean) => void
|
|
90
|
+
}) => {
|
|
91
|
+
return (
|
|
92
|
+
<XStack gap="$3">
|
|
93
|
+
<Label size="$1" onPress={() => setNative(false)}>
|
|
94
|
+
Custom
|
|
95
|
+
</Label>
|
|
96
|
+
<Switch
|
|
97
|
+
theme="surface2"
|
|
98
|
+
id="native-toggle"
|
|
99
|
+
size="$1"
|
|
100
|
+
checked={!!native}
|
|
101
|
+
onCheckedChange={(val) => setNative(val)}
|
|
102
|
+
>
|
|
103
|
+
<Switch.Thumb
|
|
104
|
+
theme="accent"
|
|
105
|
+
transition={[
|
|
106
|
+
'quickest',
|
|
107
|
+
{
|
|
108
|
+
transform: {
|
|
109
|
+
overshootClamping: true,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
]}
|
|
113
|
+
/>
|
|
114
|
+
</Switch>
|
|
115
|
+
|
|
116
|
+
<Label size="$1" onPress={() => setNative(true)}>
|
|
117
|
+
Native
|
|
118
|
+
</Label>
|
|
119
|
+
</XStack>
|
|
120
|
+
)
|
|
121
|
+
}
|
package/src/TooltipDemo.tsx
CHANGED
|
@@ -6,15 +6,7 @@ import {
|
|
|
6
6
|
Circle,
|
|
7
7
|
} from '@hanzogui/lucide-icons-2'
|
|
8
8
|
import type { TooltipProps } from '@hanzo/gui'
|
|
9
|
-
import {
|
|
10
|
-
Button,
|
|
11
|
-
Paragraph,
|
|
12
|
-
Theme,
|
|
13
|
-
Tooltip,
|
|
14
|
-
TooltipGroup,
|
|
15
|
-
XStack,
|
|
16
|
-
YStack,
|
|
17
|
-
} from '@hanzo/gui'
|
|
9
|
+
import { Button, Paragraph, Theme, Tooltip, TooltipGroup, XStack, YStack } from '@hanzo/gui'
|
|
18
10
|
|
|
19
11
|
export function TooltipDemo() {
|
|
20
12
|
return (
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Include
|
|
2
|
-
import type {} from './
|
|
1
|
+
// Include hanzogui config types for proper type checking
|
|
2
|
+
import type {} from './hanzogui.config'
|
|
3
3
|
|
|
4
4
|
export * from './AccordionDemo'
|
|
5
5
|
export * from './AddThemeDemo'
|
|
@@ -57,6 +57,7 @@ export * from './TextDemo'
|
|
|
57
57
|
export * from './ThemeInverseDemo'
|
|
58
58
|
export * from './ToastDemo'
|
|
59
59
|
export * from './ToastDuplicateDemo'
|
|
60
|
+
export * from './ToastV1Demo'
|
|
60
61
|
export * from './ToggleGroupDemo'
|
|
61
62
|
export * from './TokensDemo'
|
|
62
63
|
export * from './TooltipDemo'
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Nate Wienert
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","gui_config_exports","default","gui_config_default","module","exports","import_dev_config","require","import_gui","tamaConf","createGui","config"],"sources":["gui.config.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar gui_config_exports = {};\n__export(gui_config_exports, {\n default: () => gui_config_default\n});\nmodule.exports = __toCommonJS(gui_config_exports);\nvar import_dev_config = require(\"@hanzogui/dev-config\");\nvar import_gui = require(\"@hanzo/gui\");\nvar tamaConf = (0, import_gui.createGui)(import_dev_config.config);\nvar gui_config_default = tamaConf;\n//# sourceMappingURL=gui.config.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;AACD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;EAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;IAClE,KAAK,IAAIG,GAAG,IAAIhB,iBAAiB,CAACa,IAAI,CAAC,EACrC,IAAI,CAACX,YAAY,CAACe,IAAI,CAACL,EAAE,EAAEI,GAAG,CAAC,IAAIA,GAAG,KAAKF,MAAM,EAC/CnB,SAAS,CAACiB,EAAE,EAAEI,GAAG,EAAE;MAAEP,GAAG,EAAEA,CAAA,KAAMI,IAAI,CAACG,GAAG,CAAC;MAAEN,UAAU,EAAE,EAAEK,IAAI,GAAGjB,gBAAgB,CAACe,IAAI,EAAEG,GAAG,CAAC,CAAC,IAAID,IAAI,CAACL;IAAW,CAAC,CAAC;EACxH;EACA,OAAOE,EAAE;AACX,CAAC;AACD,IAAIM,YAAY,GAAIC,GAAG,IAAKR,WAAW,CAAChB,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE;EAAEyB,KAAK,EAAE;AAAK,CAAC,CAAC,EAAED,GAAG,CAAC;AAC1F,IAAIE,kBAAkB,GAAG,CAAC,CAAC;AAC3BhB,QAAQ,CAACgB,kBAAkB,EAAE;EAC3BC,OAAO,EAAEA,CAAA,KAAMC;AACjB,CAAC,CAAC;AACFC,MAAM,CAACC,OAAO,GAAGP,YAAY,CAACG,kBAAkB,CAAC;AACjD,IAAIK,iBAAiB,GAAGC,OAAO,CAAC,sBAAsB,CAAC;AACvD,IAAIC,UAAU,GAAGD,OAAO,CAAC,YAAY,CAAC;AACtC,IAAIE,QAAQ,GAAG,CAAC,CAAC,EAAED,UAAU,CAACE,SAAS,EAAEJ,iBAAiB,CAACK,MAAM,CAAC;AAClE,IAAIR,kBAAkB,GAAGM,QAAQ","ignoreList":[]}
|
package/dist/esm/gui.config.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["config","createGui","tamaConf","gui_config_default"],"sources":["../../src/gui.config.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AACvB,SAASC,SAAA,QAAiB;AAE1B,MAAMC,QAAA,GAAWD,SAAA,CAAUD,MAAM;AAYjC,IAAOG,kBAAA,GAAQD,QAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["config","createGui","tamaConf","gui_config_default"],"sources":["../../src/gui.config.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AACvB,SAASC,SAAA,QAAiB;AAE1B,IAAAC,QAAM,GAAAD,SAAW,CAAAD,MAAU;AAY3B,IAAOG,kBAAA,GAAQD,QAAA","ignoreList":[]}
|