@tamagui/demos 1.27.2 → 1.28.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.
Files changed (62) hide show
  1. package/dist/cjs/ButtonDemo.js +2 -2
  2. package/dist/cjs/ButtonDemo.js.map +1 -1
  3. package/dist/esm/ButtonDemo.js +2 -2
  4. package/dist/esm/ButtonDemo.js.map +1 -1
  5. package/dist/jsx/ButtonDemo.js +2 -2
  6. package/dist/jsx/ButtonDemo.js.map +1 -1
  7. package/dist/jsx/ButtonDemo.mjs +2 -2
  8. package/dist/jsx/ButtonDemo.mjs.map +1 -1
  9. package/package.json +18 -18
  10. package/src/ButtonDemo.tsx +2 -2
  11. package/dist/esm/AddThemeDemo.mjs +0 -36
  12. package/dist/esm/AlertDialogDemo.mjs +0 -53
  13. package/dist/esm/AnimationsDemo.mjs +0 -89
  14. package/dist/esm/AnimationsEnterDemo.mjs +0 -40
  15. package/dist/esm/AnimationsHoverDemo.mjs +0 -27
  16. package/dist/esm/AnimationsPresenceDemo.mjs +0 -73
  17. package/dist/esm/AnimationsTimingDemo.mjs +0 -26
  18. package/dist/esm/AvatarDemo.mjs +0 -30
  19. package/dist/esm/ButtonDemo.mjs +0 -25
  20. package/dist/esm/ButtonNewDemo.mjs +0 -31
  21. package/dist/esm/CardDemo.mjs +0 -48
  22. package/dist/esm/CheckboxDemo.mjs +0 -22
  23. package/dist/esm/ColorsDemo.mjs +0 -98
  24. package/dist/esm/DialogDemo.mjs +0 -84
  25. package/dist/esm/FormsDemo.mjs +0 -36
  26. package/dist/esm/GroupDemo.mjs +0 -25
  27. package/dist/esm/HeadingsDemo.mjs +0 -16
  28. package/dist/esm/ImageDemo.mjs +0 -18
  29. package/dist/esm/InputsDemo.mjs +0 -31
  30. package/dist/esm/LabelDemo.mjs +0 -18
  31. package/dist/esm/LinearGradientDemo.mjs +0 -33
  32. package/dist/esm/ListItemDemo.mjs +0 -47
  33. package/dist/esm/LucideIconsDemo.mjs +0 -52
  34. package/dist/esm/PopoverDemo.mjs +0 -76
  35. package/dist/esm/ProgressDemo.mjs +0 -59
  36. package/dist/esm/RadioGroupDemo.mjs +0 -21
  37. package/dist/esm/ReplaceThemeDemo.mjs +0 -49
  38. package/dist/esm/ScrollViewDemo.mjs +0 -18
  39. package/dist/esm/SelectDemo.mjs +0 -137
  40. package/dist/esm/SeparatorDemo.mjs +0 -20
  41. package/dist/esm/ShapesDemo.mjs +0 -12
  42. package/dist/esm/SheetDemo.mjs +0 -91
  43. package/dist/esm/SliderDemo.mjs +0 -19
  44. package/dist/esm/SpinnerDemo.mjs +0 -12
  45. package/dist/esm/StacksDemo.mjs +0 -58
  46. package/dist/esm/SwitchDemo.mjs +0 -33
  47. package/dist/esm/TabsAdvancedDemo.mjs +0 -283
  48. package/dist/esm/TabsDemo.mjs +0 -141
  49. package/dist/esm/TextDemo.mjs +0 -16
  50. package/dist/esm/ThemeInverseDemo.mjs +0 -42
  51. package/dist/esm/ToastDemo.mjs +0 -101
  52. package/dist/esm/ToastDuplicateDemo.mjs +0 -44
  53. package/dist/esm/ToggleGroupDemo.mjs +0 -49
  54. package/dist/esm/TokensDemo.mjs +0 -87
  55. package/dist/esm/TooltipDemo.mjs +0 -68
  56. package/dist/esm/UpdateThemeDemo.mjs +0 -56
  57. package/dist/esm/conf.mjs +0 -5
  58. package/dist/esm/index.mjs +0 -48
  59. package/dist/esm/tamagui.config.mjs +0 -6
  60. package/dist/esm/useOnIntersecting.mjs +0 -68
  61. package/dist/jsx/ButtonHeadlessDemo.mjs +0 -92
  62. package/dist/jsx/ButtonSimpleDemo.mjs +0 -24
@@ -1,283 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- //! debug
3
- import { useState } from "react";
4
- import {
5
- AnimatePresence,
6
- Button,
7
- H5,
8
- SizableText,
9
- Stack,
10
- Tabs,
11
- XStack,
12
- YStack,
13
- styled
14
- } from "tamagui";
15
- const demos = ["background", "underline"];
16
- const demosTitle = {
17
- background: "Background Indicator",
18
- underline: "Underline Indicator"
19
- };
20
- const TabsAdvancedDemo = () => {
21
- const [demoIndex, setDemoIndex] = useState(0);
22
- const demo = demos[demoIndex];
23
- return /* @__PURE__ */ jsxs(Fragment, { children: [
24
- demo === "underline" ? /* @__PURE__ */ jsx(TabsAdvancedUnderline, {}) : /* @__PURE__ */ jsx(TabsAdvancedBackground, {}),
25
- /* @__PURE__ */ jsx(
26
- XStack,
27
- {
28
- alignItems: "center",
29
- space: true,
30
- position: "absolute",
31
- bottom: "$3",
32
- left: "$4",
33
- $xxs: { display: "none" },
34
- children: /* @__PURE__ */ jsx(Button, { size: "$2", onPress: () => setDemoIndex((x) => (x + 1) % demos.length), children: demosTitle[demo] })
35
- }
36
- )
37
- ] });
38
- };
39
- const TabsAdvancedBackground = () => {
40
- const [tabState, setTabState] = useState({
41
- activeAt: null,
42
- currentTab: "tab1",
43
- intentAt: null,
44
- prevActiveAt: null
45
- });
46
- const setCurrentTab = (currentTab2) => setTabState({ ...tabState, currentTab: currentTab2 });
47
- const setIntentIndicator = (intentAt2) => setTabState({ ...tabState, intentAt: intentAt2 });
48
- const setActiveIndicator = (activeAt2) => setTabState({ ...tabState, prevActiveAt: tabState.activeAt, activeAt: activeAt2 });
49
- const { activeAt, intentAt, prevActiveAt, currentTab } = tabState;
50
- const direction = (() => {
51
- if (!activeAt || !prevActiveAt || activeAt.x === prevActiveAt.x) {
52
- return 0;
53
- }
54
- return activeAt.x > prevActiveAt.x ? -1 : 1;
55
- })();
56
- const enterVariant = direction === 1 ? "isLeft" : direction === -1 ? "isRight" : "defaultFade";
57
- const exitVariant = direction === 1 ? "isRight" : direction === -1 ? "isLeft" : "defaultFade";
58
- const handleOnInteraction = (type, layout) => {
59
- if (type === "select") {
60
- setActiveIndicator(layout);
61
- } else {
62
- setIntentIndicator(layout);
63
- }
64
- };
65
- return /* @__PURE__ */ jsxs(
66
- Tabs,
67
- {
68
- value: currentTab,
69
- onValueChange: setCurrentTab,
70
- orientation: "horizontal",
71
- size: "$4",
72
- padding: "$2",
73
- height: 150,
74
- flexDirection: "column",
75
- activationMode: "manual",
76
- backgroundColor: "$background",
77
- borderRadius: "$4",
78
- position: "relative",
79
- children: [
80
- /* @__PURE__ */ jsxs(YStack, { children: [
81
- /* @__PURE__ */ jsx(AnimatePresence, { children: intentAt && /* @__PURE__ */ jsx(
82
- TabsRovingIndicator,
83
- {
84
- borderRadius: "$4",
85
- width: intentAt.width,
86
- height: intentAt.height,
87
- x: intentAt.x,
88
- y: intentAt.y
89
- }
90
- ) }),
91
- /* @__PURE__ */ jsx(AnimatePresence, { children: activeAt && /* @__PURE__ */ jsx(
92
- TabsRovingIndicator,
93
- {
94
- borderRadius: "$4",
95
- theme: "active",
96
- width: activeAt.width,
97
- height: activeAt.height,
98
- x: activeAt.x,
99
- y: activeAt.y
100
- }
101
- ) }),
102
- /* @__PURE__ */ jsxs(
103
- Tabs.List,
104
- {
105
- disablePassBorderRadius: true,
106
- loop: false,
107
- "aria-label": "Manage your account",
108
- space: "$2",
109
- backgroundColor: "transparent",
110
- children: [
111
- /* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab1", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" }) }),
112
- /* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab2", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" }) }),
113
- /* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab3", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" }) })
114
- ]
115
- }
116
- )
117
- ] }),
118
- /* @__PURE__ */ jsx(
119
- AnimatePresence,
120
- {
121
- exitBeforeEnter: true,
122
- enterVariant,
123
- exitVariant,
124
- children: /* @__PURE__ */ jsx(AnimatedYStack, { animation: "100ms", x: 0, opacity: 1, flex: 1, children: /* @__PURE__ */ jsx(Tabs.Content, { value: currentTab, forceMount: true, flex: 1, justifyContent: "center", children: /* @__PURE__ */ jsx(H5, { textAlign: "center", children: currentTab }) }) }, currentTab)
125
- }
126
- )
127
- ]
128
- }
129
- );
130
- };
131
- const TabsAdvancedUnderline = () => {
132
- const [tabState, setTabState] = useState({
133
- activeAt: null,
134
- currentTab: "tab1",
135
- intentAt: null,
136
- prevActiveAt: null
137
- });
138
- const setCurrentTab = (currentTab2) => setTabState({ ...tabState, currentTab: currentTab2 });
139
- const setIntentIndicator = (intentAt2) => setTabState({ ...tabState, intentAt: intentAt2 });
140
- const setActiveIndicator = (activeAt2) => setTabState({ ...tabState, prevActiveAt: tabState.activeAt, activeAt: activeAt2 });
141
- const { activeAt, intentAt, prevActiveAt, currentTab } = tabState;
142
- const direction = (() => {
143
- if (!activeAt || !prevActiveAt || activeAt.x === prevActiveAt.x) {
144
- return 0;
145
- }
146
- return activeAt.x > prevActiveAt.x ? -1 : 1;
147
- })();
148
- const enterVariant = direction === 1 ? "isLeft" : direction === -1 ? "isRight" : "defaultFade";
149
- const exitVariant = direction === 1 ? "isRight" : direction === -1 ? "isLeft" : "defaultFade";
150
- const handleOnInteraction = (type, layout) => {
151
- if (type === "select") {
152
- setActiveIndicator(layout);
153
- } else {
154
- setIntentIndicator(layout);
155
- }
156
- };
157
- return /* @__PURE__ */ jsxs(
158
- Tabs,
159
- {
160
- value: currentTab,
161
- onValueChange: setCurrentTab,
162
- orientation: "horizontal",
163
- size: "$4",
164
- height: 150,
165
- flexDirection: "column",
166
- activationMode: "manual",
167
- backgroundColor: "$background",
168
- borderRadius: "$4",
169
- children: [
170
- /* @__PURE__ */ jsxs(YStack, { children: [
171
- /* @__PURE__ */ jsx(AnimatePresence, { children: intentAt && /* @__PURE__ */ jsx(
172
- TabsRovingIndicator,
173
- {
174
- width: intentAt.width,
175
- height: "$0.5",
176
- x: intentAt.x,
177
- bottom: 0
178
- }
179
- ) }),
180
- /* @__PURE__ */ jsx(AnimatePresence, { children: activeAt && /* @__PURE__ */ jsx(
181
- TabsRovingIndicator,
182
- {
183
- theme: "active",
184
- active: true,
185
- width: activeAt.width,
186
- height: "$0.5",
187
- x: activeAt.x,
188
- bottom: 0
189
- }
190
- ) }),
191
- /* @__PURE__ */ jsxs(
192
- Tabs.List,
193
- {
194
- disablePassBorderRadius: true,
195
- loop: false,
196
- "aria-label": "Manage your account",
197
- borderBottomLeftRadius: 0,
198
- borderBottomRightRadius: 0,
199
- paddingBottom: "$1.5",
200
- borderColor: "$color3",
201
- borderBottomWidth: "$0.5",
202
- backgroundColor: "transparent",
203
- children: [
204
- /* @__PURE__ */ jsx(
205
- Tabs.Tab,
206
- {
207
- unstyled: true,
208
- padding: "$5",
209
- value: "tab1",
210
- onInteraction: handleOnInteraction,
211
- children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" })
212
- }
213
- ),
214
- /* @__PURE__ */ jsx(
215
- Tabs.Tab,
216
- {
217
- unstyled: true,
218
- padding: "$5",
219
- value: "tab2",
220
- onInteraction: handleOnInteraction,
221
- children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" })
222
- }
223
- ),
224
- /* @__PURE__ */ jsx(
225
- Tabs.Tab,
226
- {
227
- unstyled: true,
228
- padding: "$5",
229
- value: "tab3",
230
- onInteraction: handleOnInteraction,
231
- children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" })
232
- }
233
- )
234
- ]
235
- }
236
- )
237
- ] }),
238
- /* @__PURE__ */ jsx(
239
- AnimatePresence,
240
- {
241
- exitBeforeEnter: true,
242
- enterVariant,
243
- exitVariant,
244
- children: /* @__PURE__ */ jsx(AnimatedYStack, { animation: "100ms", x: 0, opacity: 1, flex: 1, children: /* @__PURE__ */ jsx(Tabs.Content, { value: currentTab, forceMount: true, flex: 1, justifyContent: "center", children: /* @__PURE__ */ jsx(H5, { textAlign: "center", children: currentTab }) }) }, currentTab)
245
- }
246
- )
247
- ]
248
- }
249
- );
250
- };
251
- const TabsRovingIndicator = ({ active, ...props }) => {
252
- return /* @__PURE__ */ jsx(
253
- Stack,
254
- {
255
- position: "absolute",
256
- backgroundColor: "$color5",
257
- opacity: 0.7,
258
- animation: "100ms",
259
- enterStyle: {
260
- opacity: 0
261
- },
262
- exitStyle: {
263
- opacity: 0
264
- },
265
- ...active && {
266
- backgroundColor: "$color8",
267
- opacity: 0.6
268
- },
269
- ...props
270
- }
271
- );
272
- };
273
- const AnimatedYStack = styled(YStack, {
274
- variants: {
275
- isLeft: { true: { x: -25, opacity: 0 } },
276
- isRight: { true: { x: 25, opacity: 0 } },
277
- defaultFade: { true: { opacity: 0 } }
278
- }
279
- });
280
- export {
281
- TabsAdvancedDemo
282
- };
283
- //# sourceMappingURL=TabsAdvancedDemo.mjs.map
@@ -1,141 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import {
4
- Button,
5
- H5,
6
- Separator,
7
- SizableText,
8
- Tabs,
9
- XStack,
10
- YStack,
11
- isWeb
12
- } from "tamagui";
13
- const demos = ["horizontal", "vertical"];
14
- const demosTitle = {
15
- horizontal: "Horizontal",
16
- vertical: "Vertical"
17
- };
18
- function TabsDemo() {
19
- const [demoIndex, setDemoIndex] = useState(0);
20
- const demo = demos[demoIndex];
21
- return (
22
- // web only fix for position relative
23
- /* @__PURE__ */ jsxs(
24
- YStack,
25
- {
26
- paddingHorizontal: "$4",
27
- ...isWeb && {
28
- position: "unset"
29
- },
30
- children: [
31
- demo === "horizontal" ? /* @__PURE__ */ jsx(HorizontalTabs, {}) : /* @__PURE__ */ jsx(VerticalTabs, {}),
32
- /* @__PURE__ */ jsx(
33
- XStack,
34
- {
35
- alignItems: "center",
36
- space: true,
37
- position: "absolute",
38
- bottom: "$3",
39
- left: "$4",
40
- $xxs: { display: "none" },
41
- children: /* @__PURE__ */ jsx(Button, { size: "$2", onPress: () => setDemoIndex((x) => (x + 1) % demos.length), children: demosTitle[demo] })
42
- }
43
- )
44
- ]
45
- }
46
- )
47
- );
48
- }
49
- const HorizontalTabs = () => {
50
- return /* @__PURE__ */ jsxs(
51
- Tabs,
52
- {
53
- defaultValue: "tab1",
54
- orientation: "horizontal",
55
- flexDirection: "column",
56
- width: 400,
57
- height: 150,
58
- borderRadius: "$4",
59
- borderWidth: "$0.25",
60
- overflow: "hidden",
61
- borderColor: "$borderColor",
62
- children: [
63
- /* @__PURE__ */ jsxs(
64
- Tabs.List,
65
- {
66
- separator: /* @__PURE__ */ jsx(Separator, { vertical: true }),
67
- disablePassBorderRadius: "bottom",
68
- "aria-label": "Manage your account",
69
- children: [
70
- /* @__PURE__ */ jsx(Tabs.Tab, { flex: 1, value: "tab1", children: /* @__PURE__ */ jsx(SizableText, { fontFamily: "$body", children: "Profile" }) }),
71
- /* @__PURE__ */ jsx(Tabs.Tab, { flex: 1, value: "tab2", children: /* @__PURE__ */ jsx(SizableText, { fontFamily: "$body", children: "Connections" }) }),
72
- /* @__PURE__ */ jsx(Tabs.Tab, { flex: 1, value: "tab3", children: /* @__PURE__ */ jsx(SizableText, { fontFamily: "$body", children: "Notifications" }) })
73
- ]
74
- }
75
- ),
76
- /* @__PURE__ */ jsx(Separator, {}),
77
- /* @__PURE__ */ jsx(TabsContent, { value: "tab1", children: /* @__PURE__ */ jsx(H5, { children: "Profile" }) }),
78
- /* @__PURE__ */ jsx(TabsContent, { value: "tab2", children: /* @__PURE__ */ jsx(H5, { children: "Connections" }) }),
79
- /* @__PURE__ */ jsx(TabsContent, { value: "tab3", children: /* @__PURE__ */ jsx(H5, { children: "Notifications" }) })
80
- ]
81
- }
82
- );
83
- };
84
- const VerticalTabs = () => {
85
- return /* @__PURE__ */ jsxs(
86
- Tabs,
87
- {
88
- defaultValue: "tab1",
89
- flexDirection: "row",
90
- orientation: "vertical",
91
- width: 400,
92
- borderRadius: "$4",
93
- borderWidth: "$0.25",
94
- overflow: "hidden",
95
- borderColor: "$borderColor",
96
- children: [
97
- /* @__PURE__ */ jsxs(
98
- Tabs.List,
99
- {
100
- disablePassBorderRadius: "end",
101
- "aria-label": "Manage your account",
102
- separator: /* @__PURE__ */ jsx(Separator, {}),
103
- children: [
104
- /* @__PURE__ */ jsx(Tabs.Tab, { value: "tab1", children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" }) }),
105
- /* @__PURE__ */ jsx(Tabs.Tab, { value: "tab2", children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" }) }),
106
- /* @__PURE__ */ jsx(Tabs.Tab, { value: "tab3", children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" }) })
107
- ]
108
- }
109
- ),
110
- /* @__PURE__ */ jsx(Separator, { vertical: true }),
111
- /* @__PURE__ */ jsx(TabsContent, { value: "tab1", children: /* @__PURE__ */ jsx(H5, { textAlign: "center", children: "Profile" }) }),
112
- /* @__PURE__ */ jsx(TabsContent, { value: "tab2", children: /* @__PURE__ */ jsx(H5, { textAlign: "center", children: "Connections" }) }),
113
- /* @__PURE__ */ jsx(TabsContent, { value: "tab3", children: /* @__PURE__ */ jsx(H5, { textAlign: "center", children: "Notifications" }) })
114
- ]
115
- }
116
- );
117
- };
118
- const TabsContent = (props) => {
119
- return /* @__PURE__ */ jsx(
120
- Tabs.Content,
121
- {
122
- backgroundColor: "$background",
123
- padding: "$2",
124
- alignItems: "center",
125
- justifyContent: "center",
126
- flex: 1,
127
- borderColor: "$background",
128
- borderRadius: "$2",
129
- borderTopLeftRadius: 0,
130
- borderTopRightRadius: 0,
131
- borderWidth: "$2",
132
- ...props,
133
- children: props.children
134
- },
135
- "tab3"
136
- );
137
- };
138
- export {
139
- TabsDemo
140
- };
141
- //# sourceMappingURL=TabsDemo.mjs.map
@@ -1,16 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Paragraph, SizableText, XStack, YStack } from "tamagui";
3
- function TextDemo() {
4
- return /* @__PURE__ */ jsxs(YStack, { space: "$2", alignItems: "center", children: [
5
- /* @__PURE__ */ jsx(SizableText, { size: "$3", children: "SizableText" }),
6
- /* @__PURE__ */ jsxs(XStack, { space: true, children: [
7
- /* @__PURE__ */ jsx(SizableText, { theme: "alt1", size: "$3", children: "alt1" }),
8
- /* @__PURE__ */ jsx(SizableText, { theme: "alt2", size: "$3", children: "alt2" })
9
- ] }),
10
- /* @__PURE__ */ jsx(Paragraph, { size: "$2", fontWeight: "800", children: "Paragraph" })
11
- ] });
12
- }
13
- export {
14
- TextDemo
15
- };
16
- //# sourceMappingURL=TextDemo.mjs.map
@@ -1,42 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Button, H5, Theme, XStack, YStack, useThemeName } from "tamagui";
3
- function ThemeInverseDemo() {
4
- const themeName = useThemeName();
5
- const opposite = themeName.includes("dark") ? "light" : "dark";
6
- return /* @__PURE__ */ jsxs(XStack, { space: true, children: [
7
- /* @__PURE__ */ jsx(Buttons, { title: "Normal", name: themeName }),
8
- /* @__PURE__ */ jsx(Theme, { inverse: true, children: /* @__PURE__ */ jsx(
9
- Buttons,
10
- {
11
- title: "Inversed",
12
- name: themeName.replace(themeName.split("_")[0], opposite)
13
- }
14
- ) })
15
- ] });
16
- }
17
- function Buttons(props) {
18
- return /* @__PURE__ */ jsxs(
19
- YStack,
20
- {
21
- elevation: "$4",
22
- backgroundColor: "$background",
23
- padding: "$4",
24
- borderRadius: "$4",
25
- space: "$3",
26
- children: [
27
- /* @__PURE__ */ jsx(H5, { children: props.title }),
28
- /* @__PURE__ */ jsx(Button, { children: props.name }),
29
- /* @__PURE__ */ jsx(Button, { themeInverse: true, children: "inversed" }),
30
- /* @__PURE__ */ jsxs(Button, { theme: "alt1", children: [
31
- props.name,
32
- "_alt1"
33
- ] }),
34
- /* @__PURE__ */ jsx(Theme, { name: "yellow", children: /* @__PURE__ */ jsx(Button, { children: props.name.split("_")[0] + "_yellow" }) })
35
- ]
36
- }
37
- );
38
- }
39
- export {
40
- ThemeInverseDemo
41
- };
42
- //# sourceMappingURL=ThemeInverseDemo.mjs.map
@@ -1,101 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Toast, useToastController, useToastState } from "@tamagui/toast";
3
- import React from "react";
4
- import { Button, Label, Switch, XStack, YStack } from "tamagui";
5
- const ToastDemo = () => {
6
- const [native, setNative] = React.useState(false);
7
- return /* @__PURE__ */ jsxs(YStack, { space: true, alignItems: "center", children: [
8
- /* @__PURE__ */ jsx(ToastControl, { native }),
9
- /* @__PURE__ */ jsx(CurrentToast, {}),
10
- /* @__PURE__ */ jsx(NativeOptions, { native, setNative })
11
- ] });
12
- };
13
- const CurrentToast = () => {
14
- const currentToast = useToastState();
15
- if (!currentToast || currentToast.isHandledNatively)
16
- return null;
17
- return /* @__PURE__ */ jsx(
18
- Toast,
19
- {
20
- duration: currentToast.duration,
21
- enterStyle: { opacity: 0, scale: 0.5, y: -25 },
22
- exitStyle: { opacity: 0, scale: 1, y: -20 },
23
- y: 0,
24
- opacity: 1,
25
- scale: 1,
26
- animation: "100ms",
27
- viewportName: currentToast.viewportName,
28
- children: /* @__PURE__ */ jsxs(YStack, { children: [
29
- /* @__PURE__ */ jsx(Toast.Title, { children: currentToast.title }),
30
- !!currentToast.message && /* @__PURE__ */ jsx(Toast.Description, { children: currentToast.message })
31
- ] })
32
- },
33
- currentToast.id
34
- );
35
- };
36
- const ToastControl = ({ native }) => {
37
- const toast = useToastController();
38
- return /* @__PURE__ */ jsxs(XStack, { space: "$2", justifyContent: "center", children: [
39
- /* @__PURE__ */ jsx(
40
- Button,
41
- {
42
- onPress: () => {
43
- toast.show("Successfully saved!", {
44
- message: "Don't worry, we've got your data.",
45
- native
46
- });
47
- },
48
- children: "Show"
49
- }
50
- ),
51
- /* @__PURE__ */ jsx(
52
- Button,
53
- {
54
- id: "wot",
55
- nativeID: "woot",
56
- onPress: () => {
57
- toast.hide();
58
- },
59
- children: "Hide"
60
- }
61
- )
62
- ] });
63
- };
64
- const NativeOptions = ({
65
- native,
66
- setNative
67
- }) => {
68
- return /* @__PURE__ */ jsxs(XStack, { space: "$3", children: [
69
- /* @__PURE__ */ jsx(Label, { size: "$1", onPress: () => setNative(false), children: "Custom" }),
70
- /* @__PURE__ */ jsx(
71
- Switch,
72
- {
73
- debug: "verbose",
74
- id: "native-toggle",
75
- nativeID: "native-toggle",
76
- theme: "active",
77
- size: "$1",
78
- checked: !!native,
79
- onCheckedChange: (val) => setNative(val),
80
- children: /* @__PURE__ */ jsx(
81
- Switch.Thumb,
82
- {
83
- animation: [
84
- "quick",
85
- {
86
- transform: {
87
- overshootClamping: true
88
- }
89
- }
90
- ]
91
- }
92
- )
93
- }
94
- ),
95
- /* @__PURE__ */ jsx(Label, { size: "$1", onPress: () => setNative(true), children: "Native" })
96
- ] });
97
- };
98
- export {
99
- ToastDemo
100
- };
101
- //# sourceMappingURL=ToastDemo.mjs.map
@@ -1,44 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { CheckCircle2 } from "@tamagui/lucide-icons";
3
- import { Toast } from "@tamagui/toast";
4
- import React from "react";
5
- import { Button, XStack, YStack } from "tamagui";
6
- const ToastDuplicateDemo = () => {
7
- const [savedCount, setSavedCount] = React.useState(0);
8
- return /* @__PURE__ */ jsxs(YStack, { alignItems: "center", children: [
9
- /* @__PURE__ */ jsx(
10
- Button,
11
- {
12
- onPress: () => {
13
- setSavedCount((old) => old + 1);
14
- },
15
- children: "Show toast"
16
- }
17
- ),
18
- [...Array(savedCount)].map((_, index) => /* @__PURE__ */ jsx(
19
- Toast,
20
- {
21
- viewportName: "viewport-multiple",
22
- duration: 4e3,
23
- enterStyle: { opacity: 0, scale: 0.5, y: -25 },
24
- exitStyle: { opacity: 0, scale: 1, y: -20 },
25
- y: 0,
26
- opacity: 1,
27
- scale: 1,
28
- animation: "100ms",
29
- children: /* @__PURE__ */ jsxs(XStack, { space: true, alignItems: "center", children: [
30
- /* @__PURE__ */ jsx(YStack, { children: /* @__PURE__ */ jsx(CheckCircle2, {}) }),
31
- /* @__PURE__ */ jsxs(YStack, { children: [
32
- /* @__PURE__ */ jsx(Toast.Title, { children: "Successfully saved!" }),
33
- /* @__PURE__ */ jsx(Toast.Description, { children: "Don't worry... We've got your data." })
34
- ] })
35
- ] })
36
- },
37
- index
38
- ))
39
- ] });
40
- };
41
- export {
42
- ToastDuplicateDemo
43
- };
44
- //# sourceMappingURL=ToastDuplicateDemo.mjs.map
@@ -1,49 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { AlignCenter, AlignLeft, AlignRight } from "@tamagui/lucide-icons";
3
- import { Label, ToggleGroup, XStack, YStack } from "tamagui";
4
- function ToggleGroupDemo() {
5
- return /* @__PURE__ */ jsx(YStack, { paddingHorizontal: "$4", children: /* @__PURE__ */ jsxs(XStack, { alignItems: "center", space: "$10", children: [
6
- /* @__PURE__ */ jsxs(YStack, { alignItems: "center", space: "$6", children: [
7
- /* @__PURE__ */ jsx(ToggleGroupComponent, { type: "single", size: "$3", orientation: "horizontal" }),
8
- /* @__PURE__ */ jsx(ToggleGroupComponent, { type: "multiple", size: "$4", orientation: "horizontal" })
9
- ] }),
10
- /* @__PURE__ */ jsxs(XStack, { alignItems: "center", space: "$6", children: [
11
- /* @__PURE__ */ jsx(ToggleGroupComponent, { type: "single", size: "$3", orientation: "vertical" }),
12
- /* @__PURE__ */ jsx(ToggleGroupComponent, { type: "multiple", size: "$4", orientation: "vertical" })
13
- ] })
14
- ] }) });
15
- }
16
- function ToggleGroupComponent(props) {
17
- const id = `switch-${props.size.toString().slice(1)}-${props.type}`;
18
- return /* @__PURE__ */ jsxs(
19
- XStack,
20
- {
21
- flexDirection: props.orientation === "horizontal" ? "row" : "column",
22
- alignItems: "center",
23
- justifyContent: "center",
24
- space: "$4",
25
- children: [
26
- /* @__PURE__ */ jsx(Label, { paddingRight: "$0", justifyContent: "flex-end", size: props.size, htmlFor: id, children: props.type === "single" ? "Single" : "Multiple" }),
27
- /* @__PURE__ */ jsxs(
28
- ToggleGroup,
29
- {
30
- orientation: props.orientation,
31
- id,
32
- type: props.type,
33
- size: props.size,
34
- disableDeactivation: props.type === "single" ? true : void 0,
35
- children: [
36
- /* @__PURE__ */ jsx(ToggleGroup.Item, { value: "left", "aria-label": "Left aligned", children: /* @__PURE__ */ jsx(AlignLeft, {}) }),
37
- /* @__PURE__ */ jsx(ToggleGroup.Item, { value: "center", "aria-label": "Center aligned", children: /* @__PURE__ */ jsx(AlignCenter, {}) }),
38
- /* @__PURE__ */ jsx(ToggleGroup.Item, { value: "right", "aria-label": "Right aligned", children: /* @__PURE__ */ jsx(AlignRight, {}) })
39
- ]
40
- }
41
- )
42
- ]
43
- }
44
- );
45
- }
46
- export {
47
- ToggleGroupDemo
48
- };
49
- //# sourceMappingURL=ToggleGroupDemo.mjs.map