From 2c3300ea042f4e3cb6da4ca4736cc2363d31b300 Mon Sep 17 00:00:00 2001 From: fgrreloaded Date: Sat, 1 Mar 2025 22:09:26 +0530 Subject: [PATCH] redesigned the code container box --- .../app/(home)/_components/CodeContainer.tsx | 216 ++++++++++++++---- apps/web/src/app/(home)/page.tsx | 8 +- 2 files changed, 174 insertions(+), 50 deletions(-) diff --git a/apps/web/src/app/(home)/_components/CodeContainer.tsx b/apps/web/src/app/(home)/_components/CodeContainer.tsx index 9e3cce9..0817bb7 100644 --- a/apps/web/src/app/(home)/_components/CodeContainer.tsx +++ b/apps/web/src/app/(home)/_components/CodeContainer.tsx @@ -1,8 +1,5 @@ "use client"; - -import { ChevronRight } from "lucide-react"; import { useEffect, useRef, useState } from "react"; -import PackageIcon from "./Icons"; const CodeContainer = () => { const [isOpen, setIsOpen] = useState(false); @@ -11,6 +8,8 @@ const CodeContainer = () => { ); const [copied, setCopied] = useState(false); const menuRef = useRef(null); + const [typingComplete, setTypingComplete] = useState(false); + const [currentStep, setCurrentStep] = useState(0); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { @@ -25,8 +24,8 @@ const CodeContainer = () => { const commands = { npm: "npx create-better-t-stack@latest", - yarn: "yarn dlx create better-t-stack", - pnpm: "pnpm dlx create better-t-stack", + yarn: "yarn dlx create-better-t-stack", + pnpm: "pnpm dlx create-better-t-stack", bun: "bunx create-better-t-stack", }; @@ -38,53 +37,178 @@ const CodeContainer = () => { setTimeout(() => setCopied(false), 2000); }; + useEffect(() => { + if (!typingComplete) { + const timer = setTimeout(() => { + setTypingComplete(true); + }, 1000); + return () => clearTimeout(timer); + } + + if (typingComplete && currentStep < 5) { + const timer = setTimeout(() => { + setCurrentStep((prev) => prev + 1); + }, 800); + return () => clearTimeout(timer); + } + }, [typingComplete, currentStep]); + return ( -
-
-
-
-
-
- - - {commands[selectedPM]} +
+
+
+
+
+
+
+
+
+
terminal
+
+ + {/* Package Manager Selector */} +
+ + + {isOpen && ( +
+
    + {( + Object.keys(commands) as Array< + "npm" | "yarn" | "pnpm" | "bun" + > + ).map((pm) => ( +
  • + +
  • + ))} +
+
+ )} +
+
+ +
+
+
+ $ + {commands[selectedPM]} + + ▌
-
- +
+ + {typingComplete && ( + <> +
+ {currentStep >= 1 && ( +

= 1 ? "opacity-100" : "opacity-0" + }`} + > + Creating a new Better-T-Stack project +

)} - - {isOpen && ( -
- {(["npm", "yarn", "pnpm", "bun"] as const).map((pm) => ( - - ))} + {currentStep >= 2 && ( +
+

+ Project name:{" "} + my-t-stack +

+

+ Database:{" "} + postgres +

+

+ ORM: drizzle +

+

+ Authentication:{" "} + yes +

+

+ Features:{" "} + + docker, github-actions, SEO + +

+
+ )} +
+ + {currentStep >= 3 && ( +
+

✓ Creating project structure

+ {currentStep >= 4 && ( +

✓ Installing dependencies

+ )} + {currentStep >= 5 && ( + <> +

✓ Setting up database

+

+ ✓ Configuring authentication +

+

+ Project ready! Happy coding! +

+ + )}
)} -
+ + )} + +
+ $ +
diff --git a/apps/web/src/app/(home)/page.tsx b/apps/web/src/app/(home)/page.tsx index 196335e..9518dce 100644 --- a/apps/web/src/app/(home)/page.tsx +++ b/apps/web/src/app/(home)/page.tsx @@ -15,11 +15,11 @@ export default function HomePage() {

- + Better-T Stack - +

@@ -28,7 +28,7 @@ export default function HomePage() { Scaffold {" "} - + production-ready {" "} @@ -44,7 +44,7 @@ export default function HomePage() {
-
+