Refactored sx styling to theme file style overrides

This commit is contained in:
Daniel Cojocea committed 2024-08-29 20:42:12 -04:00
1 parent bddca58a37
commit 4352b3690d
12 files changed
+90 -101

No files matched your search

+1
View File
@@ -57,6 +57,7 @@ const Avatar = ({ src, small, sx }) => {
} }
sx={{ sx={{
fontSize: small ? "16px" : "22px", fontSize: small ? "16px" : "22px",
color: "white",
fontWeight: 400, fontWeight: 400,
backgroundColor: stringToColor(`${user?.firstName} ${user?.lastName}`), backgroundColor: stringToColor(`${user?.firstName} ${user?.lastName}`),
display: "inline-flex", display: "inline-flex",
@@ -120,17 +120,6 @@
opacity: 0.4; opacity: 0.4;
} }
.pagination-dropdown ul {
padding: 4px;
min-width: 100px;
}
.pagination-dropdown li {
font-size: var(--env-var-font-size-medium);
}
body:has(.pagination-dropdown) p:has(+ .MuiTablePagination-root) {
font-size: var(--env-var-font-size-small-plus);
}
.monitors .MuiTable-root .MuiTableHead-root .MuiTableCell-root { .monitors .MuiTable-root .MuiTableHead-root .MuiTableCell-root {
text-transform: uppercase; text-transform: uppercase;
opacity: 0.8; opacity: 0.8;
+2 -10
View File
@@ -272,7 +272,7 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
}, },
}} }}
> >
<Typography px={theme.spacing(2)} sx={{ opacity: 0.7 }}> <Typography px={theme.spacing(2)} fontSize={12} sx={{ opacity: 0.7 }}>
Showing {getRange()} of {data.rows.length} monitor(s) Showing {getRange()} of {data.rows.length} monitor(s)
</Typography> </Typography>
<TablePagination <TablePagination
@@ -300,19 +300,11 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
sx: { sx: {
mt: 0, mt: 0,
mb: theme.spacing(2), mb: theme.spacing(2),
"& li": {
p: theme.spacing(2),
color: theme.palette.text.tertiary,
},
"& li.Mui-selected, & li.Mui-selected.Mui-focusVisible, & li.Mui-selected:hover":
{
backgroundColor: theme.palette.background.fill,
},
}, },
}, },
transformOrigin: { vertical: "bottom", horizontal: "left" }, transformOrigin: { vertical: "bottom", horizontal: "left" },
anchorOrigin: { vertical: "top", horizontal: "left" }, anchorOrigin: { vertical: "top", horizontal: "left" },
sx: { mt: "-4px" }, sx: { mt: theme.spacing(-2) },
}, },
inputProps: { id: "pagination-dropdown" }, inputProps: { id: "pagination-dropdown" },
IconComponent: SelectorVertical, IconComponent: SelectorVertical,
+1 -1
View File
@@ -33,7 +33,7 @@ const Breadcrumbs = ({ list }) => {
lineHeight="18px" lineHeight="18px"
sx={{ sx={{
"& .MuiBreadcrumbs-li:not(:last-of-type):hover a": { "& .MuiBreadcrumbs-li:not(:last-of-type):hover a": {
backgroundColor: "#e3e3e3", backgroundColor: theme.palette.other.fill,
opacity: 1, opacity: 1,
}, },
}} }}
+10 -4
View File
@@ -2,7 +2,7 @@ import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material"; import { Box, Stack, Typography } from "@mui/material";
import Skeleton from "../../assets/Images/create-placeholder.svg?react"; import Skeleton from "../../assets/Images/create-placeholder.svg?react";
import background from "../../assets/Images/background_pattern_decorative.png"; import Background from "../../assets/Images/background-grid.svg?react";
import Button from "../Button"; import Button from "../Button";
import Check from "../Check/Check"; import Check from "../Check/Check";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
@@ -32,12 +32,18 @@ const Fallback = ({ title, checks, link = "/", isAdmin }) => {
<Skeleton style={{ zIndex: 1 }} /> <Skeleton style={{ zIndex: 1 }} />
<Box <Box
className="background-pattern-svg" className="background-pattern-svg"
sx={{ backgroundImage: `url(${background})` }} sx={{
/> "& svg g g:last-of-type path": {
stroke: theme.palette.border.light,
},
}}
>
<Background style={{ width: "100%" }} />
</Box>
<Stack gap={theme.spacing(4)} maxWidth={"275px"} zIndex={1}> <Stack gap={theme.spacing(4)} maxWidth={"275px"} zIndex={1}>
<Typography <Typography
component="h1" component="h1"
marginY={theme.spacing(6)} marginY={theme.spacing(4)}
color={theme.palette.text.secondary} color={theme.palette.text.secondary}
> >
A {title} is used to: A {title} is used to:
@@ -5,8 +5,3 @@
align-items: center; align-items: center;
line-height: 1; line-height: 1;
} }
.select-wrapper .MuiInputBase-root:has(> .MuiSelect-select),
.MuiMenu-List .MuiMenuItem-root,
.select-wrapper h3.MuiTypography-root {
font-size: var(--env-var-font-size-medium);
}
+1 -18
View File
@@ -77,26 +77,9 @@ const Select = ({
onChange={onChange} onChange={onChange}
displayEmpty displayEmpty
inputProps={{ id: id }} inputProps={{ id: id }}
MenuProps={{
MenuListProps: {
sx: {
p: 0,
"& li": {
color: theme.palette.text.secondary,
fontSize: 13,
px: theme.spacing(4),
py: theme.spacing(2.5),
borderRadius: theme.shape.borderRadius,
},
"& li.Mui-selected, & li.Mui-selected.Mui-focusVisible, & li.Mui-selected:hover":
{
backgroundColor: theme.palette.background.fill,
},
},
},
}}
IconComponent={KeyboardArrowDownIcon} IconComponent={KeyboardArrowDownIcon}
sx={{ sx={{
fontSize: 13,
minWidth: "125px", minWidth: "125px",
"& fieldset": { "& fieldset": {
borderRadius: theme.shape.borderRadius, borderRadius: theme.shape.borderRadius,
+14 -48
View File
@@ -305,31 +305,12 @@ function Sidebar() {
slotProps={{ slotProps={{
paper: { paper: {
sx: { sx: {
border: 1, mt: theme.spacing(-2),
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shape.boxShadow,
backgroundColor: theme.palette.background.main,
ml: theme.spacing(1), ml: theme.spacing(1),
}, },
}, },
}} }}
MenuListProps={{ MenuListProps={{ sx: { px: 1, py: 2 } }}
sx: {
p: 3,
minWidth: "100px",
"& li": {
color: theme.palette.text.secondary,
fontSize: 13,
px: theme.spacing(4),
py: theme.spacing(2.5),
borderRadius: theme.shape.borderRadius,
},
"& li:hover": {
backgroundColor: theme.palette.background.accent,
},
},
}}
sx={{ sx={{
ml: theme.spacing(8), ml: theme.spacing(8),
"& .selected-path": { "& .selected-path": {
@@ -360,9 +341,13 @@ function Sidebar() {
}} }}
sx={{ sx={{
gap: theme.spacing(4), gap: theme.spacing(4),
borderRadius: theme.shape.borderRadius, opacity: 0.9,
pl: theme.spacing(4), "& svg": {
mb: "1px", "& path": {
stroke: theme.palette.other.icon,
strokeWidth: 1.1,
},
},
}} }}
> >
{child.icon} {child.icon}
@@ -460,9 +445,7 @@ function Sidebar() {
) )
)} )}
</List> </List>
<Divider <Divider sx={{ my: theme.spacing(4) }} />
sx={{ my: theme.spacing(4), borderColor: theme.palette.border.light }}
/>
{/* other */} {/* other */}
<List <List
component="nav" component="nav"
@@ -526,7 +509,7 @@ function Sidebar() {
</Tooltip> </Tooltip>
))} ))}
</List> </List>
<Divider sx={{ mt: "auto", borderColor: theme.palette.border.light }} /> <Divider sx={{ mt: "auto" }} />
<Stack <Stack
direction="row" direction="row"
@@ -607,11 +590,6 @@ function Sidebar() {
slotProps={{ slotProps={{
paper: { paper: {
sx: { sx: {
border: 1,
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shape.boxShadow,
backgroundColor: theme.palette.background.main,
marginTop: theme.spacing(-4), marginTop: theme.spacing(-4),
marginLeft: collapsed ? theme.spacing(2) : 0, marginLeft: collapsed ? theme.spacing(2) : 0,
}, },
@@ -619,18 +597,7 @@ function Sidebar() {
}} }}
MenuListProps={{ MenuListProps={{
sx: { sx: {
p: 3, p: 2,
minWidth: "100px",
"& li": {
color: theme.palette.text.secondary,
fontSize: 13,
px: theme.spacing(4),
py: theme.spacing(2.5),
borderRadius: theme.shape.borderRadius,
},
"& li:hover": {
backgroundColor: theme.palette.background.accent,
},
"& li:has(.MuiBox-root):hover": { "& li:has(.MuiBox-root):hover": {
backgroundColor: theme.palette.background.main, backgroundColor: theme.palette.background.main,
}, },
@@ -652,11 +619,10 @@ function Sidebar() {
</Box> </Box>
</MenuItem> </MenuItem>
)} )}
{collapsed && ( {collapsed && <Divider />}
<Divider sx={{ borderColor: theme.palette.border.light }} />
)}
<MenuItem onClick={() => dispatch(setMode("light"))}>Light</MenuItem> <MenuItem onClick={() => dispatch(setMode("light"))}>Light</MenuItem>
<MenuItem onClick={() => dispatch(setMode("dark"))}>Dark</MenuItem> <MenuItem onClick={() => dispatch(setMode("dark"))}>Dark</MenuItem>
<Divider />
<MenuItem <MenuItem
onClick={logout} onClick={logout}
sx={{ sx={{
+1 -1
View File
@@ -30,7 +30,7 @@
position: absolute; position: absolute;
top: 0; top: 0;
left: 50%; left: 50%;
transform: translate(-50%, -47%); transform: translate(-50%, -50%);
z-index: 0; z-index: 0;
width: 100%; width: 100%;
-3
View File
@@ -6,9 +6,6 @@
font-size: var(--env-var-font-size-large); font-size: var(--env-var-font-size-large);
font-weight: 500; font-weight: 500;
} }
.monitors p.MuiTypography-root {
font-size: var(--env-var-font-size-medium);
}
.monitors h1.MuiTypography-root + p.MuiTypography-root { .monitors h1.MuiTypography-root + p.MuiTypography-root {
font-size: var(--env-var-font-size-medium-plus); font-size: var(--env-var-font-size-medium-plus);
} }
+30
View File
@@ -5,6 +5,7 @@ const text = {
secondary: "#e6e6e6", secondary: "#e6e6e6",
tertiary: "#a1a1aa", tertiary: "#a1a1aa",
accent: "#e6e6e6", accent: "#e6e6e6",
disabled: "rgba(172, 172, 172, 0.3)",
}; };
const background = { const background = {
main: "#151518", main: "#151518",
@@ -54,10 +55,13 @@ const darkTheme = createTheme({
border: "#fec84b", border: "#fec84b",
}, },
unresolved: { main: "#4e5ba6", light: "#e2eaf7", bg: "#f2f4f7" }, unresolved: { main: "#4e5ba6", light: "#e2eaf7", bg: "#f2f4f7" },
divider: border.light,
other: { other: {
icon: "#e6e6e6", icon: "#e6e6e6",
line: "#27272a", line: "#27272a",
fill: "#18181a",
}, },
// TO BE REMOVED //
primary: { primary: {
main: "#1570ef", main: "#1570ef",
}, },
@@ -67,6 +71,7 @@ const darkTheme = createTheme({
tertiary: { tertiary: {
main: "#e6e6e6", main: "#e6e6e6",
}, },
// ----------------- //
}, },
spacing: 2, spacing: 2,
components: { components: {
@@ -79,6 +84,7 @@ const darkTheme = createTheme({
styleOverrides: { styleOverrides: {
root: { root: {
marginTop: 4, marginTop: 4,
padding: 0,
border: 1, border: 1,
borderStyle: "solid", borderStyle: "solid",
borderColor: border.light, borderColor: border.light,
@@ -88,6 +94,30 @@ const darkTheme = createTheme({
}, },
}, },
}, },
MuiList: {
styleOverrides: {
root: {
padding: 0,
},
},
},
MuiMenuItem: {
styleOverrides: {
root: {
borderRadius: 4,
backgroundColor: "inherit",
padding: "4px 6px",
color: text.secondary,
fontSize: 13,
margin: 2,
minWidth: 100,
"&:hover, &.Mui-selected, &.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
{
backgroundColor: background.fill,
},
},
},
},
MuiTableCell: { MuiTableCell: {
styleOverrides: { styleOverrides: {
root: { root: {
+30
View File
@@ -22,6 +22,7 @@ const shadow =
const lightTheme = createTheme({ const lightTheme = createTheme({
typography: { fontFamily: fontFamilyDefault, fontSize: 13 }, typography: { fontFamily: fontFamilyDefault, fontSize: 13 },
palette: { palette: {
mode: "dark",
common: { main: "#1570ef" }, common: { main: "#1570ef" },
text: text, text: text,
background: background, background: background,
@@ -54,10 +55,13 @@ const lightTheme = createTheme({
border: "#fec84b", border: "#fec84b",
}, },
unresolved: { main: "#4e5ba6", light: "#e2eaf7", bg: "#f2f4f7" }, unresolved: { main: "#4e5ba6", light: "#e2eaf7", bg: "#f2f4f7" },
divider: border.light,
other: { other: {
icon: "#667085", icon: "#667085",
line: "#d6d9dd", line: "#d6d9dd",
fill: "#e3e3e3",
}, },
// TO BE REMOVED //
primary: { primary: {
main: "#1570EF", main: "#1570EF",
}, },
@@ -67,6 +71,7 @@ const lightTheme = createTheme({
tertiary: { tertiary: {
main: "#475467", main: "#475467",
}, },
// ----------------- //
}, },
spacing: 2, spacing: 2,
components: { components: {
@@ -88,6 +93,31 @@ const lightTheme = createTheme({
}, },
}, },
}, },
MuiList: {
styleOverrides: {
root: {
padding: 0,
},
},
},
MuiMenuItem: {
styleOverrides: {
root: {
borderRadius: 4,
backgroundColor: "inherit",
padding: "4px 6px",
color: text.secondary,
fontSize: 13,
margin: 2,
marginBottom: 0,
minWidth: 100,
"&:hover, &.Mui-selected, &.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
{
backgroundColor: background.fill,
},
},
},
},
MuiTableCell: { MuiTableCell: {
styleOverrides: { styleOverrides: {
root: { root: {