@tamagui/demos 1.12.0 → 1.12.2
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/TabsAdvancedDemo.js +127 -77
- package/dist/cjs/TabsAdvancedDemo.js.map +2 -2
- package/dist/cjs/TabsDemo.js +61 -79
- package/dist/cjs/TabsDemo.js.map +2 -2
- package/dist/esm/TabsAdvancedDemo.js +127 -77
- package/dist/esm/TabsAdvancedDemo.js.map +2 -2
- package/dist/esm/TabsAdvancedDemo.mjs +127 -77
- package/dist/esm/TabsAdvancedDemo.mjs.map +2 -2
- package/dist/esm/TabsDemo.js +70 -80
- package/dist/esm/TabsDemo.js.map +2 -2
- package/dist/esm/TabsDemo.mjs +70 -80
- package/dist/esm/TabsDemo.mjs.map +2 -2
- package/dist/jsx/TabsAdvancedDemo.js +80 -42
- package/dist/jsx/TabsAdvancedDemo.js.map +2 -2
- package/dist/jsx/TabsAdvancedDemo.mjs +80 -42
- package/dist/jsx/TabsAdvancedDemo.mjs.map +2 -2
- package/dist/jsx/TabsDemo.js +60 -58
- package/dist/jsx/TabsDemo.js.map +2 -2
- package/dist/jsx/TabsDemo.mjs +60 -58
- package/dist/jsx/TabsDemo.mjs.map +2 -2
- package/package.json +17 -17
- package/src/TabsAdvancedDemo.tsx +119 -79
- package/src/TabsDemo.tsx +78 -71
- package/types/TabsAdvancedDemo.d.ts.map +1 -1
- package/types/TabsDemo.d.ts.map +1 -1
|
@@ -12,12 +12,16 @@ import {
|
|
|
12
12
|
styled
|
|
13
13
|
} from "tamagui";
|
|
14
14
|
const demos = ["background", "underline"];
|
|
15
|
+
const demosTitle = {
|
|
16
|
+
background: "Background Indicator",
|
|
17
|
+
underline: "Underline Indicator"
|
|
18
|
+
};
|
|
15
19
|
const TabsAdvancedDemo = () => {
|
|
16
20
|
const [demoIndex, setDemoIndex] = useState(0);
|
|
17
21
|
const demo = demos[demoIndex];
|
|
18
22
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
23
|
demo === "underline" ? /* @__PURE__ */ jsx(TabsAdvancedUnderline, {}) : /* @__PURE__ */ jsx(TabsAdvancedBackground, {}),
|
|
20
|
-
/* @__PURE__ */ jsx(XStack, {
|
|
24
|
+
/* @__PURE__ */ jsx(XStack, { ai: "center", space: true, pos: "absolute", b: "$3", l: "$4", $xxs: { dsp: "none" }, children: /* @__PURE__ */ jsx(Button, { size: "$2", onPress: () => setDemoIndex((x) => (x + 1) % demos.length), children: demosTitle[demo] }) })
|
|
21
25
|
] });
|
|
22
26
|
};
|
|
23
27
|
const TabsAdvancedBackground = () => {
|
|
@@ -52,44 +56,53 @@ const TabsAdvancedBackground = () => {
|
|
|
52
56
|
value: currentTab,
|
|
53
57
|
onValueChange: setCurrentTab,
|
|
54
58
|
orientation: "horizontal",
|
|
55
|
-
size: "$
|
|
59
|
+
size: "$4",
|
|
56
60
|
padding: "$2",
|
|
57
61
|
height: 150,
|
|
58
62
|
flexDirection: "column",
|
|
59
63
|
activationMode: "manual",
|
|
64
|
+
backgroundColor: "$background",
|
|
65
|
+
borderRadius: "$4",
|
|
66
|
+
position: "relative",
|
|
60
67
|
children: [
|
|
61
|
-
/* @__PURE__ */ jsxs(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
intentAt
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
activeAt
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
/* @__PURE__ */ jsxs(YStack, { children: [
|
|
69
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: intentAt && /* @__PURE__ */ jsx(
|
|
70
|
+
TabsRovingIndicator,
|
|
71
|
+
{
|
|
72
|
+
borderRadius: "$4",
|
|
73
|
+
width: intentAt.width,
|
|
74
|
+
height: intentAt.height,
|
|
75
|
+
x: intentAt.x,
|
|
76
|
+
y: intentAt.y
|
|
77
|
+
}
|
|
78
|
+
) }),
|
|
79
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: activeAt && /* @__PURE__ */ jsx(
|
|
80
|
+
TabsRovingIndicator,
|
|
81
|
+
{
|
|
82
|
+
borderRadius: "$4",
|
|
83
|
+
theme: "active",
|
|
84
|
+
width: activeAt.width,
|
|
85
|
+
height: activeAt.height,
|
|
86
|
+
x: activeAt.x,
|
|
87
|
+
y: activeAt.y
|
|
88
|
+
}
|
|
89
|
+
) }),
|
|
90
|
+
/* @__PURE__ */ jsxs(
|
|
91
|
+
Tabs.List,
|
|
92
|
+
{
|
|
93
|
+
disablePassBorderRadius: true,
|
|
94
|
+
loop: false,
|
|
95
|
+
"aria-label": "Manage your account",
|
|
96
|
+
space: "$2",
|
|
97
|
+
backgroundColor: "transparent",
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab1", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" }) }),
|
|
100
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab2", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" }) }),
|
|
101
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab3", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" }) })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }),
|
|
93
106
|
/* @__PURE__ */ jsx(
|
|
94
107
|
AnimatePresence,
|
|
95
108
|
{
|
|
@@ -135,50 +148,81 @@ const TabsAdvancedUnderline = () => {
|
|
|
135
148
|
value: currentTab,
|
|
136
149
|
onValueChange: setCurrentTab,
|
|
137
150
|
orientation: "horizontal",
|
|
138
|
-
size: "$
|
|
139
|
-
padding: "$2",
|
|
151
|
+
size: "$4",
|
|
140
152
|
height: 150,
|
|
141
153
|
flexDirection: "column",
|
|
142
154
|
activationMode: "manual",
|
|
155
|
+
backgroundColor: "$background",
|
|
156
|
+
borderRadius: "$4",
|
|
143
157
|
children: [
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
158
|
+
/* @__PURE__ */ jsxs(YStack, { children: [
|
|
159
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: intentAt && /* @__PURE__ */ jsx(
|
|
160
|
+
TabsRovingIndicator,
|
|
161
|
+
{
|
|
162
|
+
width: intentAt.width,
|
|
163
|
+
height: "$0.5",
|
|
164
|
+
x: intentAt.x,
|
|
165
|
+
bottom: 0
|
|
166
|
+
}
|
|
167
|
+
) }),
|
|
168
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: activeAt && /* @__PURE__ */ jsx(
|
|
169
|
+
TabsRovingIndicator,
|
|
170
|
+
{
|
|
171
|
+
theme: "active",
|
|
172
|
+
active: true,
|
|
173
|
+
width: activeAt.width,
|
|
174
|
+
height: "$0.5",
|
|
175
|
+
x: activeAt.x,
|
|
176
|
+
bottom: 0
|
|
177
|
+
}
|
|
178
|
+
) }),
|
|
179
|
+
/* @__PURE__ */ jsxs(
|
|
180
|
+
Tabs.List,
|
|
181
|
+
{
|
|
182
|
+
disablePassBorderRadius: true,
|
|
183
|
+
loop: false,
|
|
184
|
+
"aria-label": "Manage your account",
|
|
185
|
+
borderBottomLeftRadius: 0,
|
|
186
|
+
borderBottomRightRadius: 0,
|
|
187
|
+
paddingBottom: "$1.5",
|
|
188
|
+
borderColor: "$color3",
|
|
189
|
+
borderBottomWidth: "$0.5",
|
|
190
|
+
backgroundColor: "transparent",
|
|
191
|
+
children: [
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
Tabs.Tab,
|
|
194
|
+
{
|
|
195
|
+
unstyled: true,
|
|
196
|
+
padding: "$5",
|
|
197
|
+
value: "tab1",
|
|
198
|
+
onInteraction: handleOnInteraction,
|
|
199
|
+
children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" })
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ jsx(
|
|
203
|
+
Tabs.Tab,
|
|
204
|
+
{
|
|
205
|
+
unstyled: true,
|
|
206
|
+
padding: "$5",
|
|
207
|
+
value: "tab2",
|
|
208
|
+
onInteraction: handleOnInteraction,
|
|
209
|
+
children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" })
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
Tabs.Tab,
|
|
214
|
+
{
|
|
215
|
+
unstyled: true,
|
|
216
|
+
padding: "$5",
|
|
217
|
+
value: "tab3",
|
|
218
|
+
onInteraction: handleOnInteraction,
|
|
219
|
+
children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" })
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] }),
|
|
182
226
|
/* @__PURE__ */ jsx(
|
|
183
227
|
AnimatePresence,
|
|
184
228
|
{
|
|
@@ -195,13 +239,19 @@ const TabsAdvancedUnderline = () => {
|
|
|
195
239
|
const TabsRovingIndicator = styled(Stack, {
|
|
196
240
|
position: "absolute",
|
|
197
241
|
backgroundColor: "$color5",
|
|
198
|
-
opacity:
|
|
242
|
+
opacity: 0.7,
|
|
199
243
|
animation: "100ms",
|
|
200
|
-
|
|
244
|
+
enterStyle: {
|
|
245
|
+
opacity: 0
|
|
246
|
+
},
|
|
247
|
+
exitStyle: {
|
|
248
|
+
opacity: 0
|
|
249
|
+
},
|
|
201
250
|
variants: {
|
|
202
251
|
active: {
|
|
203
252
|
true: {
|
|
204
|
-
backgroundColor: "$color8"
|
|
253
|
+
backgroundColor: "$color8",
|
|
254
|
+
opacity: 0.6
|
|
205
255
|
}
|
|
206
256
|
}
|
|
207
257
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/TabsAdvancedDemo.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { useState } from 'react'\nimport {\n AnimatePresence,\n Button,\n H5,\n SizableText,\n Stack,\n TabLayout,\n Tabs,\n TabsTabProps,\n XStack,\n YStack,\n styled,\n} from 'tamagui'\n\nconst demos = ['background', 'underline'] as const\nconst demosTitle: Record<(typeof demos)[number], string> = {\n background: 'Background Indicator',\n underline: 'Underline Indicator',\n}\n\nexport const TabsAdvancedDemo = () => {\n const [demoIndex, setDemoIndex] = useState(0)\n const demo = demos[demoIndex]\n return (\n <>\n {demo === 'underline' ? <TabsAdvancedUnderline /> : <TabsAdvancedBackground />}\n\n <XStack ai=\"center\" space pos=\"absolute\" b=\"$3\" l=\"$4\" $xxs={{ dsp: 'none' }}>\n <Button size=\"$2\" onPress={() => setDemoIndex((x) => (x + 1) % demos.length)}>\n {demosTitle[demo]}\n </Button>\n </XStack>\n </>\n )\n}\n\nconst TabsAdvancedBackground = () => {\n const [tabState, setTabState] = useState<{\n currentTab: string\n /**\n * Layout of the Tab user might intend to select (hovering / focusing)\n */\n intentAt: TabLayout | null\n /**\n * Layout of the Tab user selected\n */\n activeAt: TabLayout | null\n /**\n * Used to get the direction of activation for animating the active indicator\n */\n prevActiveAt: TabLayout | null\n }>({\n activeAt: null,\n currentTab: 'tab1',\n intentAt: null,\n prevActiveAt: null,\n })\n\n const setCurrentTab = (currentTab: string) => setTabState({ ...tabState, currentTab })\n const setIntentIndicator = (intentAt) => setTabState({ ...tabState, intentAt })\n const setActiveIndicator = (activeAt) =>\n setTabState({ ...tabState, prevActiveAt: tabState.activeAt, activeAt })\n const { activeAt, intentAt, prevActiveAt, currentTab } = tabState\n\n /**\n * -1: from left\n * 0: n/a\n * 1: from right\n */\n const direction = (() => {\n if (!activeAt || !prevActiveAt || activeAt.x === prevActiveAt.x) {\n return 0\n }\n return activeAt.x > prevActiveAt.x ? -1 : 1\n })()\n\n const enterVariant =\n direction === 1 ? 'isLeft' : direction === -1 ? 'isRight' : 'defaultFade'\n const exitVariant =\n direction === 1 ? 'isRight' : direction === -1 ? 'isLeft' : 'defaultFade'\n\n const handleOnInteraction: TabsTabProps['onInteraction'] = (type, layout) => {\n if (type === 'select') {\n setActiveIndicator(layout)\n } else {\n setIntentIndicator(layout)\n }\n }\n\n return (\n <Tabs\n value={currentTab}\n onValueChange={setCurrentTab}\n orientation=\"horizontal\"\n size=\"$4\"\n padding=\"$2\"\n height={150}\n flexDirection=\"column\"\n activationMode=\"manual\"\n backgroundColor=\"$background\"\n borderRadius=\"$4\"\n position=\"relative\"\n >\n <YStack>\n <AnimatePresence>\n {intentAt && (\n <TabsRovingIndicator\n borderRadius=\"$4\"\n width={intentAt.width}\n height={intentAt.height}\n x={intentAt.x}\n y={intentAt.y}\n />\n )}\n </AnimatePresence>\n <AnimatePresence>\n {activeAt && (\n <TabsRovingIndicator\n borderRadius=\"$4\"\n theme=\"active\"\n width={activeAt.width}\n height={activeAt.height}\n x={activeAt.x}\n y={activeAt.y}\n />\n )}\n </AnimatePresence>\n\n <Tabs.List\n disablePassBorderRadius\n loop={false}\n aria-label=\"Manage your account\"\n space=\"$2\"\n backgroundColor=\"transparent\"\n >\n <Tabs.Tab unstyled value=\"tab1\" onInteraction={handleOnInteraction}>\n <SizableText>Profile</SizableText>\n </Tabs.Tab>\n <Tabs.Tab unstyled value=\"tab2\" onInteraction={handleOnInteraction}>\n <SizableText>Connections</SizableText>\n </Tabs.Tab>\n <Tabs.Tab unstyled value=\"tab3\" onInteraction={handleOnInteraction}>\n <SizableText>Notifications</SizableText>\n </Tabs.Tab>\n </Tabs.List>\n </YStack>\n\n <AnimatePresence\n exitBeforeEnter\n enterVariant={enterVariant}\n exitVariant={exitVariant}\n >\n <AnimatedYStack key={currentTab} animation=\"100ms\" x={0} opacity={1} flex={1}>\n <Tabs.Content value={currentTab} forceMount flex={1} justifyContent=\"center\">\n <H5 textAlign=\"center\">{currentTab}</H5>\n </Tabs.Content>\n </AnimatedYStack>\n </AnimatePresence>\n </Tabs>\n )\n}\n\nconst TabsAdvancedUnderline = () => {\n const [tabState, setTabState] = useState<{\n currentTab: string\n /**\n * Layout of the Tab user might intend to select (hovering / focusing)\n */\n intentAt: TabLayout | null\n /**\n * Layout of the Tab user selected\n */\n activeAt: TabLayout | null\n /**\n * Used to get the direction of activation for animating the active indicator\n */\n prevActiveAt: TabLayout | null\n }>({\n activeAt: null,\n currentTab: 'tab1',\n intentAt: null,\n prevActiveAt: null,\n })\n\n const setCurrentTab = (currentTab: string) => setTabState({ ...tabState, currentTab })\n const setIntentIndicator = (intentAt) => setTabState({ ...tabState, intentAt })\n const setActiveIndicator = (activeAt) =>\n setTabState({ ...tabState, prevActiveAt: tabState.activeAt, activeAt })\n const { activeAt, intentAt, prevActiveAt, currentTab } = tabState\n\n /**\n * -1: from left\n * 0: n/a\n * 1: from right\n */\n const direction = (() => {\n if (!activeAt || !prevActiveAt || activeAt.x === prevActiveAt.x) {\n return 0\n }\n return activeAt.x > prevActiveAt.x ? -1 : 1\n })()\n\n const enterVariant =\n direction === 1 ? 'isLeft' : direction === -1 ? 'isRight' : 'defaultFade'\n const exitVariant =\n direction === 1 ? 'isRight' : direction === -1 ? 'isLeft' : 'defaultFade'\n\n const handleOnInteraction: TabsTabProps['onInteraction'] = (type, layout) => {\n if (type === 'select') {\n setActiveIndicator(layout)\n } else {\n setIntentIndicator(layout)\n }\n }\n\n return (\n <Tabs\n value={currentTab}\n onValueChange={setCurrentTab}\n orientation=\"horizontal\"\n size=\"$4\"\n height={150}\n flexDirection=\"column\"\n activationMode=\"manual\"\n backgroundColor=\"$background\"\n borderRadius=\"$4\"\n >\n <YStack>\n <AnimatePresence>\n {intentAt && (\n <TabsRovingIndicator\n width={intentAt.width}\n height=\"$0.5\"\n x={intentAt.x}\n bottom={0}\n />\n )}\n </AnimatePresence>\n <AnimatePresence>\n {activeAt && (\n <TabsRovingIndicator\n theme=\"active\"\n active\n width={activeAt.width}\n height=\"$0.5\"\n x={activeAt.x}\n bottom={0}\n />\n )}\n </AnimatePresence>\n <Tabs.List\n disablePassBorderRadius\n loop={false}\n aria-label=\"Manage your account\"\n borderBottomLeftRadius={0}\n borderBottomRightRadius={0}\n paddingBottom=\"$1.5\"\n borderColor=\"$color3\"\n borderBottomWidth=\"$0.5\"\n backgroundColor=\"transparent\"\n >\n <Tabs.Tab\n unstyled\n padding=\"$5\"\n value=\"tab1\"\n onInteraction={handleOnInteraction}\n >\n <SizableText>Profile</SizableText>\n </Tabs.Tab>\n <Tabs.Tab\n unstyled\n padding=\"$5\"\n value=\"tab2\"\n onInteraction={handleOnInteraction}\n >\n <SizableText>Connections</SizableText>\n </Tabs.Tab>\n <Tabs.Tab\n unstyled\n padding=\"$5\"\n value=\"tab3\"\n onInteraction={handleOnInteraction}\n >\n <SizableText>Notifications</SizableText>\n </Tabs.Tab>\n </Tabs.List>\n </YStack>\n\n <AnimatePresence\n exitBeforeEnter\n enterVariant={enterVariant}\n exitVariant={exitVariant}\n >\n <AnimatedYStack key={currentTab} animation=\"100ms\" x={0} opacity={1} flex={1}>\n <Tabs.Content value={currentTab} forceMount flex={1} justifyContent=\"center\">\n <H5 textAlign=\"center\">{currentTab}</H5>\n </Tabs.Content>\n </AnimatedYStack>\n </AnimatePresence>\n </Tabs>\n )\n}\n\nconst TabsRovingIndicator = styled(Stack, {\n position: 'absolute',\n backgroundColor: '$color5',\n opacity: 0.7,\n animation: '100ms',\n enterStyle: {\n opacity: 0,\n },\n exitStyle: {\n opacity: 0,\n },\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n opacity: 0.6,\n },\n },\n },\n})\n\nconst AnimatedYStack = styled(YStack, {\n variants: {\n isLeft: { true: { x: -25, opacity: 0 } },\n isRight: { true: { x: 25, opacity: 0 } },\n defaultFade: { true: { opacity: 0 } },\n } as const,\n})\n"],
|
|
5
|
+
"mappings": "AAyBI,mBAC0B,KAD1B;AAzBJ,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,QAAQ,CAAC,cAAc,WAAW;AACxC,MAAM,aAAqD;AAAA,EACzD,YAAY;AAAA,EACZ,WAAW;AACb;AAEO,MAAM,mBAAmB,MAAM;AACpC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,CAAC;AAC5C,QAAM,OAAO,MAAM,SAAS;AAC5B,SACE,iCACG;AAAA,aAAS,cAAc,oBAAC,yBAAsB,IAAK,oBAAC,0BAAuB;AAAA,IAE5E,oBAAC,UAAO,IAAG,UAAS,OAAK,MAAC,KAAI,YAAW,GAAE,MAAK,GAAE,MAAK,MAAM,EAAE,KAAK,OAAO,GACzE,8BAAC,UAAO,MAAK,MAAK,SAAS,MAAM,aAAa,CAAC,OAAO,IAAI,KAAK,MAAM,MAAM,GACxE,qBAAW,IAAI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C,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACV,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,IACR,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,iBAAiB;AAAA,QACjB,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,MAAM,iBAAiB,OAAO,QAAQ;AAAA,EACpC,UAAU;AAAA,IACR,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,SAAS,EAAE,EAAE;AAAA,IACvC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,SAAS,EAAE,EAAE;AAAA,IACvC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;AAAA,EACtC;AACF,CAAC;",
|
|
6
6
|
"names": ["currentTab", "intentAt", "activeAt"]
|
|
7
7
|
}
|
|
@@ -12,12 +12,16 @@ import {
|
|
|
12
12
|
styled
|
|
13
13
|
} from "tamagui";
|
|
14
14
|
const demos = ["background", "underline"];
|
|
15
|
+
const demosTitle = {
|
|
16
|
+
background: "Background Indicator",
|
|
17
|
+
underline: "Underline Indicator"
|
|
18
|
+
};
|
|
15
19
|
const TabsAdvancedDemo = () => {
|
|
16
20
|
const [demoIndex, setDemoIndex] = useState(0);
|
|
17
21
|
const demo = demos[demoIndex];
|
|
18
22
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
23
|
demo === "underline" ? /* @__PURE__ */ jsx(TabsAdvancedUnderline, {}) : /* @__PURE__ */ jsx(TabsAdvancedBackground, {}),
|
|
20
|
-
/* @__PURE__ */ jsx(XStack, {
|
|
24
|
+
/* @__PURE__ */ jsx(XStack, { ai: "center", space: true, pos: "absolute", b: "$3", l: "$4", $xxs: { dsp: "none" }, children: /* @__PURE__ */ jsx(Button, { size: "$2", onPress: () => setDemoIndex((x) => (x + 1) % demos.length), children: demosTitle[demo] }) })
|
|
21
25
|
] });
|
|
22
26
|
};
|
|
23
27
|
const TabsAdvancedBackground = () => {
|
|
@@ -52,44 +56,53 @@ const TabsAdvancedBackground = () => {
|
|
|
52
56
|
value: currentTab,
|
|
53
57
|
onValueChange: setCurrentTab,
|
|
54
58
|
orientation: "horizontal",
|
|
55
|
-
size: "$
|
|
59
|
+
size: "$4",
|
|
56
60
|
padding: "$2",
|
|
57
61
|
height: 150,
|
|
58
62
|
flexDirection: "column",
|
|
59
63
|
activationMode: "manual",
|
|
64
|
+
backgroundColor: "$background",
|
|
65
|
+
borderRadius: "$4",
|
|
66
|
+
position: "relative",
|
|
60
67
|
children: [
|
|
61
|
-
/* @__PURE__ */ jsxs(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
intentAt
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
activeAt
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
/* @__PURE__ */ jsxs(YStack, { children: [
|
|
69
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: intentAt && /* @__PURE__ */ jsx(
|
|
70
|
+
TabsRovingIndicator,
|
|
71
|
+
{
|
|
72
|
+
borderRadius: "$4",
|
|
73
|
+
width: intentAt.width,
|
|
74
|
+
height: intentAt.height,
|
|
75
|
+
x: intentAt.x,
|
|
76
|
+
y: intentAt.y
|
|
77
|
+
}
|
|
78
|
+
) }),
|
|
79
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: activeAt && /* @__PURE__ */ jsx(
|
|
80
|
+
TabsRovingIndicator,
|
|
81
|
+
{
|
|
82
|
+
borderRadius: "$4",
|
|
83
|
+
theme: "active",
|
|
84
|
+
width: activeAt.width,
|
|
85
|
+
height: activeAt.height,
|
|
86
|
+
x: activeAt.x,
|
|
87
|
+
y: activeAt.y
|
|
88
|
+
}
|
|
89
|
+
) }),
|
|
90
|
+
/* @__PURE__ */ jsxs(
|
|
91
|
+
Tabs.List,
|
|
92
|
+
{
|
|
93
|
+
disablePassBorderRadius: true,
|
|
94
|
+
loop: false,
|
|
95
|
+
"aria-label": "Manage your account",
|
|
96
|
+
space: "$2",
|
|
97
|
+
backgroundColor: "transparent",
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab1", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" }) }),
|
|
100
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab2", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" }) }),
|
|
101
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { unstyled: true, value: "tab3", onInteraction: handleOnInteraction, children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" }) })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }),
|
|
93
106
|
/* @__PURE__ */ jsx(
|
|
94
107
|
AnimatePresence,
|
|
95
108
|
{
|
|
@@ -135,50 +148,81 @@ const TabsAdvancedUnderline = () => {
|
|
|
135
148
|
value: currentTab,
|
|
136
149
|
onValueChange: setCurrentTab,
|
|
137
150
|
orientation: "horizontal",
|
|
138
|
-
size: "$
|
|
139
|
-
padding: "$2",
|
|
151
|
+
size: "$4",
|
|
140
152
|
height: 150,
|
|
141
153
|
flexDirection: "column",
|
|
142
154
|
activationMode: "manual",
|
|
155
|
+
backgroundColor: "$background",
|
|
156
|
+
borderRadius: "$4",
|
|
143
157
|
children: [
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
158
|
+
/* @__PURE__ */ jsxs(YStack, { children: [
|
|
159
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: intentAt && /* @__PURE__ */ jsx(
|
|
160
|
+
TabsRovingIndicator,
|
|
161
|
+
{
|
|
162
|
+
width: intentAt.width,
|
|
163
|
+
height: "$0.5",
|
|
164
|
+
x: intentAt.x,
|
|
165
|
+
bottom: 0
|
|
166
|
+
}
|
|
167
|
+
) }),
|
|
168
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: activeAt && /* @__PURE__ */ jsx(
|
|
169
|
+
TabsRovingIndicator,
|
|
170
|
+
{
|
|
171
|
+
theme: "active",
|
|
172
|
+
active: true,
|
|
173
|
+
width: activeAt.width,
|
|
174
|
+
height: "$0.5",
|
|
175
|
+
x: activeAt.x,
|
|
176
|
+
bottom: 0
|
|
177
|
+
}
|
|
178
|
+
) }),
|
|
179
|
+
/* @__PURE__ */ jsxs(
|
|
180
|
+
Tabs.List,
|
|
181
|
+
{
|
|
182
|
+
disablePassBorderRadius: true,
|
|
183
|
+
loop: false,
|
|
184
|
+
"aria-label": "Manage your account",
|
|
185
|
+
borderBottomLeftRadius: 0,
|
|
186
|
+
borderBottomRightRadius: 0,
|
|
187
|
+
paddingBottom: "$1.5",
|
|
188
|
+
borderColor: "$color3",
|
|
189
|
+
borderBottomWidth: "$0.5",
|
|
190
|
+
backgroundColor: "transparent",
|
|
191
|
+
children: [
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
Tabs.Tab,
|
|
194
|
+
{
|
|
195
|
+
unstyled: true,
|
|
196
|
+
padding: "$5",
|
|
197
|
+
value: "tab1",
|
|
198
|
+
onInteraction: handleOnInteraction,
|
|
199
|
+
children: /* @__PURE__ */ jsx(SizableText, { children: "Profile" })
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ jsx(
|
|
203
|
+
Tabs.Tab,
|
|
204
|
+
{
|
|
205
|
+
unstyled: true,
|
|
206
|
+
padding: "$5",
|
|
207
|
+
value: "tab2",
|
|
208
|
+
onInteraction: handleOnInteraction,
|
|
209
|
+
children: /* @__PURE__ */ jsx(SizableText, { children: "Connections" })
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
Tabs.Tab,
|
|
214
|
+
{
|
|
215
|
+
unstyled: true,
|
|
216
|
+
padding: "$5",
|
|
217
|
+
value: "tab3",
|
|
218
|
+
onInteraction: handleOnInteraction,
|
|
219
|
+
children: /* @__PURE__ */ jsx(SizableText, { children: "Notifications" })
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] }),
|
|
182
226
|
/* @__PURE__ */ jsx(
|
|
183
227
|
AnimatePresence,
|
|
184
228
|
{
|
|
@@ -195,13 +239,19 @@ const TabsAdvancedUnderline = () => {
|
|
|
195
239
|
const TabsRovingIndicator = styled(Stack, {
|
|
196
240
|
position: "absolute",
|
|
197
241
|
backgroundColor: "$color5",
|
|
198
|
-
opacity:
|
|
242
|
+
opacity: 0.7,
|
|
199
243
|
animation: "100ms",
|
|
200
|
-
|
|
244
|
+
enterStyle: {
|
|
245
|
+
opacity: 0
|
|
246
|
+
},
|
|
247
|
+
exitStyle: {
|
|
248
|
+
opacity: 0
|
|
249
|
+
},
|
|
201
250
|
variants: {
|
|
202
251
|
active: {
|
|
203
252
|
true: {
|
|
204
|
-
backgroundColor: "$color8"
|
|
253
|
+
backgroundColor: "$color8",
|
|
254
|
+
opacity: 0.6
|
|
205
255
|
}
|
|
206
256
|
}
|
|
207
257
|
}
|