File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 11import { storiesOf , moduleMetadata } from "@storybook/angular" ;
2+ import { withKnobs , boolean , number } from "@storybook/addon-knobs/angular" ;
23
34import { DialogModule } from "../../" ;
45
6+ let options ;
7+
8+ function createOptions ( count : number ) : Array < string > {
9+ if ( options && count === options . length ) {
10+ return options ;
11+ }
12+ options = Array ( count ) . fill ( 0 ) . map ( ( x , i ) => "Option " + ( i + 1 ) ) ;
13+ return options ;
14+ }
15+
516storiesOf ( "Overflow Menu" , module )
617 . addDecorator (
718 moduleMetadata ( {
@@ -10,6 +21,7 @@ storiesOf("Overflow Menu", module)
1021 ]
1122 } )
1223 )
24+ . addDecorator ( withKnobs )
1325 . add ( "Basic" , ( ) => ( {
1426 template : `
1527 <ibm-overflow-menu>
@@ -44,4 +56,21 @@ storiesOf("Overflow Menu", module)
4456 click : ( ) => console . log ( "click" ) ,
4557 selected : ( ) => console . log ( "selected" )
4658 }
59+ } ) )
60+ . add ( "Dynamic" , ( ) => ( {
61+ template : `
62+ <span>
63+ Dynamic <code style="font-family: monospace;">OverflowMenu</code>, using the <code style="font-family: monospace;">optionCount</code> knob <br/>
64+ to change the number of menu options
65+ </span>
66+ <ibm-overflow-menu>
67+ <ibm-overflow-menu-option *ngFor="let option of options(optionCount)">
68+ {{option}}
69+ </ibm-overflow-menu-option>
70+ </ibm-overflow-menu>
71+ ` ,
72+ props : {
73+ optionCount : number ( "optionCount" , 10 ) ,
74+ options : createOptions
75+ }
4776 } ) ) ;
You can’t perform that action at this time.
0 commit comments