Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
94 changes: 48 additions & 46 deletions frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.tsx
Expand Up @@ -6,9 +6,9 @@ import { useContext } from 'react';
import StringTruncator from '../StringTruncator/StringTruncator';
import { styled } from '@mui/material';

const StyledBreadCrumbs = styled(Breadcrumbs)(({ theme }) => ({
position: 'absolute',
top: theme.spacing(0.25),
const StyledBreadcrumbContainer = styled('div')(({ theme }) => ({
height: theme.spacing(2.5),
margin: theme.spacing(2, 0),
}));

const StyledParagraph = styled('p')({
Expand Down Expand Up @@ -50,55 +50,57 @@ const BreadcrumbNav = () => {
);

return (
<ConditionallyRender
condition={
(location.pathname.includes('admin') && isAdmin) ||
!location.pathname.includes('admin')
}
show={
<ConditionallyRender
condition={paths.length > 1}
show={
<StyledBreadCrumbs aria-label="Breadcrumbs">
{paths.map((path, index) => {
const lastItem = index === paths.length - 1;
if (lastItem) {
<StyledBreadcrumbContainer>
<ConditionallyRender
condition={
(location.pathname.includes('admin') && isAdmin) ||
!location.pathname.includes('admin')
}
show={
<ConditionallyRender
condition={paths.length > 1}
show={
<Breadcrumbs aria-label="Breadcrumbs">
{paths.map((path, index) => {
const lastItem = index === paths.length - 1;
if (lastItem) {
return (
<StyledParagraph key={path}>
<StringTruncator
text={path}
maxWidth="200"
maxLength={25}
/>
</StyledParagraph>
);
}

let link = '/';

paths.forEach((path, i) => {
if (i !== index && i < index) {
link += path + '/';
} else if (i === index) {
link += path;
}
});

return (
<StyledParagraph key={path}>
<StyledLink key={path} to={link}>
<StringTruncator
maxLength={25}
text={path}
maxWidth="200"
maxLength={25}
/>
</StyledParagraph>
</StyledLink>
);
}

let link = '/';

paths.forEach((path, i) => {
if (i !== index && i < index) {
link += path + '/';
} else if (i === index) {
link += path;
}
});

return (
<StyledLink key={path} to={link}>
<StringTruncator
maxLength={25}
text={path}
maxWidth="200"
/>
</StyledLink>
);
})}
</StyledBreadCrumbs>
}
/>
}
/>
})}
</Breadcrumbs>
}
/>
}
/>
</StyledBreadcrumbContainer>
);
};

Expand Down
7 changes: 3 additions & 4 deletions frontend/src/component/layout/MainLayout/MainLayout.tsx
Expand Up @@ -34,8 +34,7 @@ const MainLayoutContentWrapper = styled('main')(({ theme }) => ({

const MainLayoutContent = styled(Grid)(({ theme }) => ({
width: '1250px',
marginLeft: 'auto',
marginRight: 'auto',
margin: '0 auto',
[theme.breakpoints.down('lg')]: {
width: '1024px',
},
Expand All @@ -62,10 +61,10 @@ const StyledImg = styled('img')(() => ({

const MainLayoutContentContainer = styled('div')(({ theme }) => ({
height: '100%',
padding: theme.spacing(6.5, 0),
padding: theme.spacing(0, 0, 6.5, 0),
position: 'relative',
[theme.breakpoints.down('md')]: {
padding: theme.spacing(6.5, 1.5),
padding: theme.spacing(0, 1.5, 6.5, 1.5),
},
zIndex: 200,
}));
Expand Down

0 comments on commit 172f911

Please sign in to comment.