-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhook.tsx
More file actions
36 lines (32 loc) · 1.06 KB
/
hook.tsx
File metadata and controls
36 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use client"
import { Button } from "@/components/ui/button"
import { useTour } from "@/components/ui/tour"
import { WandSparklesIcon } from "lucide-react"
import { steps } from "./steps"
export function Hook() {
const tour = useTour({ steps })
return (
<div>
<Button className="grow-0" onClick={tour.start}>
<span>Start Tour (Hook)</span>
<WandSparklesIcon />
</Button>
{tour.isEnabled && (
<>
<div className="inset-0 fixed bg-black/50" onClick={tour.end} onKeyDown={tour.end} />
<div {...tour.floatingProps} className="p-2 max-w-sm rounded bg-white shadow-md">
{tour.currentStep?.step}
<div className="flex justify-between">
<button type="button" onClick={tour.prevStep} disabled={tour.currentStepIndex === 0}>
Previous
</button>
<button type="button" onClick={tour.nextStep}>
{tour.isLastStep ? "Finish" : "Next"}
</button>
</div>
</div>
</>
)}
</div>
)
}