Skip to content

Commit

Permalink
fix: consistent settings tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSciFier committed Sep 8, 2023
1 parent 349cd86 commit 253bb37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions frontend/src/pages/settings/tabHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from "react";

export default function TabHeader({ title, isActive, onClick }) {
return (
<li
<a
className={`px-4 py-2 hover:bg-cyan-600/10 hover:cursor-pointer ${
isActive ? "border-b-2 border-cyan-500" : ""
}`}
onClick={onClick}
href={`#${title}`}
>
{title}
</li>
</a>
);
}
12 changes: 11 additions & 1 deletion frontend/src/pages/settings/tabView.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import TabHeader from "./tabHeader";
import AboutTab from "./tabs/aboutTab";
import GroupTab from "./tabs/groupTab/groupTab";
import MainTab from "./tabs/mainTab/mainTab";
import InterfaceTab from "./tabs/interfaceTab/interfaceTab";
import { useLocation } from "react-router";

export default function TabView() {
const location = useLocation();
const tabs = [
{
header: "Main",
Expand All @@ -27,6 +29,14 @@ export default function TabView() {

const [curentTab, setCurentTab] = useState(0);

useEffect(() => {
if (location.hash) {
let found = tabs.filter((tab) => tab.header === location.hash.slice(1));
let foundIdx = tabs.indexOf(found[0]);
setCurentTab(foundIdx);
}
}, []);

return (
<div className="md:w-2/4 w-full px-3">
<ul className="flex gap-3 w-full text-lg overflow-x-auto">
Expand Down

0 comments on commit 253bb37

Please sign in to comment.