Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

HomeIntro.tsx

144 lines4.8 KB

1import { useNavigate } from "@tanstack/react-router";
2import { ArrowRightIcon, DatabaseZap } from "lucide-react";
3import { AnimatePresence, motion } from "motion/react";
4import { useCallback, useState } from "react";
5import { cn } from "@/lib/utils";
6import { Button } from "./ui/button";
7import {
8 Card,
9 CardContent,
10 CardDescription,
11 CardFooter,
12 CardHeader,
13 CardTitle,
14} from "./ui/card";
15​
16export function HomeIntro({
17 activeStep,
18 intro,
19}: {
20 activeStep: string | null;
21 intro: "true" | "false" | undefined;
22}) {
23 const [open, setOpen] = useState(
24 activeStep === null ||
25 // used for debugging
26 intro === "true",
27 );
28​
29 const navigate = useNavigate();
30​
31 const startTutorial = useCallback(() => {
32 setOpen(false);
33 navigate({
34 to: ".",
35 search: (o) => ({
36 ...o,
37 intro: "false",
38 }),
39 });
40 }, [navigate]);
41​
42 return (
43 <AnimatePresence initial={false}>
44 {open && (
45 <motion.div
46 animate={{ opacity: 1 }}
47 exit={{ opacity: 0 }}
48 className={cn(
49 "fixed top-0 left-0 right-0 p-6 bottom-0 bg-black/80 z-52 flex items-center justify-center",
50 )}
51 >
52 <Card className="w-lg p-6 gap-10 max-h-full overflow-y-auto">
53 <CardHeader>
54 <CardTitle className="flex justify-center">
55 <div className="text-sm bg-linear-to-r from-orange-500 to-orange-700 flex gap-2 items-center text-black px-4 py-1 rounded-full">
56 <DatabaseZap className="h-4" /> trytanstackdb.com{" "}
57 <span className="text-white">ALPHA</span>
58 </div>
59 </CardTitle>
60 <CardDescription className="text-center">
61 An interactive tutorial for learning{" "}
62 <a
63 href="https://tanstack.com/db/latest"
64 target="_blank"
65 rel="noreferrer"
66 className="underline hover:text-orange-500 transition-colors cursor-pointer"
67 >
68 TanStack DB
69 </a>
70 </CardDescription>
71 </CardHeader>
72 <CardContent>
73 <div className="flex flex-col gap-8">
74 <p>
75 What is{" "}
76 <a
77 href="https://tanstack.com/db/latest"
78 target="_blank"
79 rel="noreferrer"
80 className="underline text-orange-500 hover:text-orange-600 transition-colors cursor-pointer"
81 >
82 TanStack DB
83 </a>
84 ?
85 </p>
86 <p className="border-l border-orange-500 pl-4 italic font-bold text-2xl">
87 "The reactive client-first store for your API"
88 </p>
89​
90 <p>Still confused? Click the button below!</p>
91 </div>
92 <div className="text-sm text-muted-foreground mt-6 flex flex-col gap-2">
93 <p>
94 Open up the <span className="italic">Network tab</span> in the
95 dev tools panel, and get started!
96 </p>
97 <p>Here's what you'll get:</p>
98 <ul className="pl-4">
99 {[
100 "a short interactive guide (6-7 mins)",
101 "with a demo app using TanStack DB",
102 "and the source code for all of it.",
103 ].map((item, i) => (
104 <li key={i} className="flex items-start gap-2">
105 <span className="text-orange-500">★</span> {item}
106 </li>
107 ))}
108 </ul>
109 <p>
110 Follow the guide, inspect the requests, check the source code,
111 have fun!
112 </p>
113 </div>
114 </CardContent>
115 <CardFooter className="flex justify-center items-center flex-col gap-10">
116 <Button
117 onClick={startTutorial}
118 className="bg-orange-500 text-black hover:bg-orange-600 cursor-pointer transition-colors"
119 >
120 Start tutorial <ArrowRightIcon />
121 </Button>
122 <div className="flex items-center gap-2 text-muted-foreground text-sm">
123 by{" "}
124 <a
125 className="flex items-center gap-2"
126 target="_blank"
127 rel="noreferrer"
128 href="https://fulop.dev"
129 >
130 <img
131 alt="fuko"
132 src="https://avatars.githubusercontent.com/u/43729152?s=96&v=4"
133 className="inline h-10 w-10 rounded-full"
134 />
135 fuko
136 </a>
137 </div>
138 </CardFooter>
139 </Card>
140 </motion.div>
141 )}
142 </AnimatePresence>
143 );