Skip to content

Commit

Permalink
Menu for shortcuts (#1006)
Browse files Browse the repository at this point in the history
* init

* added shortcut navigations for external sites

* Changed icon and added logout button
  • Loading branch information
MadsNyl authored Apr 11, 2024
1 parent 6112c18 commit fa61a9e
Show file tree
Hide file tree
Showing 19 changed files with 651 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### 🎨 - Designendringer

## Neste versjon
-**Shortcuts**. La til meny med shortcuts.

## Versjon 2023.10.04
- 🎨 **Footer**. La til NITO logo i footer under "samarbeid"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
Expand Down Expand Up @@ -85,8 +86,8 @@
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.38.1",
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.56.0",
"autoprefixer": "^10.4.18",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import-helpers": "^1.3.1",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
148 changes: 148 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/URLS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ const URLS = {
jobpostsAdmin: '/admin/karriere/',
newsAdmin: '/admin/nyheter/',
bannerAdmin: '/admin/bannere/',
jubilee: 'jubileum.tihlde.org/',
jubilee: 'https://jubileum.tihlde.org/',
fondet: 'https://fondet.tihlde.org/',
kontRes: 'https://kontres.tihlde.org/',
github: 'https://github.com/TIHLDE',
pythons: 'https://pythons.tihlde.org/',
pythonsLadies: 'https://pythons-damer.tihlde.org/',
};

export default URLS;
61 changes: 61 additions & 0 deletions src/components/miscellaneous/shortCutMenu/Admin.tsx
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;
42 changes: 42 additions & 0 deletions src/components/miscellaneous/shortCutMenu/HotKey.tsx
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;
29 changes: 29 additions & 0 deletions src/components/miscellaneous/shortCutMenu/Item.tsx
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;
Loading

0 comments on commit fa61a9e

Please sign in to comment.