Open History to see the last commit
1import { ArrowRightIcon, DatabaseZap } from "lucide-react";
2import { AnimatePresence, motion, stagger, type Variants } from "motion/react";
3import { type ReactNode, useCallback, useMemo, useState } from "react";
4import { cn } from "@/lib/utils";
5import { getShowIntro } from "@/utils/getShowIntro";
6import { Button } from "./ui/button";
7import {
8 Card,
9 CardContent,
10 CardDescription,
11 CardFooter,
12 CardHeader,
13 CardTitle,
14} from "./ui/card";
15
16const container = {
17 hidden: { opacity: 0 },
18 show: {
19 opacity: 1,
20 transition: {
21 when: "beforeChildren",
22 delayChildren: stagger(0.2),
23 },
24 },
25} satisfies Variants;
26
27const item = {
28 hidden: { opacity: 0, translateY: 20 },
29 show: {
30 opacity: 1,
31 translateY: 0,
32 transition: { duration: 0.4 },
33 },
34} satisfies Variants;
35
36function FeatureItem({
37 children,
38 title,
39 emoji,
40}: {
41 title: string;
42 children: ReactNode;
43 emoji: string;
44}) {
45 return (
46 <motion.li className="text-muted-foreground h-50 w-50" variants={item}>
47 <Card className="gap-3 h-full">
48 <CardHeader className="font-bold text-pretty">
49 {emoji} {title}
50 </CardHeader>
51 <CardContent>
52 <CardDescription>{children}</CardDescription>
53 </CardContent>
54 </Card>
55 </motion.li>
56 );
57}
58
59function WavyLine() {
60 return <div className="text-muted-foreground text-center">〰〰 ★ 〰〰</div>;
61}
62
63export function HomeIntro({
64 activeStep,
65 showIntro,
66}: {
67 activeStep: string | null;
68 showIntro: boolean;
69}) {
70 const [open, setOpen] = useState(
71 activeStep === null ||
72 // used for debugging
73 showIntro,
74 );
75
76 const { updateShowIntro } = useMemo(() => getShowIntro(), []);
77
78 const startTutorial = useCallback(() => {
79 setOpen(false);
80 updateShowIntro("hidden");
81 }, [updateShowIntro]);
82
83 return (
84 <AnimatePresence initial={true}>
85 {open && (
86 <motion.div
87 initial="hidden"
88 animate="show"
89 variants={container}
90 exit={{
91 opacity: 0,
92 transition: { duration: 0.2 },
93 }}
94 className={cn(
95 "fixed top-0 left-0 right-0 p-6 bottom-0 bg-black/80 z-52 flex items-center justify-center backdrop-blur-xs",
96 )}
97 >
98 <Card className="w-3xl p-6 gap-10 max-h-full overflow-y-auto bg-background">
99 <CardHeader>
100 <CardTitle className="flex justify-center">
101 <div className="text-sm flex gap-2 items-center px-4 py-1 rounded-full">
102 <DatabaseZap className="h-4 text-primary" /> trytanstackdb.com{" "}
103 <span className="text-muted-foreground">BETA</span>
104 </div>
105 </CardTitle>
106 </CardHeader>
107 <CardContent className="space-y-6 flex justify-center flex-col items-center">
108 <motion.p
109 initial={{ opacity: 0 }}
110 animate={{ opacity: 1 }}
111 className="text-xl font-bold max-w-md text-pretty text-center"
112 >
113 <a
114 className="text-primary hover:underline hover:cursor-pointer"
115 target="_blank"
116 rel="noreferrer"
117 href="https://tanstack.com/db"
118 >
119 TanStack DB
120 </a>{" "}
121 is a library that makes it really easy to build ⚡blazing fast⚡
122 front-ends.
123 </motion.p>
124 <WavyLine />
125 <ul className="flex flex-wrap gap-4">
126 <FeatureItem emoji={"🚀"} title="User actions feel instant">
127 Updates show immediately while sync happens in the background.
128 </FeatureItem>
129 <FeatureItem
130 emoji={"🔄"}
131 title="Fetch data once, use everywhere"
132 >
133 Tanstack DB keeps it up to date!
134 </FeatureItem>
135 <FeatureItem
136 emoji={"🤝"}
137 title="Use any database and language on the backend"
138 >
139 No new libs needed.
140 </FeatureItem>
141 </ul>
142 <p className="max-w-sm text-center">
143 Sounds amazing, right? Learn the basics with this interactive
144 tutorial in 6-7 minutes!
145 </p>
146 </CardContent>
147 <CardFooter className="flex justify-center items-center flex-col gap-10">
148 <Button
149 onClick={startTutorial}
150 className="bg-primary cursor-pointer"
151 >
152 Get started <ArrowRightIcon />
153 </Button>
154 <div className="flex items-center gap-2 text-muted-foreground text-sm">
155 by{" "}
156 <a
157 className="flex items-center gap-2"
158 target="_blank"
159 rel="noreferrer"
160 href="https://fulop.dev"
161 >
162 <img
163 alt="fuko"
164 src="https://avatars.githubusercontent.com/u/43729152?s=96&v=4"
165 className="inline h-10 w-10 rounded-full border"
166 />
167 fuko
168 </a>
169 </div>
170 </CardFooter>
171 </Card>
172 </motion.div>
173 )}
174 </AnimatePresence>
175 );
176}