|
| 1 | +import type { TourStepDetails } from '@ark-ui/react/tour' |
| 2 | + |
| 3 | +export const steps: TourStepDetails[] = [ |
| 4 | + { |
| 5 | + type: 'dialog', |
| 6 | + id: 'step-0', |
| 7 | + title: 'Centered tour (no target)', |
| 8 | + description: 'This is the center of the world. Ready to start the tour?', |
| 9 | + actions: [{ label: 'Next', action: 'next' }], |
| 10 | + }, |
| 11 | + { |
| 12 | + type: 'tooltip', |
| 13 | + id: 'step-1', |
| 14 | + title: 'Step 1. Welcome', |
| 15 | + description: 'To the new world', |
| 16 | + target: () => document.querySelector<HTMLElement>('#step-1'), |
| 17 | + actions: [ |
| 18 | + { label: 'Prev', action: 'prev' }, |
| 19 | + { label: 'Next', action: 'next' }, |
| 20 | + ], |
| 21 | + effect({ show, update }) { |
| 22 | + const abort = new AbortController() |
| 23 | + |
| 24 | + fetch('https://api.github.com/users/octocat', { signal: abort.signal }) |
| 25 | + .then((res) => res.json()) |
| 26 | + .then((data) => { |
| 27 | + update({ title: data.name }) |
| 28 | + show() |
| 29 | + }) |
| 30 | + |
| 31 | + return () => { |
| 32 | + abort.abort() |
| 33 | + } |
| 34 | + }, |
| 35 | + }, |
| 36 | + { |
| 37 | + type: 'tooltip', |
| 38 | + id: 'step-2', |
| 39 | + title: 'Step 2. Inside a scrollable container', |
| 40 | + description: 'Using scrollIntoView(...) rocks!', |
| 41 | + target: () => document.querySelector<HTMLElement>('#step-2'), |
| 42 | + actions: [ |
| 43 | + { label: 'Prev', action: 'prev' }, |
| 44 | + { label: 'Next', action: 'next' }, |
| 45 | + ], |
| 46 | + }, |
| 47 | + { |
| 48 | + type: 'tooltip', |
| 49 | + id: 'step-2a', |
| 50 | + title: 'Step 2a. Inside an Iframe container', |
| 51 | + description: 'It calculates the offset rect correctly. Thanks to floating UI!', |
| 52 | + target: () => { |
| 53 | + const [frameEl] = Array.from(frames) |
| 54 | + return frameEl?.document.querySelector<HTMLElement>('#step-2a') |
| 55 | + }, |
| 56 | + actions: [ |
| 57 | + { label: 'Prev', action: 'prev' }, |
| 58 | + { label: 'Next', action: 'next' }, |
| 59 | + ], |
| 60 | + }, |
| 61 | + { |
| 62 | + type: 'tooltip', |
| 63 | + id: 'step-3', |
| 64 | + title: 'Step 3. Normal scrolling', |
| 65 | + description: 'The new world is a great place', |
| 66 | + target: () => document.querySelector<HTMLElement>('#step-3'), |
| 67 | + actions: [ |
| 68 | + { label: 'Prev', action: 'prev' }, |
| 69 | + { label: 'Next', action: 'next' }, |
| 70 | + ], |
| 71 | + }, |
| 72 | + { |
| 73 | + type: 'tooltip', |
| 74 | + id: 'step-4', |
| 75 | + title: 'Step 4. Close to bottom', |
| 76 | + description: 'So nice to see the scrolling works!', |
| 77 | + target: () => document.querySelector<HTMLElement>('#step-4'), |
| 78 | + actions: [ |
| 79 | + { label: 'Prev', action: 'prev' }, |
| 80 | + { label: 'Next', action: 'next' }, |
| 81 | + ], |
| 82 | + }, |
| 83 | + { |
| 84 | + type: 'dialog', |
| 85 | + id: 'step-5', |
| 86 | + title: "You're all sorted! (no target)", |
| 87 | + description: 'Thanks for trying out the tour. Enjoy the app!', |
| 88 | + actions: [{ label: 'Finish', action: 'dismiss' }], |
| 89 | + }, |
| 90 | +] |
0 commit comments