-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor topnav menu items * fix exports
- Loading branch information
1 parent
ea67a2f
commit 49bced5
Showing
4 changed files
with
81 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { Icon } from '@mdi/react'; | ||
|
||
type ExternalLinkMenuItemProps = { | ||
url: string; | ||
name: string; | ||
icon: string; | ||
}; | ||
|
||
const ExternalLinkMenuItem = React.memo(({ | ||
icon, | ||
name, | ||
url, | ||
}: ExternalLinkMenuItemProps) => ( | ||
<a | ||
href={url} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
aria-label={`Open ${name}`} | ||
data-tooltip-id="tooltip" | ||
data-tooltip-content={name} | ||
> | ||
<Icon className="text-topnav-icon" path={icon} size={1} /> | ||
</a> | ||
)); | ||
|
||
export default ExternalLinkMenuItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
import { Icon } from '@mdi/react'; | ||
import cx from 'classnames'; | ||
|
||
type LinkMenuItemProps = { | ||
icon: string; | ||
onClick: () => void; | ||
path: string; | ||
text: string; | ||
}; | ||
|
||
const LinkMenuItem = React.memo((props: LinkMenuItemProps) => { | ||
const { | ||
icon, | ||
onClick, | ||
path, | ||
text, | ||
} = props; | ||
return ( | ||
<NavLink | ||
to={path} | ||
key={path.split('/') | ||
.pop()} | ||
className={({ isActive }) => cx('flex items-center gap-x-3', isActive && 'text-topnav-text-primary')} | ||
onClick={onClick} | ||
> | ||
<Icon path={icon} size={1} /> | ||
{text} | ||
</NavLink> | ||
); | ||
}); | ||
|
||
export default LinkMenuItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,24 @@ | ||
import React from 'react'; | ||
import { | ||
mdiCogOutline, | ||
mdiFormatListBulletedSquare, | ||
mdiLayersTripleOutline, | ||
mdiTabletDashboard, | ||
mdiTextBoxOutline, | ||
mdiTools, | ||
} from '@mdi/js'; | ||
import { Icon } from '@mdi/react'; | ||
import cx from 'classnames'; | ||
|
||
const iconMap = { | ||
dashboard: mdiTabletDashboard, | ||
collection: mdiLayersTripleOutline, | ||
utilities: mdiTools, | ||
actions: mdiFormatListBulletedSquare, | ||
log: mdiTextBoxOutline, | ||
settings: mdiCogOutline, | ||
}; | ||
|
||
enum IconType { | ||
dashboard = 'dashboard', | ||
collection = 'collection', | ||
utilities = 'utilities', | ||
actions = 'actions', | ||
log = 'log', | ||
settings = 'settings', | ||
} | ||
|
||
export type MenuItemProps = { | ||
icon: IconType; | ||
label: string; | ||
className?: string; | ||
onClick: React.MouseEventHandler<HTMLDivElement>; | ||
id: string; | ||
text: string; | ||
icon: string; | ||
onClick: () => void; | ||
isHighlighted: boolean; | ||
}; | ||
|
||
function MenuItem(props: MenuItemProps) { | ||
const { | ||
className, | ||
icon, | ||
label, | ||
onClick, | ||
} = props; | ||
|
||
return ( | ||
<div className={cx(className, 'text-lg flex items-center')} onClick={onClick}> | ||
<div className="flex w-5 content-center justify-center"> | ||
<Icon path={iconMap[icon]} size={1} horizontal vertical rotate={180} /> | ||
</div> | ||
<div className="pl-4 font-semibold">{label}</div> | ||
</div> | ||
); | ||
} | ||
const MenuItem = React.memo(({ icon, id, isHighlighted, onClick, text }: MenuItemProps) => ( | ||
<div | ||
key={id} | ||
className={cx('flex items-center gap-x-3 cursor-pointer', isHighlighted && 'text-topnav-text-primary')} | ||
onClick={onClick} | ||
> | ||
<Icon path={icon} size={1} /> | ||
{text} | ||
</div> | ||
)); | ||
|
||
export default MenuItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters