1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: small breadcrumb adjustments (#2893)

https://linear.app/unleash/issue/2-577/small-breadcrumb-adjustments

Includes small adjustments to the breadcrumb navigation component.

### Long chain path (ellipts if width > 200px)

![image](https://user-images.githubusercontent.com/14320932/212155100-973c2b31-d990-4c0a-a67b-3d3110231569.png)

### Long final path (no longer ellipts as long as it has enough
remaining space)

![image](https://user-images.githubusercontent.com/14320932/212156184-041f671a-6bf5-4e43-9ef0-4c89015837cc.png)

### Long final path with resized window (still ellipts when needed)

![image](https://user-images.githubusercontent.com/14320932/212157091-6453c881-1c0f-4785-935e-4993ed479280.png)
This commit is contained in:
Nuno Góis 2023-01-16 12:09:38 +00:00 committed by GitHub
parent 4286103850
commit b3fcc97f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 22 deletions

View File

@ -3,27 +3,29 @@ import { Link, useLocation } from 'react-router-dom';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import AccessContext from 'contexts/AccessContext'; import AccessContext from 'contexts/AccessContext';
import { useContext } from 'react'; import { useContext } from 'react';
import StringTruncator from '../StringTruncator/StringTruncator';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import { textTruncated } from 'themes/themeStyles';
const StyledBreadcrumbContainer = styled('div')(({ theme }) => ({ const StyledBreadcrumbContainer = styled('div')(({ theme }) => ({
height: theme.spacing(2.5), height: theme.spacing(2.5),
margin: theme.spacing(2, 0), margin: theme.spacing(2, 0),
})); }));
const StyledParagraph = styled('p')({ const StyledBreadcrumbs = styled(Breadcrumbs)({
color: 'inherit', '& > ol': {
'& > *': { flexWrap: 'nowrap',
verticalAlign: 'middle', '& > li:last-child': {
minWidth: 0,
},
}, },
}); });
const StyledParagraph = styled('p')(textTruncated);
const StyledLink = styled(Link)(({ theme }) => ({ const StyledLink = styled(Link)(({ theme }) => ({
textDecoration: 'none',
'& > *': { '& > *': {
verticalAlign: 'middle', maxWidth: theme.spacing(25),
}, },
color: theme.palette.primary.main,
})); }));
const BreadcrumbNav = () => { const BreadcrumbNav = () => {
@ -60,17 +62,13 @@ const BreadcrumbNav = () => {
<ConditionallyRender <ConditionallyRender
condition={paths.length > 1} condition={paths.length > 1}
show={ show={
<Breadcrumbs aria-label="Breadcrumbs"> <StyledBreadcrumbs aria-label="Breadcrumbs">
{paths.map((path, index) => { {paths.map((path, index) => {
const lastItem = index === paths.length - 1; const lastItem = index === paths.length - 1;
if (lastItem) { if (lastItem) {
return ( return (
<StyledParagraph key={path}> <StyledParagraph key={path}>
<StringTruncator {path}
text={path}
maxWidth="200"
maxLength={25}
/>
</StyledParagraph> </StyledParagraph>
); );
} }
@ -87,15 +85,13 @@ const BreadcrumbNav = () => {
return ( return (
<StyledLink key={path} to={link}> <StyledLink key={path} to={link}>
<StringTruncator <StyledParagraph>
maxLength={25} {path}
text={path} </StyledParagraph>
maxWidth="200"
/>
</StyledLink> </StyledLink>
); );
})} })}
</Breadcrumbs> </StyledBreadcrumbs>
} }
/> />
} }

View File

@ -190,9 +190,9 @@ export default createTheme({
fontSize: '0.875rem', fontSize: '0.875rem',
'& a': { '& a': {
color: colors.purple[900], color: colors.purple[900],
textDecoration: 'underline', textDecoration: 'none',
'&:hover': { '&:hover': {
textDecoration: 'none', textDecoration: 'underline',
}, },
}, },
}, },

View File

@ -29,6 +29,12 @@ export const textCenter = {
textAlign: 'center', textAlign: 'center',
} as const; } as const;
export const textTruncated = {
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
} as const;
export const flexRow = { export const flexRow = {
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',