1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00

feat: UI tweak new sidebar (#7165)

This commit is contained in:
Mateusz Kwasniewski 2024-05-27 13:35:27 +02:00 committed by GitHub
parent 6e8e807e44
commit 67148dbdc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 52 additions and 17 deletions

View File

@ -40,9 +40,11 @@ const StyledDraftBanner = styled(Box)(({ theme }) => ({
paddingRight: theme.spacing(9), paddingRight: theme.spacing(9),
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
[theme.breakpoints.down(1024)]: { [theme.breakpoints.down('lg')]: {
marginLeft: 0, marginLeft: 0,
marginRight: 0, marginRight: 0,
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
}, },
[theme.breakpoints.down('sm')]: { [theme.breakpoints.down('sm')]: {
minWidth: '100%', minWidth: '100%',

View File

@ -70,6 +70,12 @@ const NewMainLayoutContent = styled(Grid)(({ theme }) => ({
paddingRight: theme.spacing(1), paddingRight: theme.spacing(1),
margin: 0, margin: 0,
}, },
[theme.breakpoints.up('xl')]: {
maxWidth: '1920px',
marginLeft: 'auto',
marginRight: 'auto',
},
minHeight: '94vh',
})); }));
const StyledImg = styled('img')(() => ({ const StyledImg = styled('img')(() => ({

View File

@ -59,6 +59,7 @@ import GitHubIcon from '@mui/icons-material/GitHub';
import LibraryBooksIcon from '@mui/icons-material/LibraryBooks'; import LibraryBooksIcon from '@mui/icons-material/LibraryBooks';
import { basePath } from 'utils/formatPath'; import { basePath } from 'utils/formatPath';
import { useLocalStorageState } from 'hooks/useLocalStorageState'; import { useLocalStorageState } from 'hooks/useLocalStorageState';
import type { Theme } from '@mui/material/styles/createTheme';
export const StyledProjectIcon = styled(ProjectIcon)(({ theme }) => ({ export const StyledProjectIcon = styled(ProjectIcon)(({ theme }) => ({
fill: theme.palette.neutral.main, fill: theme.palette.neutral.main,
@ -82,6 +83,14 @@ const EnterprisePlanBadge = () => (
</Tooltip> </Tooltip>
); );
const listItemButtonStyle = (theme: Theme) => ({
borderRadius: theme.spacing(0.5),
borderLeft: `${theme.spacing(0.5)} solid transparent`,
'&:hover': {
borderLeft: `${theme.spacing(0.5)} solid ${theme.palette.primary.main}`,
},
});
const FullListItem: FC<{ const FullListItem: FC<{
href: string; href: string;
text: string; text: string;
@ -90,11 +99,16 @@ const FullListItem: FC<{
}> = ({ href, text, badge, onClick, children }) => { }> = ({ href, text, badge, onClick, children }) => {
return ( return (
<ListItem disablePadding onClick={onClick}> <ListItem disablePadding onClick={onClick}>
<ListItemButton dense={true} component={Link} to={href}> <ListItemButton
dense={true}
component={Link}
to={href}
sx={listItemButtonStyle}
>
<ListItemIcon sx={(theme) => ({ minWidth: theme.spacing(4) })}> <ListItemIcon sx={(theme) => ({ minWidth: theme.spacing(4) })}>
{children} {children}
</ListItemIcon> </ListItemIcon>
<ListItemText primary={text} /> <ListItemText sx={{ whiteSpace: 'nowrap' }} primary={text} />
{badge} {badge}
</ListItemButton> </ListItemButton>
</ListItem> </ListItem>
@ -148,7 +162,12 @@ const MiniListItem: FC<{ href: string; text: string }> = ({
}) => { }) => {
return ( return (
<ListItem disablePadding> <ListItem disablePadding>
<ListItemButton dense={true} component={Link} to={href}> <ListItemButton
dense={true}
component={Link}
to={href}
sx={listItemButtonStyle}
>
<Tooltip title={text} placement='right'> <Tooltip title={text} placement='right'>
<ListItemIcon <ListItemIcon
sx={(theme) => ({ minWidth: theme.spacing(4) })} sx={(theme) => ({ minWidth: theme.spacing(4) })}
@ -163,8 +182,7 @@ const MiniListItem: FC<{ href: string; text: string }> = ({
export const StyledBox = styled(Box)(({ theme }) => ({ export const StyledBox = styled(Box)(({ theme }) => ({
backgroundColor: theme.palette.background.paper, backgroundColor: theme.palette.background.paper,
paddingTop: theme.spacing(2), padding: theme.spacing(2, 1, 6, 1),
paddingBottom: theme.spacing(6),
})); }));
const icons: Record<string, typeof SvgIcon> = { const icons: Record<string, typeof SvgIcon> = {
@ -206,19 +224,22 @@ const IconRenderer: FC<{ path: string }> = ({ path }) => {
return <IconComponent />; return <IconComponent />;
}; };
const ShowHideWrapper = styled(Box, {
shouldForwardProp: (prop) => prop !== 'mode',
})<{ mode: 'mini' | 'full' }>(({ theme, mode }) => ({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
margin: theme.spacing(2, 1, 0, mode === 'mini' ? 1.5 : 2),
cursor: 'pointer',
}));
const ShowHide: FC<{ mode: 'full' | 'mini'; onChange: () => void }> = ({ const ShowHide: FC<{ mode: 'full' | 'mini'; onChange: () => void }> = ({
mode, mode,
onChange, onChange,
}) => { }) => {
return ( return (
<Box <ShowHideWrapper onClick={onChange} mode={mode}>
sx={(theme) => ({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
margin: theme.spacing(2, 1, 0, mode === 'mini' ? 1 : 2),
})}
>
{mode === 'full' && ( {mode === 'full' && (
<Box <Box
sx={(theme) => ({ sx={(theme) => ({
@ -229,10 +250,16 @@ const ShowHide: FC<{ mode: 'full' | 'mini'; onChange: () => void }> = ({
Hide ( + B) Hide ( + B)
</Box> </Box>
)} )}
<IconButton onClick={onChange}> <IconButton>
{mode === 'full' ? <ChevronLeftIcon /> : <ChevronRightIcon />} {mode === 'full' ? (
<ChevronLeftIcon />
) : (
<Tooltip title='Expand (⌘ + B)' placement='right'>
<ChevronRightIcon />
</Tooltip>
)}
</IconButton> </IconButton>
</Box> </ShowHideWrapper>
); );
}; };