From fc548164a985cc2428034e72943f2295be98dcbd Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Wed, 11 Jan 2023 11:02:10 +0200 Subject: [PATCH] MakeStyles refactor 1-4 (#2845) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: andreas-unleash Make styles refactoring ## About the changes Closes # ### Important files ## Discussion points Signed-off-by: andreas-unleash --- .../BreadcrumbNav/BreadcrumbNav.styles.ts | 21 --------- .../common/BreadcrumbNav/BreadcrumbNav.tsx | 47 +++++++++++-------- .../CheckmarkBadge/CheckMarkBadge.styles.ts | 22 --------- .../common/CheckmarkBadge/CheckMarkBadge.tsx | 37 ++++++++++++--- .../common/Codebox/Codebox.styles.ts | 27 ----------- .../src/component/common/Codebox/Codebox.tsx | 27 ++++++++--- 6 files changed, 78 insertions(+), 103 deletions(-) delete mode 100644 frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.styles.ts delete mode 100644 frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.styles.ts delete mode 100644 frontend/src/component/common/Codebox/Codebox.styles.ts diff --git a/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.styles.ts b/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.styles.ts deleted file mode 100644 index 9706b056fd..0000000000 --- a/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.styles.ts +++ /dev/null @@ -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, - }, -})); diff --git a/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.tsx b/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.tsx index f1f659a196..2c5e3cacd3 100644 --- a/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.tsx +++ b/frontend/src/component/common/BreadcrumbNav/BreadcrumbNav.tsx @@ -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 = () => { 1} show={ - + {paths.map((path, index) => { const lastItem = index === paths.length - 1; if (lastItem) { return ( -

+ -

+ ); } @@ -74,20 +85,16 @@ const BreadcrumbNav = () => { }); return ( - + - + ); })} -
+ } /> } diff --git a/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.styles.ts b/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.styles.ts deleted file mode 100644 index 33e9bdf2be..0000000000 --- a/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.styles.ts +++ /dev/null @@ -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', - }, -})); diff --git a/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.tsx b/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.tsx index deb6c7dc1d..458fc9fa39 100644 --- a/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.tsx +++ b/frontend/src/component/common/CheckmarkBadge/CheckMarkBadge.tsx @@ -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 ( -
+ {type === 'error' ? ( - + ) : ( - + )} -
+ ); }; diff --git a/frontend/src/component/common/Codebox/Codebox.styles.ts b/frontend/src/component/common/Codebox/Codebox.styles.ts deleted file mode 100644 index f1bbb2e8a2..0000000000 --- a/frontend/src/component/common/Codebox/Codebox.styles.ts +++ /dev/null @@ -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', - }, -})); diff --git a/frontend/src/component/common/Codebox/Codebox.tsx b/frontend/src/component/common/Codebox/Codebox.tsx index 76257cfb0e..f566d50235 100644 --- a/frontend/src/component/common/Codebox/Codebox.tsx +++ b/frontend/src/component/common/Codebox/Codebox.tsx @@ -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 ( -
-
{text}
-
+ + {text} + ); };