1
1
// Copyright (c) Jupyter Development Team.
2
2
// Distributed under the terms of the Modified BSD License.
3
3
4
+ import { action } from '@storybook/addon-actions' ;
4
5
import { setTheme } from '../utilities/storybook' ;
5
6
6
7
export default {
@@ -9,23 +10,21 @@ export default {
9
10
activePanel : { control : 'select' , options : [ null , 'One' , 'Two' , 'Three' ] } ,
10
11
activeIndicator : { control : 'boolean' } ,
11
12
orientation : { control : 'radio' , options : [ 'horizontal' , 'vertical' ] }
12
- } ,
13
- parameters : {
14
- actions : {
15
- disabled : true
16
- }
17
13
}
18
14
} ;
19
15
20
16
const Template = (
21
17
args ,
22
18
{ globals : { backgrounds, accent } , parameters }
23
- ) : string => {
19
+ ) : HTMLElement => {
24
20
setTheme ( accent , parameters . backgrounds , backgrounds ) ;
25
21
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 } ` : '' }
29
28
orientation="${ args . orientation } "
30
29
>
31
30
<jp-tab id="TabOne">Tab one</jp-tab>
@@ -40,14 +39,24 @@ const Template = (
40
39
<jp-tab-panel id="TabPanelThree">
41
40
Tab three content. This is for testing.
42
41
</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 ;
44
52
} ;
45
53
46
54
export const Default = Template . bind ( { } ) ;
47
55
Default . args = {
48
56
activePanel : null ,
49
57
activeIndicator : true ,
50
- orientation : 'horizontal'
58
+ orientation : 'horizontal' ,
59
+ onChange : action ( 'tabs-onchange' )
51
60
} ;
52
61
53
62
export const Vertical = Template . bind ( { } ) ;
0 commit comments