@tamagui/demos 1.6.3 → 1.7.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/AnimationsPresenceDemo.js +3 -3
- package/dist/cjs/LucideIconsDemo.js +1 -1
- package/dist/cjs/ProgressDemo.js +2 -2
- package/dist/cjs/ProgressDemo.js.map +2 -2
- package/dist/cjs/SliderDemo.js +1 -1
- package/dist/cjs/SliderDemo.js.map +2 -2
- package/dist/cjs/TabsAdvancedDemo.js +138 -0
- package/dist/cjs/TabsAdvancedDemo.js.map +7 -0
- package/dist/cjs/TabsDemo.js +85 -0
- package/dist/cjs/TabsDemo.js.map +7 -0
- package/dist/cjs/TabsHighlightedDemo.js +188 -0
- package/dist/cjs/TabsHighlightedDemo.js.map +7 -0
- package/dist/cjs/TabsUnderlinedDemo.js +176 -0
- package/dist/cjs/TabsUnderlinedDemo.js.map +7 -0
- package/dist/cjs/UpdateThemeDemo.js +1 -1
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/ProgressDemo.js +2 -2
- package/dist/esm/ProgressDemo.js.map +2 -2
- package/dist/esm/ProgressDemo.mjs +2 -2
- package/dist/esm/ProgressDemo.mjs.map +2 -2
- package/dist/esm/SliderDemo.js +1 -1
- package/dist/esm/SliderDemo.js.map +2 -2
- package/dist/esm/SliderDemo.mjs +1 -1
- package/dist/esm/SliderDemo.mjs.map +2 -2
- package/dist/esm/TabsAdvancedDemo.js +122 -0
- package/dist/esm/TabsAdvancedDemo.js.map +7 -0
- package/dist/esm/TabsAdvancedDemo.mjs +122 -0
- package/dist/esm/TabsAdvancedDemo.mjs.map +7 -0
- package/dist/esm/TabsDemo.js +61 -0
- package/dist/esm/TabsDemo.js.map +7 -0
- package/dist/esm/TabsDemo.mjs +61 -0
- package/dist/esm/TabsDemo.mjs.map +7 -0
- package/dist/esm/TabsHighlightedDemo.js +172 -0
- package/dist/esm/TabsHighlightedDemo.js.map +7 -0
- package/dist/esm/TabsHighlightedDemo.mjs +172 -0
- package/dist/esm/TabsHighlightedDemo.mjs.map +7 -0
- package/dist/esm/TabsUnderlinedDemo.js +160 -0
- package/dist/esm/TabsUnderlinedDemo.js.map +7 -0
- package/dist/esm/TabsUnderlinedDemo.mjs +160 -0
- package/dist/esm/TabsUnderlinedDemo.mjs.map +7 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +2 -2
- package/dist/jsx/ProgressDemo.js +2 -2
- package/dist/jsx/ProgressDemo.js.map +2 -2
- package/dist/jsx/ProgressDemo.mjs +2 -2
- package/dist/jsx/ProgressDemo.mjs.map +2 -2
- package/dist/jsx/SliderDemo.js +1 -1
- package/dist/jsx/SliderDemo.js.map +2 -2
- package/dist/jsx/SliderDemo.mjs +1 -1
- package/dist/jsx/SliderDemo.mjs.map +2 -2
- package/dist/jsx/TabsAdvancedDemo.js +103 -0
- package/dist/jsx/TabsAdvancedDemo.js.map +7 -0
- package/dist/jsx/TabsAdvancedDemo.mjs +103 -0
- package/dist/jsx/TabsAdvancedDemo.mjs.map +7 -0
- package/dist/jsx/TabsDemo.js +52 -0
- package/dist/jsx/TabsDemo.js.map +7 -0
- package/dist/jsx/TabsDemo.mjs +52 -0
- package/dist/jsx/TabsDemo.mjs.map +7 -0
- package/dist/jsx/TabsHighlightedDemo.js +141 -0
- package/dist/jsx/TabsHighlightedDemo.js.map +7 -0
- package/dist/jsx/TabsHighlightedDemo.mjs +141 -0
- package/dist/jsx/TabsHighlightedDemo.mjs.map +7 -0
- package/dist/jsx/TabsUnderlinedDemo.js +133 -0
- package/dist/jsx/TabsUnderlinedDemo.js.map +7 -0
- package/dist/jsx/TabsUnderlinedDemo.mjs +133 -0
- package/dist/jsx/TabsUnderlinedDemo.mjs.map +7 -0
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/index.mjs +4 -0
- package/dist/jsx/index.mjs.map +2 -2
- package/package.json +17 -18
- package/src/ProgressDemo.tsx +2 -2
- package/src/SliderDemo.tsx +1 -1
- package/src/TabsAdvancedDemo.tsx +148 -0
- package/src/TabsDemo.tsx +91 -0
- package/src/index.tsx +2 -0
- package/types/TabsAdvancedDemo.d.ts +3 -0
- package/types/TabsAdvancedDemo.d.ts.map +1 -0
- package/types/TabsDemo.d.ts +3 -0
- package/types/TabsDemo.d.ts.map +1 -0
- package/types/TabsHighlightedDemo.d.ts.map +1 -0
- package/types/TabsUnderlinedDemo.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
H5,
|
|
5
|
+
Stack,
|
|
6
|
+
Tabs,
|
|
7
|
+
XStack,
|
|
8
|
+
YStack,
|
|
9
|
+
styled
|
|
10
|
+
} from "tamagui";
|
|
11
|
+
function TabsHighlightedDemo() {
|
|
12
|
+
return <XStack maxHeight="100%" maxWidth="100%" justifyContent="flex-start" px="$4"><HighlightTabs /></XStack>;
|
|
13
|
+
}
|
|
14
|
+
const TabsRovingIndicator = styled(Stack, {
|
|
15
|
+
name: "TabsRovingIndicator",
|
|
16
|
+
variants: {
|
|
17
|
+
active: {
|
|
18
|
+
true: {
|
|
19
|
+
backgroundColor: "$color8"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
active: {
|
|
24
|
+
true: {
|
|
25
|
+
backgroundColor: "$color8"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
enter: {
|
|
29
|
+
true: {
|
|
30
|
+
opacity: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
exit: {
|
|
34
|
+
true: {
|
|
35
|
+
opacity: 0
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
backgroundColor: "$color5",
|
|
43
|
+
opacity: 1,
|
|
44
|
+
animation: "100ms",
|
|
45
|
+
borderRadius: "$4"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const AnimatedYStack = styled(YStack, {
|
|
49
|
+
variants: {
|
|
50
|
+
isLeft: { true: { x: -25, opacity: 0 } },
|
|
51
|
+
isRight: { true: { x: 25, opacity: 0 } }
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const HighlightTabs = () => {
|
|
55
|
+
const [currentTab, setCurrentTab] = useState("tab1");
|
|
56
|
+
const [focusIndicatorLayout, setFocusIndicatorLayout] = useState(null);
|
|
57
|
+
const [hoverIndicatorLayout, setHoverIndicatorLayout] = useState(null);
|
|
58
|
+
const [selectionIndicatorLayout, setSelectionIndicatorLayout] = useState(null);
|
|
59
|
+
const prevSelectionIndicatorLayout = useRef(null);
|
|
60
|
+
const handleUpdateSelectionIndicator = (newSize) => {
|
|
61
|
+
prevSelectionIndicatorLayout.current = selectionIndicatorLayout;
|
|
62
|
+
setSelectionIndicatorLayout(newSize);
|
|
63
|
+
};
|
|
64
|
+
const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout;
|
|
65
|
+
const direction = useMemo(() => {
|
|
66
|
+
if (!selectionIndicatorLayout || !prevSelectionIndicatorLayout.current || selectionIndicatorLayout.x === prevSelectionIndicatorLayout.current.x) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
return selectionIndicatorLayout.x > prevSelectionIndicatorLayout.current.x ? 1 : -1;
|
|
70
|
+
}, [selectionIndicatorLayout]);
|
|
71
|
+
const enterVariant = direction === 1 ? "isLeft" : direction === -1 ? "isRight" : void 0;
|
|
72
|
+
const exitVariant = direction === 1 ? "isRight" : direction === -1 ? "isLeft" : void 0;
|
|
73
|
+
return <Tabs
|
|
74
|
+
value={currentTab}
|
|
75
|
+
onValueChange={setCurrentTab}
|
|
76
|
+
orientation="horizontal"
|
|
77
|
+
br="$4"
|
|
78
|
+
p="$2"
|
|
79
|
+
height={150}
|
|
80
|
+
flexDirection="column"
|
|
81
|
+
activationMode="manual"
|
|
82
|
+
>
|
|
83
|
+
<Tabs.List
|
|
84
|
+
loop={false}
|
|
85
|
+
aria-label="Manage your account"
|
|
86
|
+
disablePassBorderRadius
|
|
87
|
+
overflow="visible"
|
|
88
|
+
>
|
|
89
|
+
{intentIndicatorLayout && <TabsRovingIndicator
|
|
90
|
+
width={intentIndicatorLayout.width}
|
|
91
|
+
height={intentIndicatorLayout.height}
|
|
92
|
+
x={intentIndicatorLayout.x}
|
|
93
|
+
y={intentIndicatorLayout.y}
|
|
94
|
+
/>}
|
|
95
|
+
{selectionIndicatorLayout && <TabsRovingIndicator
|
|
96
|
+
theme="active"
|
|
97
|
+
active
|
|
98
|
+
width={selectionIndicatorLayout.width}
|
|
99
|
+
height={2}
|
|
100
|
+
x={selectionIndicatorLayout.x}
|
|
101
|
+
y={40}
|
|
102
|
+
/>}
|
|
103
|
+
<Tabs.Trigger
|
|
104
|
+
unstyled
|
|
105
|
+
color="$color12"
|
|
106
|
+
value="tab1"
|
|
107
|
+
size="$3"
|
|
108
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
109
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
110
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
111
|
+
>Profile</Tabs.Trigger>
|
|
112
|
+
<Tabs.Trigger
|
|
113
|
+
unstyled
|
|
114
|
+
color="$color12"
|
|
115
|
+
size="$3"
|
|
116
|
+
value="tab2"
|
|
117
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
118
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
119
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
120
|
+
>Connections</Tabs.Trigger>
|
|
121
|
+
<Tabs.Trigger
|
|
122
|
+
unstyled
|
|
123
|
+
color="$color12"
|
|
124
|
+
size="$3"
|
|
125
|
+
value="tab3"
|
|
126
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
127
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
128
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
129
|
+
>Notifications</Tabs.Trigger>
|
|
130
|
+
</Tabs.List>
|
|
131
|
+
<YStack f={1}><AnimatePresence
|
|
132
|
+
exitBeforeEnter
|
|
133
|
+
enterVariant={enterVariant}
|
|
134
|
+
exitVariant={exitVariant}
|
|
135
|
+
><AnimatedYStack key={currentTab} animation="100ms" x={0} o={1} f={1}><Tabs.Content value={currentTab} forceMount p="$2" f={1} jc="center"><H5 ta="center">{currentTab}</H5></Tabs.Content></AnimatedYStack></AnimatePresence></YStack>
|
|
136
|
+
</Tabs>;
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
TabsHighlightedDemo
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=TabsHighlightedDemo.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/TabsHighlightedDemo.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useRef, useState } from 'react'\nimport {\n AnimatePresence,\n H5,\n Stack,\n TabTriggerLayout,\n Tabs,\n XStack,\n YStack,\n styled,\n} from 'tamagui'\n\nexport function TabsHighlightedDemo() {\n return (\n <XStack maxHeight=\"100%\" maxWidth=\"100%\" justifyContent=\"flex-start\" px=\"$4\">\n <HighlightTabs />\n </XStack>\n )\n}\n\nconst TabsRovingIndicator = styled(Stack, {\n name: 'TabsRovingIndicator',\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n enter: {\n true: {\n opacity: 0,\n },\n },\n exit: {\n true: {\n opacity: 0,\n },\n },\n },\n },\n defaultVariants: {\n position: 'absolute',\n backgroundColor: '$color5',\n opacity: 1,\n animation: '100ms',\n borderRadius: '$4',\n },\n})\n\nconst AnimatedYStack = styled(YStack, {\n variants: {\n isLeft: { true: { x: -25, opacity: 0 } },\n isRight: { true: { x: 25, opacity: 0 } },\n } as const,\n})\n\nconst HighlightTabs = () => {\n const [currentTab, setCurrentTab] = useState('tab1')\n const [focusIndicatorLayout, setFocusIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [hoverIndicatorLayout, setHoverIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [selectionIndicatorLayout, setSelectionIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const prevSelectionIndicatorLayout = useRef<TabTriggerLayout | null>(null)\n const handleUpdateSelectionIndicator = (newSize: TabTriggerLayout | null) => {\n prevSelectionIndicatorLayout.current = selectionIndicatorLayout\n setSelectionIndicatorLayout(newSize)\n }\n\n const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout\n\n /**\n * -1: from left\n * 0: n/a\n * 1: from right\n */\n const direction = useMemo(() => {\n if (\n !selectionIndicatorLayout ||\n !prevSelectionIndicatorLayout.current ||\n selectionIndicatorLayout.x === prevSelectionIndicatorLayout.current.x\n ) {\n return 0\n }\n return selectionIndicatorLayout.x > prevSelectionIndicatorLayout.current.x ? 1 : -1\n }, [selectionIndicatorLayout])\n\n const enterVariant =\n direction === 1 ? 'isLeft' : direction === -1 ? 'isRight' : undefined\n const exitVariant =\n direction === 1 ? 'isRight' : direction === -1 ? 'isLeft' : undefined\n\n return (\n <Tabs\n value={currentTab}\n onValueChange={setCurrentTab}\n orientation=\"horizontal\"\n br=\"$4\"\n p=\"$2\"\n height={150}\n flexDirection=\"column\"\n activationMode=\"manual\"\n >\n <Tabs.List\n loop={false}\n aria-label=\"Manage your account\"\n disablePassBorderRadius\n overflow=\"visible\"\n >\n {intentIndicatorLayout && (\n <TabsRovingIndicator\n width={intentIndicatorLayout.width}\n height={intentIndicatorLayout.height}\n x={intentIndicatorLayout.x}\n y={intentIndicatorLayout.y}\n />\n )}\n\n {selectionIndicatorLayout && (\n <TabsRovingIndicator\n theme=\"active\"\n active\n width={selectionIndicatorLayout.width}\n height={2}\n x={selectionIndicatorLayout.x}\n y={40}\n />\n )}\n\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab1\"\n size=\"$3\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Profile\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n size=\"$3\"\n value=\"tab2\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Connections\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n size=\"$3\"\n value=\"tab3\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Notifications\n </Tabs.Trigger>\n </Tabs.List>\n\n <YStack f={1}>\n <AnimatePresence\n exitBeforeEnter\n enterVariant={enterVariant}\n exitVariant={exitVariant}\n >\n <AnimatedYStack key={currentTab} animation=\"100ms\" x={0} o={1} f={1}>\n <Tabs.Content value={currentTab} forceMount p=\"$2\" f={1} jc=\"center\">\n <H5 ta=\"center\">{currentTab}</H5>\n </Tabs.Content>\n </AnimatedYStack>\n </AnimatePresence>\n </YStack>\n </Tabs>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,QAAQ,gBAAgB;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,sBAAsB;AACpC,SACE,CAAC,OAAO,UAAU,OAAO,SAAS,O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ACJ;AAAA,QACA,MAAM;AAAA,QACN,KAAK;AAAA,QACL,MAAM;AAAA,QACN,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,OACxB,aAED,EAVC,KAAK;AAAA,IAWR,EA3DC,KAAK;AAAA,IA6DN,CAAC,OAAO,GAAG,GACT,CAAC;AAAA,MACC;AAAA,MACA,cAAc;AAAA,MACd,aAAa;AAAA,KAEb,CAAC,eAAe,KAAK,YAAY,UAAU,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAChE,CAAC,KAAK,QAAQ,OAAO,YAAY,WAAW,EAAE,KAAK,GAAG,GAAG,GAAG,SAC1D,CAAC,GAAG,GAAG,UAAU,WAAW,EAA3B,GACH,EAFC,KAAK,QAGR,EAJC,eAKH,EAVC,gBAWH,EAZC;AAAA,EAaH,EApFC;AAsFL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
H5,
|
|
5
|
+
Stack,
|
|
6
|
+
Tabs,
|
|
7
|
+
XStack,
|
|
8
|
+
YStack,
|
|
9
|
+
styled
|
|
10
|
+
} from "tamagui";
|
|
11
|
+
function TabsHighlightedDemo() {
|
|
12
|
+
return <XStack maxHeight="100%" maxWidth="100%" justifyContent="flex-start" px="$4"><HighlightTabs /></XStack>;
|
|
13
|
+
}
|
|
14
|
+
const TabsRovingIndicator = styled(Stack, {
|
|
15
|
+
name: "TabsRovingIndicator",
|
|
16
|
+
variants: {
|
|
17
|
+
active: {
|
|
18
|
+
true: {
|
|
19
|
+
backgroundColor: "$color8"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
active: {
|
|
24
|
+
true: {
|
|
25
|
+
backgroundColor: "$color8"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
enter: {
|
|
29
|
+
true: {
|
|
30
|
+
opacity: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
exit: {
|
|
34
|
+
true: {
|
|
35
|
+
opacity: 0
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
backgroundColor: "$color5",
|
|
43
|
+
opacity: 1,
|
|
44
|
+
animation: "100ms",
|
|
45
|
+
borderRadius: "$4"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const AnimatedYStack = styled(YStack, {
|
|
49
|
+
variants: {
|
|
50
|
+
isLeft: { true: { x: -25, opacity: 0 } },
|
|
51
|
+
isRight: { true: { x: 25, opacity: 0 } }
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const HighlightTabs = () => {
|
|
55
|
+
const [currentTab, setCurrentTab] = useState("tab1");
|
|
56
|
+
const [focusIndicatorLayout, setFocusIndicatorLayout] = useState(null);
|
|
57
|
+
const [hoverIndicatorLayout, setHoverIndicatorLayout] = useState(null);
|
|
58
|
+
const [selectionIndicatorLayout, setSelectionIndicatorLayout] = useState(null);
|
|
59
|
+
const prevSelectionIndicatorLayout = useRef(null);
|
|
60
|
+
const handleUpdateSelectionIndicator = (newSize) => {
|
|
61
|
+
prevSelectionIndicatorLayout.current = selectionIndicatorLayout;
|
|
62
|
+
setSelectionIndicatorLayout(newSize);
|
|
63
|
+
};
|
|
64
|
+
const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout;
|
|
65
|
+
const direction = useMemo(() => {
|
|
66
|
+
if (!selectionIndicatorLayout || !prevSelectionIndicatorLayout.current || selectionIndicatorLayout.x === prevSelectionIndicatorLayout.current.x) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
return selectionIndicatorLayout.x > prevSelectionIndicatorLayout.current.x ? 1 : -1;
|
|
70
|
+
}, [selectionIndicatorLayout]);
|
|
71
|
+
const enterVariant = direction === 1 ? "isLeft" : direction === -1 ? "isRight" : void 0;
|
|
72
|
+
const exitVariant = direction === 1 ? "isRight" : direction === -1 ? "isLeft" : void 0;
|
|
73
|
+
return <Tabs
|
|
74
|
+
value={currentTab}
|
|
75
|
+
onValueChange={setCurrentTab}
|
|
76
|
+
orientation="horizontal"
|
|
77
|
+
br="$4"
|
|
78
|
+
p="$2"
|
|
79
|
+
height={150}
|
|
80
|
+
flexDirection="column"
|
|
81
|
+
activationMode="manual"
|
|
82
|
+
>
|
|
83
|
+
<Tabs.List
|
|
84
|
+
loop={false}
|
|
85
|
+
aria-label="Manage your account"
|
|
86
|
+
disablePassBorderRadius
|
|
87
|
+
overflow="visible"
|
|
88
|
+
>
|
|
89
|
+
{intentIndicatorLayout && <TabsRovingIndicator
|
|
90
|
+
width={intentIndicatorLayout.width}
|
|
91
|
+
height={intentIndicatorLayout.height}
|
|
92
|
+
x={intentIndicatorLayout.x}
|
|
93
|
+
y={intentIndicatorLayout.y}
|
|
94
|
+
/>}
|
|
95
|
+
{selectionIndicatorLayout && <TabsRovingIndicator
|
|
96
|
+
theme="active"
|
|
97
|
+
active
|
|
98
|
+
width={selectionIndicatorLayout.width}
|
|
99
|
+
height={2}
|
|
100
|
+
x={selectionIndicatorLayout.x}
|
|
101
|
+
y={40}
|
|
102
|
+
/>}
|
|
103
|
+
<Tabs.Trigger
|
|
104
|
+
unstyled
|
|
105
|
+
color="$color12"
|
|
106
|
+
value="tab1"
|
|
107
|
+
size="$3"
|
|
108
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
109
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
110
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
111
|
+
>Profile</Tabs.Trigger>
|
|
112
|
+
<Tabs.Trigger
|
|
113
|
+
unstyled
|
|
114
|
+
color="$color12"
|
|
115
|
+
size="$3"
|
|
116
|
+
value="tab2"
|
|
117
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
118
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
119
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
120
|
+
>Connections</Tabs.Trigger>
|
|
121
|
+
<Tabs.Trigger
|
|
122
|
+
unstyled
|
|
123
|
+
color="$color12"
|
|
124
|
+
size="$3"
|
|
125
|
+
value="tab3"
|
|
126
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
127
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
128
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
129
|
+
>Notifications</Tabs.Trigger>
|
|
130
|
+
</Tabs.List>
|
|
131
|
+
<YStack f={1}><AnimatePresence
|
|
132
|
+
exitBeforeEnter
|
|
133
|
+
enterVariant={enterVariant}
|
|
134
|
+
exitVariant={exitVariant}
|
|
135
|
+
><AnimatedYStack key={currentTab} animation="100ms" x={0} o={1} f={1}><Tabs.Content value={currentTab} forceMount p="$2" f={1} jc="center"><H5 ta="center">{currentTab}</H5></Tabs.Content></AnimatedYStack></AnimatePresence></YStack>
|
|
136
|
+
</Tabs>;
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
TabsHighlightedDemo
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=TabsHighlightedDemo.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/TabsHighlightedDemo.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useRef, useState } from 'react'\nimport {\n AnimatePresence,\n H5,\n Stack,\n TabTriggerLayout,\n Tabs,\n XStack,\n YStack,\n styled,\n} from 'tamagui'\n\nexport function TabsHighlightedDemo() {\n return (\n <XStack maxHeight=\"100%\" maxWidth=\"100%\" justifyContent=\"flex-start\" px=\"$4\">\n <HighlightTabs />\n </XStack>\n )\n}\n\nconst TabsRovingIndicator = styled(Stack, {\n name: 'TabsRovingIndicator',\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n enter: {\n true: {\n opacity: 0,\n },\n },\n exit: {\n true: {\n opacity: 0,\n },\n },\n },\n },\n defaultVariants: {\n position: 'absolute',\n backgroundColor: '$color5',\n opacity: 1,\n animation: '100ms',\n borderRadius: '$4',\n },\n})\n\nconst AnimatedYStack = styled(YStack, {\n variants: {\n isLeft: { true: { x: -25, opacity: 0 } },\n isRight: { true: { x: 25, opacity: 0 } },\n } as const,\n})\n\nconst HighlightTabs = () => {\n const [currentTab, setCurrentTab] = useState('tab1')\n const [focusIndicatorLayout, setFocusIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [hoverIndicatorLayout, setHoverIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [selectionIndicatorLayout, setSelectionIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const prevSelectionIndicatorLayout = useRef<TabTriggerLayout | null>(null)\n const handleUpdateSelectionIndicator = (newSize: TabTriggerLayout | null) => {\n prevSelectionIndicatorLayout.current = selectionIndicatorLayout\n setSelectionIndicatorLayout(newSize)\n }\n\n const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout\n\n /**\n * -1: from left\n * 0: n/a\n * 1: from right\n */\n const direction = useMemo(() => {\n if (\n !selectionIndicatorLayout ||\n !prevSelectionIndicatorLayout.current ||\n selectionIndicatorLayout.x === prevSelectionIndicatorLayout.current.x\n ) {\n return 0\n }\n return selectionIndicatorLayout.x > prevSelectionIndicatorLayout.current.x ? 1 : -1\n }, [selectionIndicatorLayout])\n\n const enterVariant =\n direction === 1 ? 'isLeft' : direction === -1 ? 'isRight' : undefined\n const exitVariant =\n direction === 1 ? 'isRight' : direction === -1 ? 'isLeft' : undefined\n\n return (\n <Tabs\n value={currentTab}\n onValueChange={setCurrentTab}\n orientation=\"horizontal\"\n br=\"$4\"\n p=\"$2\"\n height={150}\n flexDirection=\"column\"\n activationMode=\"manual\"\n >\n <Tabs.List\n loop={false}\n aria-label=\"Manage your account\"\n disablePassBorderRadius\n overflow=\"visible\"\n >\n {intentIndicatorLayout && (\n <TabsRovingIndicator\n width={intentIndicatorLayout.width}\n height={intentIndicatorLayout.height}\n x={intentIndicatorLayout.x}\n y={intentIndicatorLayout.y}\n />\n )}\n\n {selectionIndicatorLayout && (\n <TabsRovingIndicator\n theme=\"active\"\n active\n width={selectionIndicatorLayout.width}\n height={2}\n x={selectionIndicatorLayout.x}\n y={40}\n />\n )}\n\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab1\"\n size=\"$3\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Profile\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n size=\"$3\"\n value=\"tab2\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Connections\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n size=\"$3\"\n value=\"tab3\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Notifications\n </Tabs.Trigger>\n </Tabs.List>\n\n <YStack f={1}>\n <AnimatePresence\n exitBeforeEnter\n enterVariant={enterVariant}\n exitVariant={exitVariant}\n >\n <AnimatedYStack key={currentTab} animation=\"100ms\" x={0} o={1} f={1}>\n <Tabs.Content value={currentTab} forceMount p=\"$2\" f={1} jc=\"center\">\n <H5 ta=\"center\">{currentTab}</H5>\n </Tabs.Content>\n </AnimatedYStack>\n </AnimatePresence>\n </YStack>\n </Tabs>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,QAAQ,gBAA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,MAAM;AAAA,QACN,KAAK;AAAA,QACL,MAAM;AAAA,QACN,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,OACxB,WAED,EAVC,KAAK;AAAA,MAWN,CAAC,KAAK;AAAA,QACJ;AAAA,QACA,MAAM;AAAA,QACN,KAAK;AAAA,QACL,MAAM;AAAA,QACN,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,OACxB,aAED,EAVC,KAAK;AAAA,IAWR,EA3DC,KAAK;AAAA,IA6DN,CAAC,OAAO,GAAG,GACT,CAAC;AAAA,MACC;AAAA,MACA,cAAc;AAAA,MACd,aAAa;AAAA,KAEb,CAAC,eAAe,KAAK,YAAY,UAAU,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAChE,CAAC,KAAK,QAAQ,OAAO,YAAY,WAAW,EAAE,KAAK,GAAG,GAAG,GAAG,SAC1D,CAAC,GAAG,GAAG,UAAU,WAAW,EAA3B,GACH,EAFC,KAAK,QAGR,EAJC,eAKH,EAVC,gBAWH,EAZC;AAAA,EAaH,EApFC;AAsFL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
H5,
|
|
5
|
+
Stack,
|
|
6
|
+
Tabs,
|
|
7
|
+
XStack,
|
|
8
|
+
YStack,
|
|
9
|
+
styled
|
|
10
|
+
} from "tamagui";
|
|
11
|
+
function TabsUnderlinedDemo() {
|
|
12
|
+
return <XStack maxHeight="100%" maxWidth="100%" justifyContent="flex-start" px="$4"><UnderlineTabs /></XStack>;
|
|
13
|
+
}
|
|
14
|
+
const TabsRovingIndicator = styled(Stack, {
|
|
15
|
+
name: "TabsRovingIndicator",
|
|
16
|
+
variants: {
|
|
17
|
+
active: {
|
|
18
|
+
true: {
|
|
19
|
+
backgroundColor: "$color8"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
active: {
|
|
24
|
+
true: {
|
|
25
|
+
backgroundColor: "$color8"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
enter: {
|
|
29
|
+
true: {
|
|
30
|
+
opacity: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
exit: {
|
|
34
|
+
true: {
|
|
35
|
+
opacity: 0
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
backgroundColor: "$color5",
|
|
43
|
+
opacity: 1,
|
|
44
|
+
animation: "100ms"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const AnimatedYStack = styled(YStack, {
|
|
48
|
+
variants: {
|
|
49
|
+
isTop: { true: { y: -25, opacity: 0 } },
|
|
50
|
+
isBottom: { true: { y: 25, opacity: 0 } }
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const UnderlineTabs = () => {
|
|
54
|
+
const [currentTab, setCurrentTab] = useState("tab1");
|
|
55
|
+
const [focusIndicatorLayout, setFocusIndicatorLayout] = useState(null);
|
|
56
|
+
const [hoverIndicatorLayout, setHoverIndicatorLayout] = useState(null);
|
|
57
|
+
const [selectionIndicatorLayout, setSelectionIndicatorLayout] = useState(null);
|
|
58
|
+
const prevSelectionIndicatorLayout = useRef(null);
|
|
59
|
+
const handleUpdateSelectionIndicator = (newSize) => {
|
|
60
|
+
prevSelectionIndicatorLayout.current = selectionIndicatorLayout;
|
|
61
|
+
setSelectionIndicatorLayout(newSize);
|
|
62
|
+
};
|
|
63
|
+
const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout;
|
|
64
|
+
const direction = useMemo(() => {
|
|
65
|
+
if (!selectionIndicatorLayout || !prevSelectionIndicatorLayout.current || selectionIndicatorLayout.y === prevSelectionIndicatorLayout.current.y) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
return selectionIndicatorLayout.y > prevSelectionIndicatorLayout.current.y ? 1 : -1;
|
|
69
|
+
}, [selectionIndicatorLayout]);
|
|
70
|
+
const enterVariant = direction === 1 ? "isTop" : direction === -1 ? "isBottom" : void 0;
|
|
71
|
+
const exitVariant = direction === 1 ? "isBottom" : direction === -1 ? "isTop" : void 0;
|
|
72
|
+
return <Tabs
|
|
73
|
+
value={currentTab}
|
|
74
|
+
onValueChange={setCurrentTab}
|
|
75
|
+
orientation="vertical"
|
|
76
|
+
width={300}
|
|
77
|
+
br="$4"
|
|
78
|
+
ai="center"
|
|
79
|
+
activationMode="manual"
|
|
80
|
+
>
|
|
81
|
+
<YStack borderColor="$color3" borderRightWidth="$0.5" mr="$2"><Tabs.List loop={false} aria-label="Manage your account" disablePassBorderRadius>
|
|
82
|
+
{intentIndicatorLayout && <TabsRovingIndicator
|
|
83
|
+
width="$0.5"
|
|
84
|
+
height={intentIndicatorLayout.height}
|
|
85
|
+
x={intentIndicatorLayout.x}
|
|
86
|
+
y={intentIndicatorLayout.y}
|
|
87
|
+
right={0}
|
|
88
|
+
/>}
|
|
89
|
+
{selectionIndicatorLayout && <TabsRovingIndicator
|
|
90
|
+
theme="active"
|
|
91
|
+
active
|
|
92
|
+
width="$0.5"
|
|
93
|
+
height={selectionIndicatorLayout.height}
|
|
94
|
+
x={selectionIndicatorLayout.x}
|
|
95
|
+
y={selectionIndicatorLayout.y}
|
|
96
|
+
right={0}
|
|
97
|
+
/>}
|
|
98
|
+
<Tabs.Trigger
|
|
99
|
+
unstyled
|
|
100
|
+
color="$color12"
|
|
101
|
+
value="tab1"
|
|
102
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
103
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
104
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
105
|
+
>Profile</Tabs.Trigger>
|
|
106
|
+
<Tabs.Trigger
|
|
107
|
+
unstyled
|
|
108
|
+
color="$color12"
|
|
109
|
+
value="tab2"
|
|
110
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
111
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
112
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
113
|
+
>Connections</Tabs.Trigger>
|
|
114
|
+
<Tabs.Trigger
|
|
115
|
+
unstyled
|
|
116
|
+
color="$color12"
|
|
117
|
+
value="tab3"
|
|
118
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
119
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
120
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
121
|
+
>Notifications</Tabs.Trigger>
|
|
122
|
+
</Tabs.List></YStack>
|
|
123
|
+
<AnimatePresence
|
|
124
|
+
exitBeforeEnter
|
|
125
|
+
enterVariant={enterVariant}
|
|
126
|
+
exitVariant={exitVariant}
|
|
127
|
+
><AnimatedYStack key={currentTab} animation="100ms" y={0} o={1}><Tabs.Content value={currentTab} forceMount p="$2"><H5 ta="center">{currentTab}</H5></Tabs.Content></AnimatedYStack></AnimatePresence>
|
|
128
|
+
</Tabs>;
|
|
129
|
+
};
|
|
130
|
+
export {
|
|
131
|
+
TabsUnderlinedDemo
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=TabsUnderlinedDemo.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/TabsUnderlinedDemo.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useRef, useState } from 'react'\nimport {\n AnimatePresence,\n H5,\n Stack,\n TabTriggerLayout,\n Tabs,\n XStack,\n YStack,\n styled,\n} from 'tamagui'\n\nexport function TabsUnderlinedDemo() {\n return (\n <XStack maxHeight=\"100%\" maxWidth=\"100%\" justifyContent=\"flex-start\" px=\"$4\">\n <UnderlineTabs />\n </XStack>\n )\n}\n\nconst TabsRovingIndicator = styled(Stack, {\n name: 'TabsRovingIndicator',\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n enter: {\n true: {\n opacity: 0,\n },\n },\n exit: {\n true: {\n opacity: 0,\n },\n },\n },\n },\n defaultVariants: {\n position: 'absolute',\n backgroundColor: '$color5',\n opacity: 1,\n animation: '100ms',\n },\n})\n\nconst AnimatedYStack = styled(YStack, {\n variants: {\n isTop: { true: { y: -25, opacity: 0 } },\n isBottom: { true: { y: 25, opacity: 0 } },\n } as const,\n})\n\nconst UnderlineTabs = () => {\n const [currentTab, setCurrentTab] = useState('tab1')\n const [focusIndicatorLayout, setFocusIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [hoverIndicatorLayout, setHoverIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [selectionIndicatorLayout, setSelectionIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const prevSelectionIndicatorLayout = useRef<TabTriggerLayout | null>(null)\n const handleUpdateSelectionIndicator = (newSize: TabTriggerLayout | null) => {\n prevSelectionIndicatorLayout.current = selectionIndicatorLayout\n setSelectionIndicatorLayout(newSize)\n }\n\n const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout\n\n /**\n * -1: from top\n * 0: n/a\n * 1: from bottom\n */\n const direction = useMemo(() => {\n if (\n !selectionIndicatorLayout ||\n !prevSelectionIndicatorLayout.current ||\n selectionIndicatorLayout.y === prevSelectionIndicatorLayout.current.y\n ) {\n return 0\n }\n return selectionIndicatorLayout.y > prevSelectionIndicatorLayout.current.y ? 1 : -1\n }, [selectionIndicatorLayout])\n\n const enterVariant =\n direction === 1 ? 'isTop' : direction === -1 ? 'isBottom' : undefined\n const exitVariant =\n direction === 1 ? 'isBottom' : direction === -1 ? 'isTop' : undefined\n\n return (\n <Tabs\n value={currentTab}\n onValueChange={setCurrentTab}\n orientation=\"vertical\"\n width={300}\n br=\"$4\"\n ai=\"center\"\n activationMode=\"manual\"\n >\n <YStack borderColor=\"$color3\" borderRightWidth=\"$0.5\" mr=\"$2\">\n <Tabs.List loop={false} aria-label=\"Manage your account\" disablePassBorderRadius>\n {intentIndicatorLayout && (\n <TabsRovingIndicator\n width=\"$0.5\"\n height={intentIndicatorLayout.height}\n x={intentIndicatorLayout.x}\n y={intentIndicatorLayout.y}\n right={0}\n />\n )}\n {selectionIndicatorLayout && (\n <TabsRovingIndicator\n theme=\"active\"\n active\n width=\"$0.5\"\n height={selectionIndicatorLayout.height}\n x={selectionIndicatorLayout.x}\n y={selectionIndicatorLayout.y}\n right={0}\n />\n )}\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab1\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Profile\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab2\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Connections\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab3\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Notifications\n </Tabs.Trigger>\n </Tabs.List>\n </YStack>\n <AnimatePresence\n exitBeforeEnter\n enterVariant={enterVariant}\n exitVariant={exitVariant}\n >\n <AnimatedYStack key={currentTab} animation=\"100ms\" y={0} o={1}>\n <Tabs.Content value={currentTab} forceMount p=\"$2\">\n <H5 ta=\"center\">{currentTab}</H5>\n </Tabs.Content>\n </AnimatedYStack>\n </AnimatePresence>\n </Tabs>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,QAAQ,gBAAg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AAA,QACN,MAAM;AAAA,QACN,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,OACxB,WAED,EATC,KAAK;AAAA,MAUN,CAAC,KAAK;AAAA,QACJ;AAAA,QACA,MAAM;AAAA,QACN,MAAM;AAAA,QACN,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,OACxB,aAED,EATC,KAAK;AAAA,IAUR,EAnDC,KAAK,KAoDR,EArDC;AAAA,IAsDD,CAAC;AAAA,MACC;AAAA,MACA,cAAc;AAAA,MACd,aAAa;AAAA,KAEb,CAAC,eAAe,KAAK,YAAY,UAAU,QAAQ,GAAG,GAAG,GAAG,GAC1D,CAAC,KAAK,QAAQ,OAAO,YAAY,WAAW,EAAE,KAC5C,CAAC,GAAG,GAAG,UAAU,WAAW,EAA3B,GACH,EAFC,KAAK,QAGR,EAJC,eAKH,EAVC;AAAA,EAWH,EA1EC;AA4EL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
H5,
|
|
5
|
+
Stack,
|
|
6
|
+
Tabs,
|
|
7
|
+
XStack,
|
|
8
|
+
YStack,
|
|
9
|
+
styled
|
|
10
|
+
} from "tamagui";
|
|
11
|
+
function TabsUnderlinedDemo() {
|
|
12
|
+
return <XStack maxHeight="100%" maxWidth="100%" justifyContent="flex-start" px="$4"><UnderlineTabs /></XStack>;
|
|
13
|
+
}
|
|
14
|
+
const TabsRovingIndicator = styled(Stack, {
|
|
15
|
+
name: "TabsRovingIndicator",
|
|
16
|
+
variants: {
|
|
17
|
+
active: {
|
|
18
|
+
true: {
|
|
19
|
+
backgroundColor: "$color8"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
active: {
|
|
24
|
+
true: {
|
|
25
|
+
backgroundColor: "$color8"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
enter: {
|
|
29
|
+
true: {
|
|
30
|
+
opacity: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
exit: {
|
|
34
|
+
true: {
|
|
35
|
+
opacity: 0
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
backgroundColor: "$color5",
|
|
43
|
+
opacity: 1,
|
|
44
|
+
animation: "100ms"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const AnimatedYStack = styled(YStack, {
|
|
48
|
+
variants: {
|
|
49
|
+
isTop: { true: { y: -25, opacity: 0 } },
|
|
50
|
+
isBottom: { true: { y: 25, opacity: 0 } }
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const UnderlineTabs = () => {
|
|
54
|
+
const [currentTab, setCurrentTab] = useState("tab1");
|
|
55
|
+
const [focusIndicatorLayout, setFocusIndicatorLayout] = useState(null);
|
|
56
|
+
const [hoverIndicatorLayout, setHoverIndicatorLayout] = useState(null);
|
|
57
|
+
const [selectionIndicatorLayout, setSelectionIndicatorLayout] = useState(null);
|
|
58
|
+
const prevSelectionIndicatorLayout = useRef(null);
|
|
59
|
+
const handleUpdateSelectionIndicator = (newSize) => {
|
|
60
|
+
prevSelectionIndicatorLayout.current = selectionIndicatorLayout;
|
|
61
|
+
setSelectionIndicatorLayout(newSize);
|
|
62
|
+
};
|
|
63
|
+
const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout;
|
|
64
|
+
const direction = useMemo(() => {
|
|
65
|
+
if (!selectionIndicatorLayout || !prevSelectionIndicatorLayout.current || selectionIndicatorLayout.y === prevSelectionIndicatorLayout.current.y) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
return selectionIndicatorLayout.y > prevSelectionIndicatorLayout.current.y ? 1 : -1;
|
|
69
|
+
}, [selectionIndicatorLayout]);
|
|
70
|
+
const enterVariant = direction === 1 ? "isTop" : direction === -1 ? "isBottom" : void 0;
|
|
71
|
+
const exitVariant = direction === 1 ? "isBottom" : direction === -1 ? "isTop" : void 0;
|
|
72
|
+
return <Tabs
|
|
73
|
+
value={currentTab}
|
|
74
|
+
onValueChange={setCurrentTab}
|
|
75
|
+
orientation="vertical"
|
|
76
|
+
width={300}
|
|
77
|
+
br="$4"
|
|
78
|
+
ai="center"
|
|
79
|
+
activationMode="manual"
|
|
80
|
+
>
|
|
81
|
+
<YStack borderColor="$color3" borderRightWidth="$0.5" mr="$2"><Tabs.List loop={false} aria-label="Manage your account" disablePassBorderRadius>
|
|
82
|
+
{intentIndicatorLayout && <TabsRovingIndicator
|
|
83
|
+
width="$0.5"
|
|
84
|
+
height={intentIndicatorLayout.height}
|
|
85
|
+
x={intentIndicatorLayout.x}
|
|
86
|
+
y={intentIndicatorLayout.y}
|
|
87
|
+
right={0}
|
|
88
|
+
/>}
|
|
89
|
+
{selectionIndicatorLayout && <TabsRovingIndicator
|
|
90
|
+
theme="active"
|
|
91
|
+
active
|
|
92
|
+
width="$0.5"
|
|
93
|
+
height={selectionIndicatorLayout.height}
|
|
94
|
+
x={selectionIndicatorLayout.x}
|
|
95
|
+
y={selectionIndicatorLayout.y}
|
|
96
|
+
right={0}
|
|
97
|
+
/>}
|
|
98
|
+
<Tabs.Trigger
|
|
99
|
+
unstyled
|
|
100
|
+
color="$color12"
|
|
101
|
+
value="tab1"
|
|
102
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
103
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
104
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
105
|
+
>Profile</Tabs.Trigger>
|
|
106
|
+
<Tabs.Trigger
|
|
107
|
+
unstyled
|
|
108
|
+
color="$color12"
|
|
109
|
+
value="tab2"
|
|
110
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
111
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
112
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
113
|
+
>Connections</Tabs.Trigger>
|
|
114
|
+
<Tabs.Trigger
|
|
115
|
+
unstyled
|
|
116
|
+
color="$color12"
|
|
117
|
+
value="tab3"
|
|
118
|
+
onSelectedLayoutChange={handleUpdateSelectionIndicator}
|
|
119
|
+
onHoveredLayoutChange={setHoverIndicatorLayout}
|
|
120
|
+
onFocusedLayoutChange={setFocusIndicatorLayout}
|
|
121
|
+
>Notifications</Tabs.Trigger>
|
|
122
|
+
</Tabs.List></YStack>
|
|
123
|
+
<AnimatePresence
|
|
124
|
+
exitBeforeEnter
|
|
125
|
+
enterVariant={enterVariant}
|
|
126
|
+
exitVariant={exitVariant}
|
|
127
|
+
><AnimatedYStack key={currentTab} animation="100ms" y={0} o={1}><Tabs.Content value={currentTab} forceMount p="$2"><H5 ta="center">{currentTab}</H5></Tabs.Content></AnimatedYStack></AnimatePresence>
|
|
128
|
+
</Tabs>;
|
|
129
|
+
};
|
|
130
|
+
export {
|
|
131
|
+
TabsUnderlinedDemo
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=TabsUnderlinedDemo.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/TabsUnderlinedDemo.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useRef, useState } from 'react'\nimport {\n AnimatePresence,\n H5,\n Stack,\n TabTriggerLayout,\n Tabs,\n XStack,\n YStack,\n styled,\n} from 'tamagui'\n\nexport function TabsUnderlinedDemo() {\n return (\n <XStack maxHeight=\"100%\" maxWidth=\"100%\" justifyContent=\"flex-start\" px=\"$4\">\n <UnderlineTabs />\n </XStack>\n )\n}\n\nconst TabsRovingIndicator = styled(Stack, {\n name: 'TabsRovingIndicator',\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n variants: {\n active: {\n true: {\n backgroundColor: '$color8',\n },\n },\n enter: {\n true: {\n opacity: 0,\n },\n },\n exit: {\n true: {\n opacity: 0,\n },\n },\n },\n },\n defaultVariants: {\n position: 'absolute',\n backgroundColor: '$color5',\n opacity: 1,\n animation: '100ms',\n },\n})\n\nconst AnimatedYStack = styled(YStack, {\n variants: {\n isTop: { true: { y: -25, opacity: 0 } },\n isBottom: { true: { y: 25, opacity: 0 } },\n } as const,\n})\n\nconst UnderlineTabs = () => {\n const [currentTab, setCurrentTab] = useState('tab1')\n const [focusIndicatorLayout, setFocusIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [hoverIndicatorLayout, setHoverIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const [selectionIndicatorLayout, setSelectionIndicatorLayout] =\n useState<TabTriggerLayout | null>(null)\n const prevSelectionIndicatorLayout = useRef<TabTriggerLayout | null>(null)\n const handleUpdateSelectionIndicator = (newSize: TabTriggerLayout | null) => {\n prevSelectionIndicatorLayout.current = selectionIndicatorLayout\n setSelectionIndicatorLayout(newSize)\n }\n\n const intentIndicatorLayout = hoverIndicatorLayout || focusIndicatorLayout\n\n /**\n * -1: from top\n * 0: n/a\n * 1: from bottom\n */\n const direction = useMemo(() => {\n if (\n !selectionIndicatorLayout ||\n !prevSelectionIndicatorLayout.current ||\n selectionIndicatorLayout.y === prevSelectionIndicatorLayout.current.y\n ) {\n return 0\n }\n return selectionIndicatorLayout.y > prevSelectionIndicatorLayout.current.y ? 1 : -1\n }, [selectionIndicatorLayout])\n\n const enterVariant =\n direction === 1 ? 'isTop' : direction === -1 ? 'isBottom' : undefined\n const exitVariant =\n direction === 1 ? 'isBottom' : direction === -1 ? 'isTop' : undefined\n\n return (\n <Tabs\n value={currentTab}\n onValueChange={setCurrentTab}\n orientation=\"vertical\"\n width={300}\n br=\"$4\"\n ai=\"center\"\n activationMode=\"manual\"\n >\n <YStack borderColor=\"$color3\" borderRightWidth=\"$0.5\" mr=\"$2\">\n <Tabs.List loop={false} aria-label=\"Manage your account\" disablePassBorderRadius>\n {intentIndicatorLayout && (\n <TabsRovingIndicator\n width=\"$0.5\"\n height={intentIndicatorLayout.height}\n x={intentIndicatorLayout.x}\n y={intentIndicatorLayout.y}\n right={0}\n />\n )}\n {selectionIndicatorLayout && (\n <TabsRovingIndicator\n theme=\"active\"\n active\n width=\"$0.5\"\n height={selectionIndicatorLayout.height}\n x={selectionIndicatorLayout.x}\n y={selectionIndicatorLayout.y}\n right={0}\n />\n )}\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab1\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Profile\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab2\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Connections\n </Tabs.Trigger>\n <Tabs.Trigger\n unstyled\n color=\"$color12\"\n value=\"tab3\"\n onSelectedLayoutChange={handleUpdateSelectionIndicator}\n onHoveredLayoutChange={setHoverIndicatorLayout}\n onFocusedLayoutChange={setFocusIndicatorLayout}\n >\n Notifications\n </Tabs.Trigger>\n </Tabs.List>\n </YStack>\n <AnimatePresence\n exitBeforeEnter\n enterVariant={enterVariant}\n exitVariant={exitVariant}\n >\n <AnimatedYStack key={currentTab} animation=\"100ms\" y={0} o={1}>\n <Tabs.Content value={currentTab} forceMount p=\"$2\">\n <H5 ta=\"center\">{currentTab}</H5>\n </Tabs.Content>\n </AnimatedYStack>\n </AnimatePresence>\n </Tabs>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,QAAQ,gBAAgB;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;A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AAK;AAAA,MAUN,CAAC,KAAK;AAAA,QACJ;AAAA,QACA,MAAM;AAAA,QACN,MAAM;AAAA,QACN,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,OACxB,aAED,EATC,KAAK;AAAA,IAUR,EAnDC,KAAK,KAoDR,EArDC;AAAA,IAsDD,CAAC;AAAA,MACC;AAAA,MACA,cAAc;AAAA,MACd,aAAa;AAAA,KAEb,CAAC,eAAe,KAAK,YAAY,UAAU,QAAQ,GAAG,GAAG,GAAG,GAC1D,CAAC,KAAK,QAAQ,OAAO,YAAY,WAAW,EAAE,KAC5C,CAAC,GAAG,GAAG,UAAU,WAAW,EAA3B,GACH,EAFC,KAAK,QAGR,EAJC,eAKH,EAVC;AAAA,EAWH,EA1EC;AA4EL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/jsx/index.js
CHANGED
|
@@ -37,6 +37,8 @@ import { ThemeInverseDemo } from "./ThemeInverseDemo";
|
|
|
37
37
|
import { TooltipDemo } from "./TooltipDemo";
|
|
38
38
|
import { ColorsDemo } from "./ColorsDemo";
|
|
39
39
|
import { TokensDemo } from "./TokensDemo";
|
|
40
|
+
import { TabsDemo } from "./TabsDemo";
|
|
41
|
+
import { TabsAdvancedDemo } from "./TabsAdvancedDemo";
|
|
40
42
|
export * from "./useOnIntersecting";
|
|
41
43
|
export {
|
|
42
44
|
AddThemeDemo,
|
|
@@ -73,6 +75,8 @@ export {
|
|
|
73
75
|
SpinnerDemo,
|
|
74
76
|
StacksDemo,
|
|
75
77
|
SwitchDemo,
|
|
78
|
+
TabsAdvancedDemo,
|
|
79
|
+
TabsDemo,
|
|
76
80
|
TextDemo,
|
|
77
81
|
ThemeInverseDemo,
|
|
78
82
|
TokensDemo,
|