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

HomeIntro.tsx

139 lines4.4 KB

1import { useNavigate } from "@tanstack/react-router";
2import { ArrowRightIcon, DatabaseZap } from "lucide-react";
3import { AnimatePresence, motion } from "motion/react";
4import { type ReactNode, useCallback, useState } from "react";
5import { cn } from "@/lib/utils";
6import { Button } from "./ui/button";
7import {
8 Card,
9 CardContent,
10 CardFooter,
11 CardHeader,
12 CardTitle,
13} from "./ui/card";
14​
15function Bold({ children }: { children: ReactNode }) {
16 return <span className="font-bold text-foreground">{children}</span>;
18​
19function FeatureItem({ children }: { children: ReactNode }) {
20 return (
21 <li className="text-muted-foreground">
22 <span className="text-primary">★</span> {children}
23 </li>
24 );
26​
27function WavyLine() {
28 return <div className="text-muted-foreground text-center">〰〰 ★ 〰〰</div>;
30​
31export function HomeIntro({
32 activeStep,
33 intro,
34}: {
35 activeStep: string | null;
36 intro: "true" | "false" | undefined;
37}) {
38 const [open, setOpen] = useState(
39 activeStep === null ||
40 // used for debugging
41 intro === "true",
42 );
43​
44 const navigate = useNavigate();
45​
46 const startTutorial = useCallback(() => {
47 setOpen(false);
48 navigate({
49 to: ".",
50 search: (o) => ({
51 ...o,
52 intro: "false",
53 }),
54 });
55 }, [navigate]);
56​
57 return (
58 <AnimatePresence initial={false}>
59 {open && (
60 <motion.div
61 animate={{ opacity: 1 }}
62 exit={{ opacity: 0 }}
63 className={cn(
64 "fixed top-0 left-0 right-0 p-6 bottom-0 bg-black/80 z-52 flex items-center justify-center backdrop-blur-xs",
65 )}
66 >
67 <Card className="w-lg p-6 gap-10 max-h-full overflow-y-auto">
68 <CardHeader>
69 <CardTitle className="flex justify-center">
70 <div className="text-sm flex gap-2 items-center px-4 py-1 rounded-full">
71 <DatabaseZap className="h-4 text-primary" /> trytanstackdb.com{" "}
72 <span className="text-muted-foreground">BETA</span>
73 </div>
74 </CardTitle>
75 </CardHeader>
76 <CardContent className="space-y-6">
77 <WavyLine />
78 <p className="text-xl font-bold">
79 <a
80 className="text-primary hover:underline hover:cursor-pointer"
81 target="_blank"
82 rel="noreferrer"
83 href="https://tanstack.com/db"
84 >
85 TanStack DB
86 </a>{" "}
87 is a library that makes it really easy to build ⚡blazing fast⚡
88 front-ends.
89 </p>
90 <WavyLine />
91 <ul className="pl-4">
92 <FeatureItem>
93 <Bold>user actions feel instant</Bold> – updates show
94 immediately while sync happens in the background
95 </FeatureItem>
96 <FeatureItem>
97 <Bold>fetch data once, use everywhere</Bold> – Tanstack DB
98 keeps it up to date
99 </FeatureItem>
100 <FeatureItem>
101 <Bold>use any database and language on the backend</Bold> – no
102 new libs needed
103 </FeatureItem>
104 </ul>
105 <p>
106 Sounds amazing, right? Learn the basics with this interactive
107 tutorial in 6-7 minutes!
108 </p>
109 </CardContent>
110 <CardFooter className="flex justify-center items-center flex-col gap-10">
111 <Button
112 onClick={startTutorial}
113 className="bg-primary cursor-pointer"
114 >
115 Get started <ArrowRightIcon />
116 </Button>
117 <div className="flex items-center gap-2 text-muted-foreground text-sm">
118 by{" "}
119 <a
120 className="flex items-center gap-2"
121 target="_blank"
122 rel="noreferrer"
123 href="https://fulop.dev"
124 >
125 <img
126 alt="fuko"
127 src="https://avatars.githubusercontent.com/u/43729152?s=96&v=4"
128 className="inline h-10 w-10 rounded-full border"
129 />
130 fuko
131 </a>
132 </div>
133 </CardFooter>
134 </Card>
135 </motion.div>
136 )}
137 </AnimatePresence>
138 );