@@ -15,8 +15,8 @@ export const Example01 = component$(() => {
15
15
return (
16
16
< PreviewCodeExample >
17
17
< div q :slot = "actualComponent" class = "tabs-example" >
18
+ < h3 > Danish Composers</ h3 >
18
19
< Tabs behavior = "automatic" >
19
- < h3 id = "tablist-1" > Danish Composers</ h3 >
20
20
< TabList >
21
21
< Tab > Maria Ahlefeldt</ Tab >
22
22
< Tab > Carl Andersen</ Tab >
@@ -50,8 +50,9 @@ export const VerticalTabsExample = component$(() => {
50
50
return (
51
51
< PreviewCodeExample >
52
52
< div q :slot = "actualComponent" class = "tabs-example mr-auto" >
53
- < Tabs vertical >
54
- < h3 id = "tablist-1" > Danish Composers</ h3 >
53
+ < h3 > Danish Composers</ h3 >
54
+
55
+ < Tabs vertical class = "flex flex-wrap gap-5" >
55
56
< TabList class = "flex flex-col w-fit" >
56
57
< Tab > Maria Ahlefeldt</ Tab >
57
58
< Tab > Carl Andersen</ Tab >
@@ -84,27 +85,26 @@ export const VerticalTabsExample = component$(() => {
84
85
export const DisabledTabsExample = component$ ( ( ) => {
85
86
return (
86
87
< PreviewCodeExample >
87
- < div q :slot = "actualComponent" class = "tabs-example mr-auto" >
88
+ < div q :slot = "actualComponent" class = "tabs-example mr-auto w-full" >
89
+ < h3 > Dad jokes</ h3 >
88
90
< Tabs >
89
- < h3 id = "tablist-1" > Danish Composers</ h3 >
90
91
< TabList >
91
- < Tab disabled = { true } > I'm a disabled tab</ Tab >
92
- < Tab > Carl Andersen</ Tab >
93
- < Tab > Ida Henriette da Fonseca</ Tab >
92
+ < Tab style = "width: 25%" disabled = { true } >
93
+ Disabled Tab
94
+ </ Tab >
95
+ < Tab style = "width: 25%" > Joke 2</ Tab >
96
+ < Tab style = "width: 25%" > Joke 3</ Tab >
97
+ < Tab style = "width: 25%" > Joke 4</ Tab >
94
98
</ TabList >
95
99
< TabPanel >
96
- < p >
97
- Maria Theresia Ahlefeldt (16 January 1755 - 20 December 1810) was
98
- a ...
99
- </ p >
100
+ "What did the coffee report to the police", " A mugging."
100
101
</ TabPanel >
102
+ < TabPanel > "What's brown and sticky", " A stick."</ TabPanel >
101
103
< TabPanel >
102
- < p > Carl Joachim Andersen (29 April 1847 - 7 May 1909) was a ... </ p >
104
+ "How do the trees get on the internet?", "They log on."
103
105
</ TabPanel >
104
106
< TabPanel >
105
- < p >
106
- Ida Henriette da Fonseca (July 27, 1802 - July 6, 1858) was a ...
107
- </ p >
107
+ "What did the fish say when he hit the wall", " Dam."
108
108
</ TabPanel >
109
109
</ Tabs >
110
110
</ div >
@@ -116,47 +116,13 @@ export const DisabledTabsExample = component$(() => {
116
116
) ;
117
117
} ) ;
118
118
119
- export const DynamicTabsExample = component$ ( ( ) => {
120
- const tabsState = useStore ( [
121
- 'Dynamic Tab 1' ,
122
- 'Dynamic Tab 2' ,
123
- 'Dynamic Tab 3' ,
124
- ] ) ;
125
-
126
- return (
127
- < PreviewCodeExample >
128
- < div q :slot = "actualComponent" class = "tabs-example mr-auto" >
129
- < Tabs >
130
- < TabList >
131
- { tabsState . map ( ( tab ) => (
132
- < Tab key = { tab } > { tab } </ Tab >
133
- ) ) }
134
- </ TabList >
135
- { tabsState . map ( ( tab ) => (
136
- < TabPanel key = { tab } > { tab } Panel</ TabPanel >
137
- ) ) }
138
- </ Tabs >
139
- < button
140
- style = { { color : 'red' } }
141
- onClick$ = { ( ) => tabsState . splice ( 0 , 1 ) }
142
- >
143
- Remove Tab
144
- </ button >
145
- </ div >
146
-
147
- < div q :slot = "codeExample" >
148
- < Slot />
149
- </ div >
150
- </ PreviewCodeExample >
151
- ) ;
152
- } ) ;
153
-
154
119
export const AutomaticBehaviorTabsExample = component$ ( ( ) => {
155
120
return (
156
121
< PreviewCodeExample >
157
122
< div q :slot = "actualComponent" class = "tabs-example mr-auto" >
158
123
< Tabs behavior = "automatic" >
159
- < h3 id = "tablist-1" > Danish Composers</ h3 >
124
+ < h3 > Danish Composers</ h3 >
125
+ < h4 > (Hover over the tabs)</ h4 >
160
126
< TabList >
161
127
< Tab > Maria Ahlefeldt</ Tab >
162
128
< Tab > Carl Andersen</ Tab >
@@ -190,8 +156,9 @@ export const ManualBehaviorTabsExample = component$(() => {
190
156
return (
191
157
< PreviewCodeExample >
192
158
< div q :slot = "actualComponent" class = "tabs-example mr-auto" >
193
- < Tabs behavior = "automatic" >
194
- < h3 id = "tablist-1" > Danish Composers</ h3 >
159
+ < Tabs behavior = "manual" >
160
+ < h3 > Danish Composers</ h3 >
161
+ < h4 > (Hover over the tabs - they should not be selected)</ h4 >
195
162
< TabList >
196
163
< Tab > Maria Ahlefeldt</ Tab >
197
164
< Tab > Carl Andersen</ Tab >
@@ -221,19 +188,58 @@ export const ManualBehaviorTabsExample = component$(() => {
221
188
) ;
222
189
} ) ;
223
190
191
+ export const DynamicTabsExample = component$ ( ( ) => {
192
+ const tabsState = useStore ( [
193
+ 'Dynamic Tab 1' ,
194
+ 'Dynamic Tab 2' ,
195
+ 'Dynamic Tab 3' ,
196
+ ] ) ;
197
+
198
+ return (
199
+ < PreviewCodeExample >
200
+ < div q :slot = "actualComponent" class = "tabs-example mr-auto" >
201
+ < Tabs >
202
+ < TabList >
203
+ { tabsState . map ( ( tab ) => (
204
+ < Tab key = { tab } > { tab } </ Tab >
205
+ ) ) }
206
+ </ TabList >
207
+ { tabsState . map ( ( tab ) => (
208
+ < TabPanel key = { tab } > { tab } Panel</ TabPanel >
209
+ ) ) }
210
+ </ Tabs >
211
+
212
+ < button
213
+ style = { { color : 'red' , marginTop : '1rem' } }
214
+ onClick$ = { ( ) => {
215
+ if ( tabsState . length > 1 ) {
216
+ tabsState . splice ( 0 , 1 ) ;
217
+ }
218
+ } }
219
+ >
220
+ Remove First Tab
221
+ </ button >
222
+ </ div >
223
+
224
+ < div q :slot = "codeExample" >
225
+ < Slot />
226
+ </ div >
227
+ </ PreviewCodeExample >
228
+ ) ;
229
+ } ) ;
230
+
224
231
export const OnSelectedIndexChangeTabsExample = component$ ( ( ) => {
225
232
const selectedIndexSig = useSignal ( 0 ) ;
226
233
227
234
return (
228
235
< PreviewCodeExample >
229
236
< div q :slot = "actualComponent" class = "tabs-example mr-auto" >
230
237
< Tabs
231
- selectedIndex = { selectedIndexSig . value }
232
- onSelectedIndexChange$ = { ( e ) => {
233
- selectedIndexSig . value = e ;
238
+ onSelectedIndexChange$ = { ( index ) => {
239
+ selectedIndexSig . value = index ;
234
240
} }
235
241
>
236
- < h3 id = "tablist-1" > Danish Composers</ h3 >
242
+ < h3 > Danish Composers</ h3 >
237
243
< TabList >
238
244
< Tab > Maria Ahlefeldt</ Tab >
239
245
< Tab > Carl Andersen</ Tab >
@@ -271,12 +277,13 @@ export const OnClickTabsExample = component$(() => {
271
277
return (
272
278
< PreviewCodeExample >
273
279
< div q :slot = "actualComponent" class = "tabs-example mr-auto" >
280
+ < h3 > Danish Composers</ h3 >
281
+ < h4 > (watch the counter below)</ h4 >
274
282
< Tabs
275
283
onClick$ = { ( ) => {
276
284
tabsClickedCountSig . value ++ ;
277
285
} }
278
286
>
279
- < h3 id = "tablist-1" > Danish Composers</ h3 >
280
287
< TabList >
281
288
< Tab > Maria Ahlefeldt</ Tab >
282
289
< Tab > Carl Andersen</ Tab >
0 commit comments