@@ -15,8 +15,8 @@ export const Example01 = component$(() => {
1515 return (
1616 < PreviewCodeExample >
1717 < div q :slot = "actualComponent" class = "tabs-example" >
18+ < h3 > Danish Composers</ h3 >
1819 < Tabs behavior = "automatic" >
19- < h3 id = "tablist-1" > Danish Composers</ h3 >
2020 < TabList >
2121 < Tab > Maria Ahlefeldt</ Tab >
2222 < Tab > Carl Andersen</ Tab >
@@ -50,8 +50,9 @@ export const VerticalTabsExample = component$(() => {
5050 return (
5151 < PreviewCodeExample >
5252 < 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" >
5556 < TabList class = "flex flex-col w-fit" >
5657 < Tab > Maria Ahlefeldt</ Tab >
5758 < Tab > Carl Andersen</ Tab >
@@ -84,27 +85,26 @@ export const VerticalTabsExample = component$(() => {
8485export const DisabledTabsExample = component$ ( ( ) => {
8586 return (
8687 < 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 >
8890 < Tabs >
89- < h3 id = "tablist-1" > Danish Composers</ h3 >
9091 < 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 >
9498 </ TabList >
9599 < 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."
100101 </ TabPanel >
102+ < TabPanel > "What's brown and sticky", " A stick."</ TabPanel >
101103 < 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."
103105 </ TabPanel >
104106 < 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."
108108 </ TabPanel >
109109 </ Tabs >
110110 </ div >
@@ -116,47 +116,13 @@ export const DisabledTabsExample = component$(() => {
116116 ) ;
117117} ) ;
118118
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-
154119export const AutomaticBehaviorTabsExample = component$ ( ( ) => {
155120 return (
156121 < PreviewCodeExample >
157122 < div q :slot = "actualComponent" class = "tabs-example mr-auto" >
158123 < Tabs behavior = "automatic" >
159- < h3 id = "tablist-1" > Danish Composers</ h3 >
124+ < h3 > Danish Composers</ h3 >
125+ < h4 > (Hover over the tabs)</ h4 >
160126 < TabList >
161127 < Tab > Maria Ahlefeldt</ Tab >
162128 < Tab > Carl Andersen</ Tab >
@@ -190,8 +156,9 @@ export const ManualBehaviorTabsExample = component$(() => {
190156 return (
191157 < PreviewCodeExample >
192158 < 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 >
195162 < TabList >
196163 < Tab > Maria Ahlefeldt</ Tab >
197164 < Tab > Carl Andersen</ Tab >
@@ -221,19 +188,58 @@ export const ManualBehaviorTabsExample = component$(() => {
221188 ) ;
222189} ) ;
223190
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+
224231export const OnSelectedIndexChangeTabsExample = component$ ( ( ) => {
225232 const selectedIndexSig = useSignal ( 0 ) ;
226233
227234 return (
228235 < PreviewCodeExample >
229236 < div q :slot = "actualComponent" class = "tabs-example mr-auto" >
230237 < Tabs
231- selectedIndex = { selectedIndexSig . value }
232- onSelectedIndexChange$ = { ( e ) => {
233- selectedIndexSig . value = e ;
238+ onSelectedIndexChange$ = { ( index ) => {
239+ selectedIndexSig . value = index ;
234240 } }
235241 >
236- < h3 id = "tablist-1" > Danish Composers</ h3 >
242+ < h3 > Danish Composers</ h3 >
237243 < TabList >
238244 < Tab > Maria Ahlefeldt</ Tab >
239245 < Tab > Carl Andersen</ Tab >
@@ -271,12 +277,13 @@ export const OnClickTabsExample = component$(() => {
271277 return (
272278 < PreviewCodeExample >
273279 < div q :slot = "actualComponent" class = "tabs-example mr-auto" >
280+ < h3 > Danish Composers</ h3 >
281+ < h4 > (watch the counter below)</ h4 >
274282 < Tabs
275283 onClick$ = { ( ) => {
276284 tabsClickedCountSig . value ++ ;
277285 } }
278286 >
279- < h3 id = "tablist-1" > Danish Composers</ h3 >
280287 < TabList >
281288 < Tab > Maria Ahlefeldt</ Tab >
282289 < Tab > Carl Andersen</ Tab >
0 commit comments