Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert "fix : Bug title not change on first click" #63

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 30 additions & 22 deletions components/NavigationLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useMediaQuery from "@mui/material/useMediaQuery";
export default function NavigationLinks() {
const [activeSection, setActiveSection] = useState("");

const handleSectionClick = (section: string) => {
const handleSectionClick = (section) => {
setActiveSection(section);
};

Expand All @@ -23,11 +23,16 @@ export default function NavigationLinks() {
},
};

const handleToolsClick = () => {
document.title = "AI Fusion - Tools";
};

const handleClick = (event: React.MouseEvent<HTMLAnchorElement>, title: string) => {
event.preventDefault();
const handlePromptsClick = () => {
document.title = "AI Fusion - Prompts";
};

document.title = `AI Fusion | ${title}`;
const handleDatasetsClick = () => {
document.title = "AI Fusion - Datasets";
};

return (
Expand All @@ -38,40 +43,43 @@ export default function NavigationLinks() {
>
<div className="w-50 border border-[--dark-bg] dark:border-[--light-bg] rounded-3xl flex flex-row justify-evenly items-center">
<Link
className={`w-24 text-center font-semibold ${activeSection === "tools"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-l-3xl transition px-4 py-2`}
className={`w-24 text-center font-semibold ${
activeSection === "tools"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-l-3xl transition px-4 py-2`}
href="/tools"
onClick={(event) => {
onClick={() => {
handleSectionClick("tools");
handleClick(event, "Tools");
handleToolsClick();
}}
>
Tools
</Link>
<Link
className={`w-24 text-center font-semibold ${activeSection === "prompts"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} transition px-4 py-2`}
className={`w-24 text-center font-semibold ${
activeSection === "prompts"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} transition px-4 py-2`}
href="/prompts"
onClick={(event) => {
onClick={() => {
handleSectionClick("prompts");
handleClick(event, "Prompts");
handlePromptsClick();
}}
>
Prompts
</Link>
<Link
className={`w-24 text-center font-semibold ${activeSection === "datasets"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-r-3xl transition px-4 py-2`}
className={`w-24 text-center font-semibold ${
activeSection === "datasets"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-r-3xl transition px-4 py-2`}
href="/datasets"
onClick={(event) => {
onClick={() => {
handleSectionClick("datasets");
handleClick(event, "Datasets");
handleDatasetsClick();
}}
>
Datasets
Expand Down
Loading