removed unused code
This commit is contained in:
parent
825d23d5ea
commit
de66cafb0b
2 changed files with 4 additions and 44 deletions
|
@ -2,7 +2,7 @@
|
||||||
* @file Submenu item for sidebar
|
* @file Submenu item for sidebar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useState } from "react"
|
import { useCallback, useState } from "react"
|
||||||
import { Link } from "react-router-dom"
|
import { Link } from "react-router-dom"
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
|
|
||||||
|
@ -26,32 +26,15 @@ const SidebarLabel = styled.span`
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
`
|
`
|
||||||
|
|
||||||
const DropdownLink = styled(Link)`
|
|
||||||
background: #414757;
|
|
||||||
height: 60px;
|
|
||||||
padding-left: 3rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #f5f5f5;
|
|
||||||
font-size: 18px;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #632ce4;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: Item
|
item: Item
|
||||||
}
|
}
|
||||||
|
|
||||||
const SubMenu = (props: Props) => {
|
const SubMenu = (props: Props) => {
|
||||||
const [isSubNavOpen, setSubNavOpen] = useState(false)
|
const [isSubNavOpen, setSubNavOpen] = useState(false)
|
||||||
|
const handleSidebarLinkClick = useCallback(() => {
|
||||||
const handleSidebarLinkClick = () => {
|
setSubNavOpen((prev) => !prev)
|
||||||
if (props.item.subNav) setSubNavOpen((prev) => !prev)
|
}, [isSubNavOpen])
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -60,27 +43,7 @@ const SubMenu = (props: Props) => {
|
||||||
{props.item.icon}
|
{props.item.icon}
|
||||||
<SidebarLabel>{props.item.title}</SidebarLabel>
|
<SidebarLabel>{props.item.title}</SidebarLabel>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
{props.item.subNav && isSubNavOpen
|
|
||||||
? props.item.iconOpened
|
|
||||||
: props.item.subNav
|
|
||||||
? props.item.iconClosed
|
|
||||||
: undefined}
|
|
||||||
</div>
|
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
|
|
||||||
{/* not used as of the moment */}
|
|
||||||
{isSubNavOpen && // check if subNav is open
|
|
||||||
props.item.subNav && // check if subNav exists in that item
|
|
||||||
props.item.subNav.map((item, index) => {
|
|
||||||
// shows all items in subNav
|
|
||||||
return (
|
|
||||||
<DropdownLink to={item.path} key={index}>
|
|
||||||
{item.icon}
|
|
||||||
<SidebarLabel>{item.title}</SidebarLabel>
|
|
||||||
</DropdownLink>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,8 @@ import {
|
||||||
// item from sidebar data
|
// item from sidebar data
|
||||||
export type Item = {
|
export type Item = {
|
||||||
path: string
|
path: string
|
||||||
subNav?: Array<Item>
|
|
||||||
icon: JSX.Element
|
icon: JSX.Element
|
||||||
title: string
|
title: string
|
||||||
iconOpened?: JSX.Element
|
|
||||||
iconClosed?: JSX.Element
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const NavbarData: Array<Item> = [
|
const NavbarData: Array<Item> = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue