"use client"; import { useEffect, useRef, useState } from "react"; const CodeContainer = () => { const [isOpen, setIsOpen] = useState(false); const [selectedPM, setSelectedPM] = useState<"npm" | "yarn" | "pnpm" | "bun">( "npm", ); const [copied, setCopied] = useState(false); const menuRef = useRef(null); const [typingComplete, setTypingComplete] = useState(false); const [currentStep, setCurrentStep] = useState(0); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (menuRef.current && !menuRef.current.contains(event.target as Node)) { setIsOpen(false); } }; document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, []); const commands = { npm: "npx create-better-t-stack@latest", yarn: "yarn dlx create-better-t-stack", pnpm: "pnpm dlx create-better-t-stack", bun: "bunx create-better-t-stack", }; const copyToClipboard = async (pm: "npm" | "yarn" | "pnpm" | "bun") => { await navigator.clipboard.writeText(commands[pm]); setSelectedPM(pm); setCopied(true); setIsOpen(false); 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 (
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

)} {currentStep >= 2 && (

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

Database:{" "} postgres

ORM: drizzle

Authentication:{" "} yes

Addons:{" "} docker, github-actions, SEO

)}
{currentStep >= 3 && (

✓ Creating project structure

{currentStep >= 4 && (

✓ Installing dependencies

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

✓ Setting up database

✓ Configuring authentication

Project ready! Happy coding!

)}
)} )}
$
); }; const CopyIcon = ({ className = "" }) => ( copy ); const CheckIcon = ({ className = "" }) => ( check ); export default CodeContainer;