Skip to content

Commit eabc866

Browse files
Resolved the problem for switching between the dark and light mode for the tools, prompts, datasets. (#62)
1 parent 2382fae commit eabc866

1 file changed

Lines changed: 63 additions & 14 deletions

File tree

components/NavigationLinks.tsx

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,90 @@
1-
'use client'
1+
"use client";
22
import React, { useState } from "react";
33
import Link from "next/link";
44
import { motion } from "framer-motion";
5-
import useMediaQuery from '@mui/material/useMediaQuery';
5+
import useMediaQuery from "@mui/material/useMediaQuery";
66

77
export default function NavigationLinks() {
8+
const [activeSection, setActiveSection] = useState("");
9+
10+
const handleSectionClick = (section) => {
11+
setActiveSection(section);
12+
};
13+
814
const isMobile = useMediaQuery("(max-width: 600px)");
915

1016
const linkVariant = {
1117
hover: {
1218
scale: isMobile ? 1.1 : 1.02,
1319
transition: {
1420
duration: 0.3,
15-
yoyo: Infinity
16-
}
17-
}
18-
}
21+
yoyo: Infinity,
22+
},
23+
},
24+
};
1925

2026
const handleToolsClick = () => {
2127
document.title = "AI Fusion - Tools";
22-
}
28+
};
2329

2430
const handlePromptsClick = () => {
2531
document.title = "AI Fusion - Prompts";
26-
}
32+
};
2733

2834
const handleDatasetsClick = () => {
2935
document.title = "AI Fusion - Datasets";
30-
}
36+
};
3137

3238
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+
>
3444
<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>
3887
</div>
3988
</motion.div>
40-
)
89+
);
4190
}

0 commit comments

Comments
 (0)