11import { Box , Button , Tour , type TourProps } from "@frigade/react" ;
22import { StoryContext , StoryFn } from "@storybook/react" ;
3- import { useEffect , useRef } from "react" ;
3+ import { useEffect , useRef , useState } from "react" ;
44
55export default {
66 title : "Components/Tour" ,
@@ -23,28 +23,33 @@ export const Default = {
2323 } ,
2424 decorators : [
2525 ( _ : StoryFn , options : StoryContext ) => {
26- // const [open, setOpen] = useState(true);
26+ const [ , setForceRender ] = useState ( Math . random ( ) ) ;
27+ const [ open , setOpen ] = useState ( true ) ;
2728 // const { flow } = useFlow("flow_U63A5pndRrvCwxNs");
2829
2930 const lateAnchorRef = useRef ( null ) ;
3031
3132 useEffect ( ( ) => {
32- // @ts -expect-error Shush TypeScript, it's a debug ref in a story, it's fine
33- lateAnchorRef . current = (
34- < Box
35- borderRadius = "10px"
36- id = "tooltip-storybook-0"
37- p = { 4 }
38- style = { { background : "pink" , width : "200px" } }
39- >
40- < Button . Primary
41- title = "Anchor here"
42- onClick = { ( ) => {
43- // no-op
44- } }
45- />
46- </ Box >
47- ) ;
33+ setTimeout ( ( ) => {
34+ // @ts -expect-error Shush TypeScript, it's a debug ref in a story, it's fine
35+ lateAnchorRef . current = (
36+ < Box
37+ borderRadius = "10px"
38+ id = "tooltip-storybook-0"
39+ p = { 4 }
40+ style = { { background : "pink" , width : "200px" } }
41+ >
42+ < Button . Primary
43+ title = "Anchor here"
44+ onClick = { ( ) => {
45+ // no-op
46+ } }
47+ />
48+ </ Box >
49+ ) ;
50+
51+ setForceRender ( Math . random ( ) ) ;
52+ } , 333 ) ;
4853 } , [ ] ) ;
4954
5055 return (
@@ -77,11 +82,12 @@ export const Default = {
7782 Second anchor
7883 </ Box >
7984 < Tour
80- // onOpenChange={setOpen}
81- // open={open}
85+ onOpenChange = { setOpen }
86+ open = { open }
8287 // variables={{
8388 // firstName: "John",
8489 // }}
90+ onSecondary = { ( ) => setOpen ( false ) }
8591 { ...( options . args as TourProps ) }
8692 />
8793 </ Box >
0 commit comments