-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * added shortcut navigations for external sites * Changed icon and added logout button
- Loading branch information
Showing
19 changed files
with
651 additions
and
5 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,61 @@ | ||
import URLS from 'URLS'; | ||
|
||
import { PermissionApp } from 'types/Enums'; | ||
|
||
import { HavePermission } from 'hooks/User'; | ||
|
||
import { ShortCutMenuProps } from '.'; | ||
import ShortCutLink from './Item'; | ||
import ShortCutSectionWrapper from './SectionWrapper'; | ||
|
||
const ShortCutAdmin = ({ setOpen }: Pick<ShortCutMenuProps, 'setOpen'>) => { | ||
const links = [ | ||
{ | ||
apps: [PermissionApp.EVENT], | ||
title: 'Arrangementer', | ||
path: URLS.eventAdmin, | ||
}, | ||
{ | ||
apps: [PermissionApp.GROUP], | ||
title: 'Grupper', | ||
path: URLS.groups.index, | ||
}, | ||
{ | ||
apps: [PermissionApp.JOBPOST], | ||
title: 'Jobbannonser', | ||
path: URLS.jobpostsAdmin, | ||
}, | ||
{ | ||
apps: [PermissionApp.USER], | ||
title: 'Medlemmer', | ||
path: URLS.userAdmin, | ||
}, | ||
{ | ||
apps: [PermissionApp.NEWS], | ||
title: 'Nyheter', | ||
path: URLS.newsAdmin, | ||
}, | ||
{ | ||
apps: [PermissionApp.STRIKE], | ||
title: 'Prikker', | ||
path: URLS.strikeAdmin, | ||
}, | ||
{ | ||
apps: [PermissionApp.BANNERS], | ||
title: 'Bannere', | ||
path: URLS.bannerAdmin, | ||
}, | ||
]; | ||
|
||
return ( | ||
<ShortCutSectionWrapper title='Admin'> | ||
{links.map((link, index) => ( | ||
<HavePermission apps={link.apps} key={index}> | ||
<ShortCutLink setOpen={setOpen} {...link} /> | ||
</HavePermission> | ||
))} | ||
</ShortCutSectionWrapper> | ||
); | ||
}; | ||
|
||
export default ShortCutAdmin; |
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,42 @@ | ||
import { ArrowBigUp, Command, Option } from 'lucide-react'; | ||
import { ReactNode } from 'react'; | ||
|
||
type HotKeyProps = { | ||
modifiers: Array<'shift' | 'alt' | 'ctrl' | undefined>; | ||
letter: string; | ||
}; | ||
|
||
const HotKey = ({ modifiers, letter }: HotKeyProps) => { | ||
const getModifierKey = (modifier: 'shift' | 'alt' | 'ctrl' | undefined): ReactNode | undefined => { | ||
switch (modifier) { | ||
case 'shift': | ||
return <ArrowBigUp className='w-4 h-4 stroke-[1.5px]' />; | ||
case 'alt': | ||
return <Option className='w-4 h-4 stroke-[1.5px]' />; | ||
case 'ctrl': | ||
return <Command className='w-4 h-4 stroke-[1.5px]' />; | ||
default: | ||
return undefined; | ||
} | ||
}; | ||
|
||
const getModifierKeys = (): ReactNode | undefined => { | ||
if (modifiers.length === 0) { | ||
return undefined; | ||
} | ||
return modifiers.map((modifier, index) => ( | ||
<span className='mr-1 p-1 border border-primary/30 rounded-md' key={index}> | ||
{getModifierKey(modifier)} | ||
</span> | ||
)); | ||
}; | ||
|
||
return ( | ||
<div className='flex items-center'> | ||
{getModifierKeys()} | ||
<span className='font-medium p-1 px-2 text-xs border border-primary/30 rounded-md'>{letter.toUpperCase()}</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HotKey; |
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,29 @@ | ||
import { Link as LinkIcon, SquareArrowOutUpRight } from 'lucide-react'; | ||
import { Dispatch, ReactNode, SetStateAction } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
type MenuItemProps = { | ||
title: string; | ||
path: string; | ||
setOpen: Dispatch<SetStateAction<boolean>>; | ||
external?: boolean; | ||
hotKey?: ReactNode; | ||
}; | ||
|
||
const ShortCutLink = ({ title, path, setOpen, external, hotKey }: MenuItemProps) => { | ||
return ( | ||
<Link | ||
className='flex items-center justify-between text-sm p-2 rounded-md hover:bg-secondary' | ||
onClick={() => setOpen(false)} | ||
rel={external ? 'noreferrer' : ''} | ||
target={external ? '_blank' : ''} | ||
to={path}> | ||
<div className='flex items-center'> | ||
{!external ? <LinkIcon className='mr-2 w-4 h-4 stroke-[1.5px]' /> : <SquareArrowOutUpRight className='mr-2 w-4 h-4 stroke-[1.5px]' />} {title} | ||
</div> | ||
{hotKey && hotKey} | ||
</Link> | ||
); | ||
}; | ||
|
||
export default ShortCutLink; |
Oops, something went wrong.