1
- import { Tour , useTour } from '@ark-ui/react/tour'
2
- import type { StepDetails } from '@zag-js/tour'
3
- import { XIcon } from 'lucide-react'
4
- import { useEffect } from 'react'
5
- import { Frame } from '../../frame'
6
-
7
- export const DemoTour = ( ) => {
8
- const tour = useTour ( { steps : tourData } )
9
-
10
- // Start the tour when the component mounts
11
- useEffect ( ( ) => {
12
- tour . start ( )
13
- } , [ tour ] )
14
-
15
- return (
16
- < Tour . Root tour = { tour } >
17
- < Tour . Backdrop />
18
- < Tour . Spotlight />
19
- < Tour . Positioner >
20
- < Tour . Content >
21
- < Tour . Arrow >
22
- < Tour . ArrowTip />
23
- </ Tour . Arrow >
24
- < Tour . Title />
25
- < Tour . Description />
26
- < Tour . ProgressText />
27
- < Tour . CloseTrigger >
28
- < XIcon />
29
- </ Tour . CloseTrigger >
30
- < Tour . Actions >
31
- { ( actions ) =>
32
- actions . map ( ( action ) => < Tour . ActionTrigger key = { action . label } action = { action } /> )
33
- }
34
- </ Tour . Actions >
35
- </ Tour . Content >
36
- </ Tour . Positioner >
37
- </ Tour . Root >
38
- )
39
- }
1
+ import { Frame } from '@ark-ui/react/frame'
2
+ import { DemoTour } from './tour'
40
3
41
4
export const Basic = ( ) => {
42
5
return (
43
- < main className = "tour" >
44
- < div >
6
+ < main >
7
+ < DemoTour />
8
+ < div className = "tour" >
45
9
< div className = "steps__container" >
46
10
< h3 id = "step-1" > Step 1</ h3 >
47
11
< div className = "overflow__container" >
@@ -59,97 +23,7 @@ export const Basic = () => {
59
23
< h3 id = "step-3" > Step 3</ h3 >
60
24
< h3 id = "step-4" > Step 4</ h3 >
61
25
</ div >
62
- < DemoTour />
63
26
</ div >
64
27
</ main >
65
28
)
66
29
}
67
-
68
- export const tourData : StepDetails [ ] = [
69
- {
70
- type : 'dialog' ,
71
- id : 'step-0' ,
72
- title : 'Centered tour (no target)' ,
73
- description : 'This is the center of the world. Ready to start the tour?' ,
74
- actions : [ { label : 'Next' , action : 'next' } ] ,
75
- } ,
76
- {
77
- type : 'tooltip' ,
78
- id : 'step-1' ,
79
- title : 'Step 1. Welcome' ,
80
- description : 'To the new world' ,
81
- target : ( ) => document . querySelector < HTMLElement > ( '#step-1' ) ,
82
- actions : [
83
- { label : 'Prev' , action : 'prev' } ,
84
- { label : 'Next' , action : 'next' } ,
85
- ] ,
86
- effect ( { show, update } ) {
87
- const abort = new AbortController ( )
88
-
89
- fetch ( 'https://api.github.com/users/octocat' , { signal : abort . signal } )
90
- . then ( ( res ) => res . json ( ) )
91
- . then ( ( data ) => {
92
- update ( { title : data . name } )
93
- show ( )
94
- } )
95
-
96
- return ( ) => {
97
- abort . abort ( )
98
- }
99
- } ,
100
- } ,
101
- {
102
- type : 'tooltip' ,
103
- id : 'step-2' ,
104
- title : 'Step 2. Inside a scrollable container' ,
105
- description : 'Using scrollIntoView(...) rocks!' ,
106
- target : ( ) => document . querySelector < HTMLElement > ( '#step-2' ) ,
107
- actions : [
108
- { label : 'Prev' , action : 'prev' } ,
109
- { label : 'Next' , action : 'next' } ,
110
- ] ,
111
- } ,
112
- {
113
- type : 'tooltip' ,
114
- id : 'step-2a' ,
115
- title : 'Step 2a. Inside an Iframe container' ,
116
- description : 'It calculates the offset rect correctly. Thanks to floating UI!' ,
117
- target : ( ) => {
118
- const [ frameEl ] = Array . from ( frames )
119
- return frameEl ?. document . querySelector < HTMLElement > ( '#step-2a' )
120
- } ,
121
- actions : [
122
- { label : 'Prev' , action : 'prev' } ,
123
- { label : 'Next' , action : 'next' } ,
124
- ] ,
125
- } ,
126
- {
127
- type : 'tooltip' ,
128
- id : 'step-3' ,
129
- title : 'Step 3. Normal scrolling' ,
130
- description : 'The new world is a great place' ,
131
- target : ( ) => document . querySelector < HTMLElement > ( '#step-3' ) ,
132
- actions : [
133
- { label : 'Prev' , action : 'prev' } ,
134
- { label : 'Next' , action : 'next' } ,
135
- ] ,
136
- } ,
137
- {
138
- type : 'tooltip' ,
139
- id : 'step-4' ,
140
- title : 'Step 4. Close to bottom' ,
141
- description : 'So nice to see the scrolling works!' ,
142
- target : ( ) => document . querySelector < HTMLElement > ( '#step-4' ) ,
143
- actions : [
144
- { label : 'Prev' , action : 'prev' } ,
145
- { label : 'Next' , action : 'next' } ,
146
- ] ,
147
- } ,
148
- {
149
- type : 'dialog' ,
150
- id : 'step-5' ,
151
- title : "You're all sorted! (no target)" ,
152
- description : 'Thanks for trying out the tour. Enjoy the app!' ,
153
- actions : [ { label : 'Finish' , action : 'dismiss' } ] ,
154
- } ,
155
- ]
0 commit comments