@@ -24,9 +24,8 @@ export default {
2424 argTypes : { } ,
2525} as Meta < typeof VisualTour > ;
2626
27- // FIXME: should give code example about the tour, not only about the elements used as targets
2827const Template : StoryFn < typeof VisualTour > = ( args : VisualTourProps ) => {
29- const [ closed , setClosed ] = React . useState < boolean > ( true ) ;
28+ const [ isOpen , setIsOpen ] = React . useState < boolean | undefined > ( ) ;
3029
3130 return (
3231 < div style = { { minHeight : "600px" , minWidth : "800px" } } >
@@ -37,7 +36,7 @@ const Template: StoryFn<typeof VisualTour> = (args: VisualTourProps) => {
3736 < ToolbarSection id = { "buttonSection" } >
3837 < Button id = { "actionA" } > Action A</ Button >
3938 < Button id = { "actionB" } > Action B</ Button >
40- < Button id = { "startTour" } intent = { "primary" } onClick = { ( ) => setClosed ( false ) } >
39+ < Button id = { "startTour" } intent = { "primary" } onClick = { ( ) => setIsOpen ( true ) } >
4140 Start tour!
4241 </ Button >
4342 </ ToolbarSection >
@@ -49,7 +48,11 @@ const Template: StoryFn<typeof VisualTour> = (args: VisualTourProps) => {
4948 < div id = "actionD" style = { { margin : "1rem" , padding : "1rem" , border : "dotted 1px lightgray" } } >
5049 Another element for the tour, not visible at first.
5150 </ div >
52- { ! closed ? < VisualTour { ...args } onClose = { ( ) => setClosed ( true ) } /> : null }
51+ < VisualTour
52+ { ...args }
53+ onClose = { ( ) => setIsOpen ( false ) }
54+ dontStartAutomatically = { typeof isOpen !== "undefined" ? ! isOpen : args . dontStartAutomatically }
55+ />
5356 </ div >
5457 ) ;
5558} ;
@@ -107,5 +110,6 @@ const defaultArgs: VisualTourProps = {
107110 } ,
108111 ] ,
109112 onClose : ( ) => { } ,
113+ dontStartAutomatically : true ,
110114} ;
111115Default . args = defaultArgs ;
0 commit comments