@@ -291,6 +291,68 @@ Async.parameters = {
291
291
} ,
292
292
} ;
293
293
294
+ export const Dynamic : Story = props => {
295
+ const addTab = ( ) => {
296
+ const tabGroup = document . querySelector ( 'uui-tab-group' ) ;
297
+ if ( ! tabGroup ) return ;
298
+
299
+ const tab = document . createElement ( 'uui-tab' ) ;
300
+ const nameWithRandomLength = Math . random ( ) . toString ( 36 ) . substring ( 7 ) ;
301
+ tab . label = nameWithRandomLength ;
302
+ tab . innerHTML = nameWithRandomLength ;
303
+ tabGroup . appendChild ( tab ) ;
304
+ } ;
305
+
306
+ const removeRandomTab = ( ) => {
307
+ const tabGroup = document . querySelector ( 'uui-tab-group' ) ;
308
+ if ( ! tabGroup ) return ;
309
+
310
+ const tabs = tabGroup . querySelectorAll ( 'uui-tab' ) ;
311
+ if ( tabs . length > 0 ) {
312
+ const randomIndex = Math . floor ( Math . random ( ) * tabs . length ) ;
313
+ tabGroup . removeChild ( tabs [ randomIndex ] ) ;
314
+ }
315
+ } ;
316
+
317
+ return html `
318
+ < uui-icon-registry-essential >
319
+ < div style ="display: flex ">
320
+ < uui-tab-group
321
+ dropdown-direction ="vertical "
322
+ style ="
323
+ margin: auto;
324
+ --uui-tab-group-gap: 25px;
325
+ font-size: var(--uui-type-small-size);
326
+ ${ props . inlineStyles } ">
327
+ </ uui-tab-group >
328
+ </ div >
329
+ < uui-button @click =${ addTab } > Add tab</ uui-button >
330
+ < uui-button @click =${ removeRandomTab } > Remove tab</ uui-button >
331
+ </ uui-icon-registry-essential >
332
+ ` ;
333
+ } ;
334
+ Dynamic . parameters = {
335
+ docs : {
336
+ source : {
337
+ code : `
338
+ <uui-tab-group>
339
+ <uui-tab>
340
+ <uui-icon slot="icon" name="document"></uui-icon>
341
+ Content
342
+ </uui-tab>
343
+ <uui-tab active>
344
+ <uui-icon slot="icon" name="settings"></uui-icon>
345
+ Packages
346
+ </uui-tab>
347
+ <uui-tab>
348
+ <uui-icon slot="icon" name="picture"></uui-icon>
349
+ Media
350
+ </uui-tab>
351
+ </uui-tab-group>` ,
352
+ } ,
353
+ } ,
354
+ } ;
355
+
294
356
export const FlexLayout : Story = props => html `
295
357
< uui-icon-registry-essential >
296
358
< div style ="display: flex; ">
0 commit comments