mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
MakeStyles refactor 1-4 (#2845)
Signed-off-by: andreas-unleash <andreas@getunleash.ai> Make styles refactoring <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
e050495199
commit
fc548164a9
@ -1,21 +0,0 @@
|
||||
import { makeStyles } from 'tss-react/mui';
|
||||
|
||||
export const useStyles = makeStyles()(theme => ({
|
||||
breadcrumbNav: {
|
||||
position: 'absolute',
|
||||
top: '4px',
|
||||
},
|
||||
breadcrumbNavParagraph: {
|
||||
color: 'inherit',
|
||||
'& > *': {
|
||||
verticalAlign: 'middle',
|
||||
},
|
||||
},
|
||||
breadcrumbLink: {
|
||||
textDecoration: 'none',
|
||||
'& > *': {
|
||||
verticalAlign: 'middle',
|
||||
},
|
||||
color: theme.palette.primary.main,
|
||||
},
|
||||
}));
|
@ -1,14 +1,33 @@
|
||||
import Breadcrumbs from '@mui/material/Breadcrumbs';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||
import { useStyles } from './BreadcrumbNav.styles';
|
||||
import AccessContext from 'contexts/AccessContext';
|
||||
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 StyledParagraph = styled('p')({
|
||||
color: 'inherit',
|
||||
'& > *': {
|
||||
verticalAlign: 'middle',
|
||||
},
|
||||
});
|
||||
|
||||
const StyledLink = styled(Link)(({ theme }) => ({
|
||||
textDecoration: 'none',
|
||||
'& > *': {
|
||||
verticalAlign: 'middle',
|
||||
},
|
||||
color: theme.palette.primary.main,
|
||||
}));
|
||||
|
||||
const BreadcrumbNav = () => {
|
||||
const { isAdmin } = useContext(AccessContext);
|
||||
const { classes: styles } = useStyles();
|
||||
const location = useLocation();
|
||||
|
||||
const paths = location.pathname
|
||||
@ -40,26 +59,18 @@ const BreadcrumbNav = () => {
|
||||
<ConditionallyRender
|
||||
condition={paths.length > 1}
|
||||
show={
|
||||
<Breadcrumbs
|
||||
className={styles.breadcrumbNav}
|
||||
aria-label="Breadcrumbs"
|
||||
>
|
||||
<StyledBreadCrumbs aria-label="Breadcrumbs">
|
||||
{paths.map((path, index) => {
|
||||
const lastItem = index === paths.length - 1;
|
||||
if (lastItem) {
|
||||
return (
|
||||
<p
|
||||
key={path}
|
||||
className={
|
||||
styles.breadcrumbNavParagraph
|
||||
}
|
||||
>
|
||||
<StyledParagraph key={path}>
|
||||
<StringTruncator
|
||||
text={path}
|
||||
maxWidth="200"
|
||||
maxLength={25}
|
||||
/>
|
||||
</p>
|
||||
</StyledParagraph>
|
||||
);
|
||||
}
|
||||
|
||||
@ -74,20 +85,16 @@ const BreadcrumbNav = () => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={path}
|
||||
className={styles.breadcrumbLink}
|
||||
to={link}
|
||||
>
|
||||
<StyledLink key={path} to={link}>
|
||||
<StringTruncator
|
||||
maxLength={25}
|
||||
text={path}
|
||||
maxWidth="200"
|
||||
/>
|
||||
</Link>
|
||||
</StyledLink>
|
||||
);
|
||||
})}
|
||||
</Breadcrumbs>
|
||||
</StyledBreadCrumbs>
|
||||
}
|
||||
/>
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
import { makeStyles } from 'tss-react/mui';
|
||||
|
||||
export const useStyles = makeStyles()(theme => ({
|
||||
badge: {
|
||||
backgroundColor: theme.palette.checkmarkBadge,
|
||||
width: '75px',
|
||||
height: '75px',
|
||||
borderRadius: '50px',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
[theme.breakpoints.down('sm')]: {
|
||||
width: '50px',
|
||||
height: '50px',
|
||||
},
|
||||
},
|
||||
check: {
|
||||
color: '#fff',
|
||||
width: '35px',
|
||||
height: '35px',
|
||||
},
|
||||
}));
|
@ -1,22 +1,45 @@
|
||||
import { Check, Close } from '@mui/icons-material';
|
||||
import { useStyles } from './CheckMarkBadge.styles';
|
||||
import classnames from 'classnames';
|
||||
import { styled } from '@mui/material';
|
||||
|
||||
interface ICheckMarkBadgeProps {
|
||||
className: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
const StyledBatch = styled('div')(({ theme }) => ({
|
||||
backgroundColor: theme.palette.checkmarkBadge,
|
||||
width: '75px',
|
||||
height: '75px',
|
||||
borderRadius: '50px',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
[theme.breakpoints.down('sm')]: {
|
||||
width: '50px',
|
||||
height: '50px',
|
||||
},
|
||||
}));
|
||||
|
||||
const StyledClose = styled(Close)(({ theme }) => ({
|
||||
color: theme.palette.tertiary.background,
|
||||
width: '35px',
|
||||
height: '35px',
|
||||
}));
|
||||
const StyledCheck = styled(Check)(({ theme }) => ({
|
||||
color: theme.palette.tertiary.background,
|
||||
width: '35px',
|
||||
height: '35px',
|
||||
}));
|
||||
|
||||
const CheckMarkBadge = ({ type, className }: ICheckMarkBadgeProps) => {
|
||||
const { classes: styles } = useStyles();
|
||||
return (
|
||||
<div className={classnames(styles.badge, className)}>
|
||||
<StyledBatch className={className}>
|
||||
{type === 'error' ? (
|
||||
<Close className={styles.check} titleAccess="Error" />
|
||||
<StyledClose titleAccess="Error" />
|
||||
) : (
|
||||
<Check className={styles.check} />
|
||||
<StyledCheck />
|
||||
)}
|
||||
</div>
|
||||
</StyledBatch>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
import { makeStyles } from 'tss-react/mui';
|
||||
|
||||
export const useStyles = makeStyles()(theme => ({
|
||||
container: {
|
||||
backgroundColor: theme.palette.codebox,
|
||||
padding: '1rem',
|
||||
borderRadius: theme.shape.borderRadiusMedium,
|
||||
position: 'relative',
|
||||
maxHeight: '500px',
|
||||
overflow: 'auto',
|
||||
},
|
||||
code: {
|
||||
margin: 0,
|
||||
wordBreak: 'break-all',
|
||||
whiteSpace: 'pre-wrap',
|
||||
color: theme.palette.formSidebarTextColor,
|
||||
fontSize: 14,
|
||||
},
|
||||
icon: {
|
||||
fill: '#fff',
|
||||
},
|
||||
iconButton: {
|
||||
position: 'absolute',
|
||||
bottom: '10px',
|
||||
right: '20px',
|
||||
},
|
||||
}));
|
@ -1,16 +1,31 @@
|
||||
import { useStyles } from './Codebox.styles';
|
||||
import { styled } from '@mui/material';
|
||||
|
||||
interface ICodeboxProps {
|
||||
text: string;
|
||||
}
|
||||
|
||||
const Codebox = ({ text }: ICodeboxProps) => {
|
||||
const { classes: styles } = useStyles();
|
||||
const StyledContainer = styled('div')(({ theme }) => ({
|
||||
backgroundColor: theme.palette.codebox,
|
||||
padding: theme.spacing(2),
|
||||
borderRadius: theme.shape.borderRadiusMedium,
|
||||
position: 'relative',
|
||||
maxHeight: '500px',
|
||||
overflow: 'auto',
|
||||
}));
|
||||
|
||||
const StyledCode = styled('pre')(({ theme }) => ({
|
||||
margin: 0,
|
||||
wordBreak: 'break-all',
|
||||
whiteSpace: 'pre-wrap',
|
||||
color: theme.palette.formSidebarTextColor,
|
||||
fontSize: theme.fontSizes.smallBody,
|
||||
}));
|
||||
|
||||
const Codebox = ({ text }: ICodeboxProps) => {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<pre className={styles.code}>{text}</pre>
|
||||
</div>
|
||||
<StyledContainer>
|
||||
<StyledCode>{text}</StyledCode>
|
||||
</StyledContainer>
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user