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

feat: change menu style #408

Merged
merged 3 commits into from
Nov 8, 2024
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
2 changes: 1 addition & 1 deletion cypress/e2e/job/preheats/preheats.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Preheats', () => {

cy.get('[data-testid="isloading"]').should('not.exist');

cy.get(':nth-child(3) > .css-ibh903-MuiButtonBase-root-MuiListItemButton-root').click();
cy.get('.MuiList-root > :nth-child(3) > .MuiButtonBase-root').click();

// Whether the style selected by menu is Preheat.
cy.get(
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/job/task/executions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Executions', () => {

cy.get('#list-11 > .css-1mlhis1').should('exist').find('#PENDING-11').should('exist');

cy.get(':nth-child(3) > .css-ibh903-MuiButtonBase-root-MuiListItemButton-root').click();
cy.get('.MuiList-root > :nth-child(3) > .MuiButtonBase-root').click();

// Whether the style selected by menu is Task.
cy.get(
Expand Down
5 changes: 5 additions & 0 deletions public/icons/cluster/selected-cluster.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/icons/cluster/user.svg

This file was deleted.

12 changes: 12 additions & 0 deletions public/icons/insight/selected-insight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/icons/job/preheat/selected-job.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions public/icons/tokens/selected-developer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/icons/user/selected-user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/icons/user/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/components/menu/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
background-position: center;
height: 100vh;
max-width: 16rem;
background-color: rgba(254, 252, 251, 86%);
display: flex;
flex-direction: column;
justify-content: space-between;
Expand Down Expand Up @@ -39,7 +38,15 @@
background: var(--button-color) !important;
}

.menu {
padding-top: 0.4rem;
padding-bottom: 0.4rem;
width: 14rem;
}

.expandMenu {
padding-top: 0.4rem;
padding-bottom: 0.4rem;
width: 14rem;
float: right;
}
67 changes: 44 additions & 23 deletions src/components/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import List from '@mui/material/List';
import { ListItemButton, ListItemIcon } from '@mui/material';
import { createContext, useEffect, useState } from 'react';
import { ExpandLess, ExpandMore, Logout, PersonAdd } from '@mui/icons-material';
import ChevronRightOutlinedIcon from '@mui/icons-material/ChevronRightOutlined';
import { getUserRoles, getUser, signOut, getUserResponse } from '../../lib/api';
import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
import { getJwtPayload, setPageTitle } from '../../lib/utils';
Expand Down Expand Up @@ -134,12 +135,14 @@ export default function Layout(props: any) {
href: '/clusters',
text: 'Cluster',
icon: <Box component="img" className={styles.menuIcon} src="/icons/cluster/cluster.svg" />,
selectedIcon: <Box component="img" className={styles.menuIcon} src="/icons/cluster/selected-cluster.svg" />,
},
{
label: 'Developer',
label: 'developer',
href: '/tokens',
text: 'Developer',
icon: <Box component="img" className={styles.menuIcon} src="/icons/tokens/developer.svg" />,
selectedIcon: <Box component="img" className={styles.menuIcon} src="/icons/tokens/selected-developer.svg" />,
expand: expandDeveloper,
setExpand: setExpandDeveloper,
menuProps: [
Expand All @@ -151,10 +154,11 @@ export default function Layout(props: any) {
],
},
{
label: 'Job',
label: 'jobs',
href: '/jobs',
text: 'Job',
icon: <Box component="img" className={styles.menuIcon} src="/icons/job/preheat/job.svg" />,
selectedIcon: <Box component="img" className={styles.menuIcon} src="/icons/job/preheat/selected-job.svg" />,
expand: expandJob,
setExpand: setExpandJob,
menuProps: [
Expand All @@ -171,10 +175,11 @@ export default function Layout(props: any) {
],
},
{
label: 'Insight',
label: 'insight',
href: '/insight',
text: 'Insight',
icon: <Box component="img" className={styles.menuIcon} src="/icons/insight/insight.svg" />,
selectedIcon: <Box component="img" className={styles.menuIcon} src="/icons/insight/selected-insight.svg" />,
expand: expandInsight,
setExpand: setExpandInsight,
menuProps: [
Expand All @@ -192,7 +197,8 @@ export default function Layout(props: any) {
label: 'users',
href: '/users',
text: 'User',
icon: <Box component="img" className={styles.menuIcon} src="/icons/cluster/user.svg" />,
icon: <Box component="img" className={styles.menuIcon} src="/icons/user/user.svg" />,
selectedIcon: <Box component="img" className={styles.menuIcon} src="/icons/user/selected-user.svg" />,
});
}

Expand Down Expand Up @@ -261,46 +267,56 @@ export default function Layout(props: any) {
<List component="nav" aria-label="main mailbox folders">
{menu.map((items) =>
items?.menuProps ? (
<Box key={items.href} className={styles.expandMenu}>
<Box key={items.href} className={styles.menu}>
<ListItemButton
selected={(location.pathname.split('/')[1] || '') === items.label}
onClick={() => {
items?.setExpand(!items?.expand);
}}
sx={{
'&.Mui-selected': { backgroundColor: '#DFFF55' },
'&.Mui-selected': {
backgroundColor: 'var(--menu-background-color)',
color: 'var(--menu-color)',
},
'&.Mui-selected:hover': {
backgroundColor: '#DDFF55',
color: '#121726',
backgroundColor: 'var(--hover-menu-background-color)',
color: 'var(--menu-color)',
},
height: '2rem',
height: '2.6rem',
borderRadius: '0.2rem',
}}
>
{items.icon}
{(location.pathname.split('/')[1] || '') === items.label ? items.selectedIcon : items.icon}
<Typography variant="subtitle1" sx={{ fontFamily: 'mabry-bold', ml: '0.4rem', width: '100%' }}>
{items.text}
</Typography>
{items.expand ? <ExpandLess /> : <ExpandMore />}
{items.expand ? <ExpandMore /> : <ChevronRightOutlinedIcon />}
</ListItemButton>
<Collapse in={items.expand} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
{items.menuProps?.map((item) => {
return (
<ListItemButton
selected={location.pathname.split('/')[2] === item.label}
className={styles.expandMenu}
selected={(location.pathname.split('/')[2] || '') === item.label}
component={Link}
to={item.href || ''}
sx={{
'&.Mui-selected': { backgroundColor: '#DFFF55' },
'&.Mui-selected': {
backgroundColor: '#fff',
color: 'var(--menu-color)',
},
'&.Mui-selected:hover': {
backgroundColor: '#DDFF55',
color: '#121726',
backgroundColor: '#fff',
color: 'var(--menu-color)',
},
height: '2rem',
height: '2.4rem',
borderRadius: '0.2rem',
pl: '1rem',
mt: '0.8rem',
}}
>
<Typography variant="body1" sx={{ ml: '2rem', fontFamily: 'mabry-bold' }}>
<Typography variant="body1" sx={{ fontFamily: 'mabry-bold', ml: '2rem' }}>
{item.text}
</Typography>
</ListItemButton>
Expand All @@ -311,22 +327,27 @@ export default function Layout(props: any) {
</Box>
) : (
<ListItemButton
className={styles.menu}
key={items.href}
selected={location.pathname.split('/')[1] === items.label}
selected={(location.pathname.split('/')[1] || '') === items.label}
component={Link}
to={items.href}
sx={{
'&.Mui-selected': { backgroundColor: '#DFFF55' },
'&.Mui-selected': {
backgroundColor: 'var(--menu-background-color)',
color: 'var(--menu-color)',
},
'&.Mui-selected:hover': {
backgroundColor: '#DDFF55',
color: '#121726',
backgroundColor: 'var(--hover-menu-background-color)',
color: 'var(--menu-color)',
},
height: '2rem',
height: '2.6rem',
borderRadius: '0.2rem',
mb: '0.4rem',
mt: '0.4rem',
}}
>
{items.icon}
{(location.pathname.split('/')[1] || '') === items.label ? items.selectedIcon : items.icon}
<Typography variant="subtitle1" sx={{ fontFamily: 'mabry-bold', ml: '0.4rem' }}>
{items.text}
</Typography>
Expand Down
3 changes: 3 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
--scopes-icon-color: #edeff2;
--table-title-color: #f6f6f6;
--title-light-color: #7a7a7a;
--menu-background-color: rgba(0, 167, 111, 0.08);
--hover-menu-background-color: rgba(0, 167, 111, 0.2);
--menu-color: #00a76f;
}

body {
Expand Down