|
1 | | -'use client' |
| 1 | +"use client"; |
2 | 2 | import React, { useState } from "react"; |
3 | 3 | import Link from "next/link"; |
4 | 4 | import { motion } from "framer-motion"; |
5 | | -import useMediaQuery from '@mui/material/useMediaQuery'; |
| 5 | +import useMediaQuery from "@mui/material/useMediaQuery"; |
6 | 6 |
|
7 | 7 | export default function NavigationLinks() { |
| 8 | + const [activeSection, setActiveSection] = useState(""); |
| 9 | + |
| 10 | + const handleSectionClick = (section) => { |
| 11 | + setActiveSection(section); |
| 12 | + }; |
| 13 | + |
8 | 14 | const isMobile = useMediaQuery("(max-width: 600px)"); |
9 | 15 |
|
10 | 16 | const linkVariant = { |
11 | 17 | hover: { |
12 | 18 | scale: isMobile ? 1.1 : 1.02, |
13 | 19 | transition: { |
14 | 20 | duration: 0.3, |
15 | | - yoyo: Infinity |
16 | | - } |
17 | | - } |
18 | | - } |
| 21 | + yoyo: Infinity, |
| 22 | + }, |
| 23 | + }, |
| 24 | + }; |
19 | 25 |
|
20 | 26 | const handleToolsClick = () => { |
21 | 27 | document.title = "AI Fusion - Tools"; |
22 | | - } |
| 28 | + }; |
23 | 29 |
|
24 | 30 | const handlePromptsClick = () => { |
25 | 31 | document.title = "AI Fusion - Prompts"; |
26 | | - } |
| 32 | + }; |
27 | 33 |
|
28 | 34 | const handleDatasetsClick = () => { |
29 | 35 | document.title = "AI Fusion - Datasets"; |
30 | | - } |
| 36 | + }; |
31 | 37 |
|
32 | 38 | return ( |
33 | | - <motion.div className='flex text-[--dark-bg] bg-[--light-bg] dark:bg-[--dark-bg] dark:text-[--light-bg] flex-col items-center justify-between ' whileHover='hover' variants={linkVariant}> |
| 39 | + <motion.div |
| 40 | + className="flex text-[--dark-bg] bg-[--light-bg] dark:bg-[--dark-bg] dark:text-[--light-bg] flex-col items-center justify-between " |
| 41 | + whileHover="hover" |
| 42 | + variants={linkVariant} |
| 43 | + > |
34 | 44 | <div className="w-50 border border-[--dark-bg] dark:border-[--light-bg] rounded-3xl flex flex-row justify-evenly items-center"> |
35 | | - <Link className="w-24 text-center font-semibold hover:bg-[color:var(--primary-color)] hover:text-[--dark-bg] focus:bg-[--primary-color] rounded-l-3xl transition px-4 py-2" href={"/tools"} onClick={handleToolsClick}>Tools</Link> |
36 | | - <Link className="w-24 text-center font-semibold hover:bg-[color:var(--primary-color)] hover:text-[--dark-bg] focus:bg-[--primary-color] transition px-4 py-2" href={"/prompts"} onClick={handlePromptsClick}>Prompts</Link> |
37 | | - <Link className="w-24 text-center font-semibold hover:bg-[color:var(--primary-color)] hover:text-[--dark-bg] focus:bg-[--primary-color] rounded-r-3xl transition px-4 py-2" href={"/datasets"} onClick={handleDatasetsClick}>Datasets</Link> |
| 45 | + <Link |
| 46 | + className={`w-24 text-center font-semibold ${ |
| 47 | + activeSection === "tools" |
| 48 | + ? "bg-green-500 text-white" |
| 49 | + : "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]" |
| 50 | + } rounded-l-3xl transition px-4 py-2`} |
| 51 | + href="/tools" |
| 52 | + onClick={() => { |
| 53 | + handleSectionClick("tools"); |
| 54 | + handleToolsClick(); |
| 55 | + }} |
| 56 | + > |
| 57 | + Tools |
| 58 | + </Link> |
| 59 | + <Link |
| 60 | + className={`w-24 text-center font-semibold ${ |
| 61 | + activeSection === "prompts" |
| 62 | + ? "bg-green-500 text-white" |
| 63 | + : "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]" |
| 64 | + } transition px-4 py-2`} |
| 65 | + href="/prompts" |
| 66 | + onClick={() => { |
| 67 | + handleSectionClick("prompts"); |
| 68 | + handlePromptsClick(); |
| 69 | + }} |
| 70 | + > |
| 71 | + Prompts |
| 72 | + </Link> |
| 73 | + <Link |
| 74 | + className={`w-24 text-center font-semibold ${ |
| 75 | + activeSection === "datasets" |
| 76 | + ? "bg-green-500 text-white" |
| 77 | + : "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]" |
| 78 | + } rounded-r-3xl transition px-4 py-2`} |
| 79 | + href="/datasets" |
| 80 | + onClick={() => { |
| 81 | + handleSectionClick("datasets"); |
| 82 | + handleDatasetsClick(); |
| 83 | + }} |
| 84 | + > |
| 85 | + Datasets |
| 86 | + </Link> |
38 | 87 | </div> |
39 | 88 | </motion.div> |
40 | | - ) |
| 89 | + ); |
41 | 90 | } |
0 commit comments