11// Copyright (c) Jupyter Development Team.
22// Distributed under the terms of the Modified BSD License.
33
4+ import { action } from '@storybook/addon-actions' ;
45import { setTheme } from '../utilities/storybook' ;
56
67export default {
@@ -9,23 +10,21 @@ export default {
910 activePanel : { control : 'select' , options : [ null , 'One' , 'Two' , 'Three' ] } ,
1011 activeIndicator : { control : 'boolean' } ,
1112 orientation : { control : 'radio' , options : [ 'horizontal' , 'vertical' ] }
12- } ,
13- parameters : {
14- actions : {
15- disabled : true
16- }
1713 }
1814} ;
1915
2016const Template = (
2117 args ,
2218 { globals : { backgrounds, accent } , parameters }
23- ) : string => {
19+ ) : HTMLElement => {
2420 setTheme ( accent , parameters . backgrounds , backgrounds ) ;
2521
26- return `<jp-tabs
27- ${ ! args . activeIndicator && 'activeIndicator="false"' }
28- ${ args . activePanel ? `activeId=Tab${ args . activePanel } ` : '' }
22+ const container = document . createElement ( 'div' ) ;
23+ container . insertAdjacentHTML (
24+ 'afterbegin' ,
25+ `<jp-tabs
26+ ${ ! args . activeIndicator && 'activeindicator="false"' }
27+ ${ args . activePanel ? `activeid=Tab${ args . activePanel } ` : '' }
2928 orientation="${ args . orientation } "
3029 >
3130 <jp-tab id="TabOne">Tab one</jp-tab>
@@ -40,14 +39,24 @@ const Template = (
4039 <jp-tab-panel id="TabPanelThree">
4140 Tab three content. This is for testing.
4241 </jp-tab-panel>
43- </jp-tabs>` ;
42+ </jp-tabs>`
43+ ) ;
44+
45+ const tabs = container . firstChild as HTMLElement ;
46+
47+ if ( args . onChange ) {
48+ tabs . addEventListener ( 'change' , args . onChange ) ;
49+ }
50+
51+ return tabs ;
4452} ;
4553
4654export const Default = Template . bind ( { } ) ;
4755Default . args = {
4856 activePanel : null ,
4957 activeIndicator : true ,
50- orientation : 'horizontal'
58+ orientation : 'horizontal' ,
59+ onChange : action ( 'tabs-onchange' )
5160} ;
5261
5362export const Vertical = Template . bind ( { } ) ;
0 commit comments