|
1 | 1 | 'use client';
|
2 | 2 |
|
3 |
| -import { Building2Icon, Construction, CloudDrizzleIcon, HandMetalIcon, Settings } from "lucide-react"; |
4 |
| -import { usePathname } from "next/navigation"; |
5 |
| -import Link from "next/link"; |
6 | 3 | import { useState } from "react";
|
| 4 | +import { usePathname } from "next/navigation"; |
| 5 | +import { |
| 6 | + Building2Icon, |
| 7 | + Construction, |
| 8 | + CloudDrizzleIcon, |
| 9 | + HandMetalIcon, |
| 10 | + Settings, |
| 11 | +} from "lucide-react"; |
7 | 12 | import TutorialPopup from "@/content/Dialogue/helpButton";
|
| 13 | +import { MiningComponentComponent } from "../mining-component"; |
8 | 14 |
|
9 | 15 | const menuItems = [
|
10 |
| - { icon: Building2Icon, label: "Structures", href: "/" }, |
11 |
| - { icon: Construction, label: "Mining", href: "/#" }, |
12 |
| - { icon: CloudDrizzleIcon, label: "Weather", href: "/#" }, |
13 |
| - { icon: HandMetalIcon, label: "Topography", href: "/#" }, |
| 16 | + { icon: Building2Icon, label: "Structures", content: "Structures Content" }, |
| 17 | + { icon: Construction, label: "Mining", content: <MiningComponentComponent /> }, |
| 18 | + { icon: CloudDrizzleIcon, label: "Weather", content: "Weather Content" }, |
| 19 | + { icon: HandMetalIcon, label: "Topography", content: <TutorialPopup /> }, |
14 | 20 | ];
|
15 | 21 |
|
16 | 22 | export default function VerticalToolbar() {
|
17 | 23 | const pathname = usePathname();
|
18 | 24 | const [hovered, setHovered] = useState<string | null>(null);
|
19 |
| - const [isMenuOpen, setIsMenuOpen] = useState(false); |
| 25 | + const [activeModal, setActiveModal] = useState<string | null>(null); |
20 | 26 |
|
21 | 27 | return (
|
22 | 28 | <div className="z-50">
|
| 29 | + {/* Vertical Toolbar for larger screens */} |
23 | 30 | <div className="hidden md:block fixed left-4 top-1/4 transform -translate-y-1/2">
|
24 | 31 | <nav className="bg-[#1E3A4C] rounded-xl shadow-lg backdrop-blur-md bg-opacity-80 p-2">
|
25 | 32 | <ul className="flex flex-col space-y-4">
|
26 |
| - {menuItems.map(({ icon: Icon, label, href }) => ( |
| 33 | + {menuItems.map(({ icon: Icon, label }) => ( |
27 | 34 | <li key={label}>
|
28 |
| - <Link legacyBehavior href={href}> |
29 |
| - <a |
30 |
| - onMouseEnter={() => setHovered(label)} |
31 |
| - onMouseLeave={() => setHovered(null)} |
32 |
| - className={`flex items-center px-4 py-3 rounded-full transition-all duration-300 relative |
33 |
| - ${pathname === href |
| 35 | + <button |
| 36 | + onMouseEnter={() => setHovered(label)} |
| 37 | + onMouseLeave={() => setHovered(null)} |
| 38 | + onClick={() => setActiveModal(label)} |
| 39 | + className={`flex items-center px-4 py-3 rounded-full transition-all duration-300 relative |
| 40 | + ${ |
| 41 | + pathname === label |
34 | 42 | ? "bg-white text-[#1E3A4C] shadow-md"
|
35 |
| - : "text-white hover:bg-white/10"}`} |
36 |
| - aria-label={label} |
| 43 | + : "text-white hover:bg-white/10" |
| 44 | + }`} |
| 45 | + aria-label={label} |
| 46 | + > |
| 47 | + <Icon className="w-6 h-6" /> |
| 48 | + <span |
| 49 | + className={`absolute left-12 opacity-0 transition-opacity duration-300 ${ |
| 50 | + hovered === label || pathname === label ? "opacity-100" : "" |
| 51 | + } text-sm font-medium whitespace-nowrap bg-[#1E3A4C] bg-opacity-90 text-white px-2 py-1 rounded-md`} |
37 | 52 | >
|
38 |
| - <Icon className="w-6 h-6" /> |
39 |
| - <span |
40 |
| - className={`absolute left-12 opacity-0 transition-opacity duration-300 ${ |
41 |
| - hovered === label || pathname === href ? 'opacity-100' : '' |
42 |
| - } text-sm font-medium whitespace-nowrap bg-[#1E3A4C] bg-opacity-90 text-white px-2 py-1 rounded-md`} |
43 |
| - > |
44 |
| - {label} |
45 |
| - </span> |
46 |
| - </a> |
47 |
| - </Link> |
| 53 | + {label} |
| 54 | + </span> |
| 55 | + </button> |
48 | 56 | </li>
|
49 | 57 | ))}
|
50 | 58 | </ul>
|
51 |
| - <div className="mt-4"> |
52 |
| - <center> |
53 |
| - <TutorialPopup /> |
54 |
| - </center> |
55 |
| - </div> |
56 | 59 | </nav>
|
57 | 60 | </div>
|
58 | 61 |
|
| 62 | + {/* Modal for Popups */} |
| 63 | + {activeModal && ( |
| 64 | + <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"> |
| 65 | + <div |
| 66 | + className="w-[90vw] max-w-3xl h-[90vh] bg-white rounded-lg p-4 overflow-y-auto relative" |
| 67 | + > |
| 68 | + <button |
| 69 | + onClick={() => setActiveModal(null)} |
| 70 | + className="absolute top-4 right-4 text-gray-500 hover:text-gray-700" |
| 71 | + aria-label="Close modal" |
| 72 | + > |
| 73 | + β |
| 74 | + </button> |
| 75 | + <h2 className="text-xl font-bold mb-4">{activeModal}</h2> |
| 76 | + <div className="text-gray-800"> |
| 77 | + {menuItems.find((item) => item.label === activeModal)?.content} |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + </div> |
| 81 | + )} |
| 82 | + |
| 83 | + {/* Bottom Menu for smaller screens */} |
59 | 84 | <div className="block md:hidden fixed left-4 bottom-4">
|
60 | 85 | <button
|
61 |
| - onClick={() => setIsMenuOpen(!isMenuOpen)} |
| 86 | + onClick={() => setActiveModal("Menu")} |
62 | 87 | className="bg-[#1E3A4C] p-4 rounded-full shadow-lg text-white focus:outline-none"
|
63 | 88 | aria-label="Open menu"
|
64 | 89 | >
|
65 | 90 | <Settings className="w-6 h-6" />
|
66 | 91 | </button>
|
67 | 92 |
|
68 |
| - {isMenuOpen && ( |
| 93 | + {activeModal === "Menu" && ( |
69 | 94 | <div className="absolute left-0 bottom-16 bg-[#1E3A4C] rounded-xl shadow-lg backdrop-blur-md bg-opacity-80 p-2">
|
70 | 95 | <ul className="flex flex-col space-y-4">
|
71 |
| - {menuItems.map(({ icon: Icon, label, href }) => ( |
| 96 | + {menuItems.map(({ icon: Icon, label }) => ( |
72 | 97 | <li key={label}>
|
73 |
| - <Link legacyBehavior href={href}> |
74 |
| - <a |
75 |
| - onClick={() => setIsMenuOpen(false)} |
76 |
| - className={`flex items-center space-x-2 px-4 py-3 rounded-full transition-all duration-300 |
77 |
| - ${pathname === href |
| 98 | + <button |
| 99 | + onClick={() => setActiveModal(label)} |
| 100 | + className={`flex items-center space-x-2 px-4 py-3 rounded-full transition-all duration-300 |
| 101 | + ${ |
| 102 | + pathname === label |
78 | 103 | ? "bg-white text-[#1E3A4C] shadow-md"
|
79 |
| - : "text-white hover:bg-white/10"}`} |
80 |
| - aria-label={label} |
81 |
| - > |
82 |
| - <Icon className="w-6 h-6" /> |
83 |
| - <span className="text-sm font-medium">{label}</span> |
84 |
| - </a> |
85 |
| - </Link> |
| 104 | + : "text-white hover:bg-white/10" |
| 105 | + }`} |
| 106 | + aria-label={label} |
| 107 | + > |
| 108 | + <Icon className="w-6 h-6" /> |
| 109 | + <span className="text-sm font-medium">{label}</span> |
| 110 | + </button> |
86 | 111 | </li>
|
87 | 112 | ))}
|
88 | 113 | </ul>
|
|
0 commit comments