Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scrollbar to menu #277

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.authenticationDisplayButtons {
position: absolute;
left: 0px;
bottom: 0px;
width: 100%;
margin-top: 1rem;
text-align: center;
color: white;

Expand Down
15 changes: 0 additions & 15 deletions src/components/PageLayout/MenuMain/MenuMain.module.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
.menu {
position: fixed;
width: 25%;
height: 100vh;
top: -100%;
background-color: black;
transition: 750ms;
z-index: 100;

&.visible {
left: 0;
top: 0;
}
}

.menuButton {
cursor: pointer;
display: grid;
Expand Down
2 changes: 0 additions & 2 deletions src/components/PageLayout/MenuMain/MenuMain.module.scss.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export type Styles = {
active: string
loading: string
menu: string
menuButton: string
menuCloseButton: string
menuItem: string
menuOpenButton: string
visible: string
}

export type ClassNames = keyof Styles
Expand Down
58 changes: 38 additions & 20 deletions src/components/PageLayout/MenuMain/MenuMain.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Stack, Theme, Typography, useMediaQuery} from '@mui/material'
import {Box, Stack, Theme, Typography, useMediaQuery} from '@mui/material'
import {useQuery} from '@tanstack/react-query'
import axios from 'axios'
import clsx from 'clsx'
Expand Down Expand Up @@ -45,27 +45,45 @@ export const MenuMain: FC = () => {
<Menu width={iconSize} height={iconSize} />
</div>
)}
<div className={clsx(styles.menu, isVisible && styles.visible)}>
<CloseButton size={iconSize} onClick={toggleMenu} className={clsx(styles.menuButton, styles.menuCloseButton)} />
{menuItemsIsLoading && (
<div className={styles.loading}>
<Loading />
</div>
)}
<Stack mt="176px">
{menuItems.map(({id, caption, url}) => (
// `url` je vo formate `/vysledky/` alebo `/akcie/matboj/`
<MenuMainItem key={id} caption={caption} url={`/${seminar}${url}`} />
))}
</Stack>
{hasPermissions && (
<Stack sx={{mt: 4, mx: 2, borderTop: '8px dashed white', pt: 4}}>
<MenuMainItem caption="TODO: Opravovanie" url={`/${seminar}/admin/opravovanie`} />
<MenuMainItem caption="Admin" url="/admin" />
<Stack
sx={{
position: 'fixed',
width: '25%',
height: '100%',
left: 0,
top: isVisible ? 0 : '-100%',
overflow: 'auto',
backgroundColor: 'black',
transition: '750ms',
zIndex: 100,
}}
>
<Box flexGrow={1}>
<CloseButton
size={iconSize}
onClick={toggleMenu}
className={clsx(styles.menuButton, styles.menuCloseButton)}
/>
{menuItemsIsLoading && (
<div className={styles.loading}>
<Loading />
</div>
)}
<Stack mt="176px">
{menuItems.map(({id, caption, url}) => (
// `url` je vo formate `/vysledky/` alebo `/akcie/matboj/`
<MenuMainItem key={id} caption={caption} url={`/${seminar}${url}`} />
))}
</Stack>
)}
{hasPermissions && (
<Stack sx={{mt: 4, mx: 2, borderTop: '8px dashed white', pt: 4}}>
<MenuMainItem caption="TODO: Opravovanie" url={`/${seminar}/admin/opravovanie`} />
<MenuMainItem caption="Admin" url="/admin" />
</Stack>
)}
</Box>
<Authentication />
</div>
</Stack>
</>
)
}
Expand Down
Loading