|
| 1 | +"use client"; |
| 2 | +import Image from "next/image"; |
| 3 | +import { useState, useEffect } from "react"; |
| 4 | +import { Button } from "@/components/ui/button"; |
| 5 | +import { X } from "lucide-react"; |
| 6 | +import Link from "next/link"; |
| 7 | + |
| 8 | +const images = { |
| 9 | + stare: "/characters/stare.png", |
| 10 | + okay: "/characters/okay.png", |
| 11 | + thankyou: "/characters/thank-you.png", |
| 12 | +}; |
| 13 | + |
| 14 | +export function JobCard() { |
| 15 | + const [active, setActive] = useState("stare"); |
| 16 | + const [mounted, setMounted] = useState(false); |
| 17 | + const [isVisible, setIsVisible] = useState(true); |
| 18 | + |
| 19 | + useEffect(() => { |
| 20 | + setMounted(true); |
| 21 | + // Check if user previously closed the card in this session |
| 22 | + const isHidden = sessionStorage.getItem("hide-job-card"); |
| 23 | + if (isHidden) setIsVisible(false); |
| 24 | + }, []); |
| 25 | + |
| 26 | + const handleClose = () => { |
| 27 | + setIsVisible(false); |
| 28 | + sessionStorage.setItem("hide-job-card", "true"); |
| 29 | + }; |
| 30 | + |
| 31 | + if (!mounted || !isVisible) return null; |
| 32 | + |
| 33 | + return ( |
| 34 | + <div className="group relative w-full max-w-[240px] rounded-xl border p-5 shadow-sm transition-all hover:shadow-md mt-8 backdrop-blur-sm"> |
| 35 | + {/* Subtle Close Button */} |
| 36 | + <button |
| 37 | + onClick={handleClose} |
| 38 | + className="absolute right-2 top-2 p-1 rounded-md opacity-0 group-hover:opacity-100 hover:bg-muted transition-all" |
| 39 | + aria-label="Close card" |
| 40 | + > |
| 41 | + <X size={14} className="text-muted-foreground" /> |
| 42 | + </button> |
| 43 | + |
| 44 | + <div className="flex flex-col items-center text-center gap-4"> |
| 45 | + {/* Character - Clean & Scaled */} |
| 46 | + <div className="relative w-20 h-20 transition-transform duration-300 ease-out group-hover:scale-110"> |
| 47 | + <Image |
| 48 | + src={images[active as keyof typeof images]} |
| 49 | + alt="Character" |
| 50 | + width={80} |
| 51 | + height={80} |
| 52 | + className="object-contain" |
| 53 | + /> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div className="space-y-2"> |
| 57 | + <div className="space-y-1"> |
| 58 | + <p className="text-xs font-semibold text-foreground tracking-tight"> |
| 59 | + Available for work |
| 60 | + </p> |
| 61 | + <p className="text-xs leading-relaxed text-muted-foreground text-balance"> |
| 62 | + I'm graduating soon and looking to join a team. |
| 63 | + </p> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + |
| 67 | + <div className="w-full flex flex-col gap-2 pt-1"> |
| 68 | + <Link href={"/hire-me"}> |
| 69 | + <Button |
| 70 | + size="sm" |
| 71 | + variant={"outline"} |
| 72 | + onMouseEnter={() => setActive("thankyou")} |
| 73 | + onMouseLeave={() => setActive("stare")} |
| 74 | + className="w-full text-[11px] h-8 font-medium border-primary/20 hover:bg-primary/5 hover:text-primary transition-colors" |
| 75 | + > |
| 76 | + View My Work |
| 77 | + </Button> |
| 78 | + </Link> |
| 79 | + |
| 80 | + <button |
| 81 | + onMouseEnter={() => setActive("okay")} |
| 82 | + onMouseLeave={() => setActive("stare")} |
| 83 | + onClick={handleClose} |
| 84 | + className="w-full text-[10px] text-muted-foreground/60 hover:text-muted-foreground transition-colors py-1" |
| 85 | + > |
| 86 | + Maybe later |
| 87 | + </button> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + ); |
| 92 | +} |
0 commit comments