Skip to content

Commit

Permalink
fix navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
menthy-wu committed Nov 16, 2023
1 parent 47bc932 commit af60ec1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Upcoming from "@/components/static/upcoming/Upcoming";

const Home = () => {
return (
<>
<div className="w-full">
<Release release={RELEASES.STATIC.UPCOMING}>
<Upcoming />
</Release>
Expand All @@ -20,7 +20,7 @@ const Home = () => {
<Release release={RELEASES.STATIC.POSTLIVE}>
<Postlive />
</Release>
</>
</div>
);
};

Expand Down
18 changes: 11 additions & 7 deletions src/components/dynamic/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { BiSolidDownArrow } from "react-icons/bi";
const Navigation = () => {
const [expand, setExpand] = useState(false);
const pathName = usePathname();
const tabs = TABS[pathName.split("/")[1]];
const [dropdown, setDropdown] = useState(Object.keys(tabs)[0]);
const [tabs, setTabs] = useState(TABS[pathName.split("/")[1]]);

return (
<>
Expand Down Expand Up @@ -50,23 +49,28 @@ const Navigation = () => {
</div>
<div className="w-full flex flex-col items-center h-full">
{Object.entries(tabs)
.filter(([title]) => title !== " ")
.filter(([title]) => title !== " " && title !== "dropdown")
.map(([title, subTabs], index) => (
<div key={index} className="w-full">
<p
className={`text-white text-xl font-poppin font-bold w-full px-2 mb-0 flex items-center justify-between hover:cursor-pointer ${subTabs.mt}`}
onClick={() => setDropdown(title === dropdown ? "" : title)}
onClick={() =>
setTabs({
...tabs,
[title]: { ...subTabs, expand: !subTabs.expand },
})
}
>
{title}
{subTabs.expand && (
{tabs.dropdown && (
<BiSolidDownArrow
className={`text-sm duration-300 ${
dropdown === title && "rotate-180"
subTabs.expand && "rotate-180"
}`}
/>
)}
</p>
{(dropdown === title || !subTabs.expand) &&
{(subTabs.expand || !tabs.dropdown) &&
subTabs.tabs.map((tab, index) => (
<Link
key={index}
Expand Down
2 changes: 2 additions & 0 deletions src/data/dynamic/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const iconStyle = "mr-2";

export const TABS = {
admin: {
dropdown: true,
Dashboards: {
expand: true,
mt: "mt-0",
Expand Down Expand Up @@ -75,6 +76,7 @@ export const TABS = {
],
},
Services: {
dropdown: false,
expand: true,
mt: "mt-3",
tabs: [
Expand Down

0 comments on commit af60ec1

Please sign in to comment.