mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-14 01:16:17 +02:00
chore: fix weird alignment issue with main content and admin menu (#9636)
This commit is contained in:
parent
db1ec7ffa6
commit
5da9f75014
@ -5,21 +5,84 @@ import { Sticky } from 'component/common/Sticky/Sticky';
|
|||||||
import { AdminMenuNavigation } from './AdminNavigationItems';
|
import { AdminMenuNavigation } from './AdminNavigationItems';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
const StyledAdminMainGrid = styled(Grid)(({ theme }) => ({
|
const breakpointLgMinusPadding = 1250;
|
||||||
|
const breakpointLgMinusPaddingAdmin = 1550;
|
||||||
|
const breakpointXlMinusPadding = 1512;
|
||||||
|
const breakpointXlAdmin = 1812;
|
||||||
|
const breakpointXxl = 1856;
|
||||||
|
const breakpointXxlAdmin = 2156;
|
||||||
|
|
||||||
|
const MainLayoutContent = styled(Grid)(({ theme }) => ({
|
||||||
minWidth: 0, // this is a fix for overflowing flex
|
minWidth: 0, // this is a fix for overflowing flex
|
||||||
maxWidth: '1812px',
|
maxWidth: `${breakpointXlMinusPadding}px`,
|
||||||
margin: '0 auto',
|
margin: '0 auto',
|
||||||
paddingLeft: theme.spacing(2),
|
paddingLeft: theme.spacing(2),
|
||||||
paddingRight: theme.spacing(2),
|
paddingRight: theme.spacing(2),
|
||||||
[theme.breakpoints.up(2156)]: {
|
[theme.breakpoints.up(breakpointXxl)]: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
},
|
},
|
||||||
[theme.breakpoints.down(2156)]: {
|
[theme.breakpoints.down(breakpointXxl)]: {
|
||||||
|
marginLeft: theme.spacing(7),
|
||||||
|
marginRight: theme.spacing(7),
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down('lg')]: {
|
||||||
|
maxWidth: `${breakpointLgMinusPadding}px`,
|
||||||
|
paddingLeft: theme.spacing(1),
|
||||||
|
paddingRight: theme.spacing(1),
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(1024)]: {
|
||||||
|
marginLeft: 0,
|
||||||
|
marginRight: 0,
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
minWidth: '100%',
|
||||||
|
},
|
||||||
|
minHeight: '94vh',
|
||||||
|
}));
|
||||||
|
|
||||||
|
const AdminMainLayoutContent = styled(Grid)(({ theme }) => ({
|
||||||
|
minWidth: 0, // this is a fix for overflowing flex
|
||||||
|
maxWidth: `${breakpointXlMinusPadding}px`,
|
||||||
|
margin: '0 auto',
|
||||||
|
paddingLeft: theme.spacing(2),
|
||||||
|
paddingRight: theme.spacing(2),
|
||||||
|
[theme.breakpoints.up(breakpointXxl)]: {
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(breakpointXxl)]: {
|
||||||
marginLeft: 0,
|
marginLeft: 0,
|
||||||
marginRight: 0,
|
marginRight: 0,
|
||||||
},
|
},
|
||||||
[theme.breakpoints.down('lg')]: {
|
[theme.breakpoints.down('lg')]: {
|
||||||
maxWidth: '1550px',
|
maxWidth: `${breakpointLgMinusPadding}px`,
|
||||||
|
paddingLeft: theme.spacing(1),
|
||||||
|
paddingRight: theme.spacing(1),
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(1024)]: {
|
||||||
|
marginLeft: 0,
|
||||||
|
marginRight: 0,
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
minWidth: '100%',
|
||||||
|
},
|
||||||
|
minHeight: '94vh',
|
||||||
|
}));
|
||||||
|
|
||||||
|
const StyledAdminMainGrid = styled(Grid)(({ theme }) => ({
|
||||||
|
minWidth: 0, // this is a fix for overflowing flex
|
||||||
|
maxWidth: `${breakpointXlAdmin}px`,
|
||||||
|
margin: '0 auto',
|
||||||
|
paddingLeft: theme.spacing(2),
|
||||||
|
paddingRight: theme.spacing(2),
|
||||||
|
[theme.breakpoints.up(breakpointXxlAdmin)]: {
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(breakpointXxlAdmin)]: {
|
||||||
|
marginLeft: 0,
|
||||||
|
marginRight: 0,
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down('lg')]: {
|
||||||
|
maxWidth: `${breakpointLgMinusPaddingAdmin}px`,
|
||||||
paddingLeft: theme.spacing(1),
|
paddingLeft: theme.spacing(1),
|
||||||
paddingRight: theme.spacing(1),
|
paddingRight: theme.spacing(1),
|
||||||
},
|
},
|
||||||
@ -65,10 +128,14 @@ export const WrapIfAdminSubpage = ({ children }: IWrapIfAdminSubpageProps) => {
|
|||||||
location.pathname.indexOf('/admin') === 0;
|
location.pathname.indexOf('/admin') === 0;
|
||||||
|
|
||||||
if (showAdminMenu) {
|
if (showAdminMenu) {
|
||||||
return <AdminMenu>{children}</AdminMenu>;
|
return (
|
||||||
|
<AdminMenu>
|
||||||
|
<AdminMainLayoutContent>{children}</AdminMainLayoutContent>
|
||||||
|
</AdminMenu>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>{children}</>;
|
return <MainLayoutContent>{children}</MainLayoutContent>;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IAdminMenuProps {
|
interface IAdminMenuProps {
|
||||||
@ -77,7 +144,8 @@ interface IAdminMenuProps {
|
|||||||
|
|
||||||
export const AdminMenu = ({ children }: IAdminMenuProps) => {
|
export const AdminMenu = ({ children }: IAdminMenuProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isBreakpoint = useMediaQuery(theme.breakpoints.down(1350));
|
const isBreakpoint = useMediaQuery(theme.breakpoints.down(1352));
|
||||||
|
const breakpointedSize = isBreakpoint ? 8 : 9;
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
scrollTo({
|
scrollTo({
|
||||||
top: 0,
|
top: 0,
|
||||||
@ -94,7 +162,7 @@ export const AdminMenu = ({ children }: IAdminMenuProps) => {
|
|||||||
</StyledMenuPaper>
|
</StyledMenuPaper>
|
||||||
</StickyContainer>
|
</StickyContainer>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item md={isBreakpoint ? true : 9}>
|
<Grid item md={breakpointedSize}>
|
||||||
{children}
|
{children}
|
||||||
</Grid>
|
</Grid>
|
||||||
</StyledAdminMainGrid>
|
</StyledAdminMainGrid>
|
||||||
|
@ -42,34 +42,6 @@ const MainLayoutContentWrapper = styled('div')(({ theme }) => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const MainLayoutContent = styled(Grid)(({ theme }) => ({
|
|
||||||
minWidth: 0, // this is a fix for overflowing flex
|
|
||||||
maxWidth: '1512px',
|
|
||||||
margin: '0 auto',
|
|
||||||
paddingLeft: theme.spacing(2),
|
|
||||||
paddingRight: theme.spacing(2),
|
|
||||||
[theme.breakpoints.up(1856)]: {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down(1856)]: {
|
|
||||||
marginLeft: theme.spacing(7),
|
|
||||||
marginRight: theme.spacing(7),
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down('lg')]: {
|
|
||||||
maxWidth: '1250px',
|
|
||||||
paddingLeft: theme.spacing(1),
|
|
||||||
paddingRight: theme.spacing(1),
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down(1024)]: {
|
|
||||||
marginLeft: 0,
|
|
||||||
marginRight: 0,
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down('sm')]: {
|
|
||||||
minWidth: '100%',
|
|
||||||
},
|
|
||||||
minHeight: '94vh',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledImg = styled('img')(() => ({
|
const StyledImg = styled('img')(() => ({
|
||||||
display: 'block',
|
display: 'block',
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
@ -147,16 +119,12 @@ export const MainLayout = forwardRef<HTMLDivElement, IMainLayoutProps>(
|
|||||||
<Header />
|
<Header />
|
||||||
|
|
||||||
<WrapIfAdminSubpage>
|
<WrapIfAdminSubpage>
|
||||||
<MainLayoutContent>
|
<SkipNavTarget />
|
||||||
<SkipNavTarget />
|
<MainLayoutContentContainer ref={ref}>
|
||||||
<MainLayoutContentContainer ref={ref}>
|
<BreadcrumbNav />
|
||||||
<BreadcrumbNav />
|
<Proclamation toast={uiConfig.toast} />
|
||||||
<Proclamation
|
{children}
|
||||||
toast={uiConfig.toast}
|
</MainLayoutContentContainer>
|
||||||
/>
|
|
||||||
{children}
|
|
||||||
</MainLayoutContentContainer>
|
|
||||||
</MainLayoutContent>
|
|
||||||
</WrapIfAdminSubpage>
|
</WrapIfAdminSubpage>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
Loading…
Reference in New Issue
Block a user