feat: using common baseTheme to avoid repetition
This commit is contained in:
1 parent
9459416fc5
commit
d62f5952d5
10 files changed
+135
-33
No files matched your search
@@ -79,7 +79,6 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/"
|
path="/"
|
||||||
/* TODO redirect to /monitors */
|
|
||||||
element={<Navigate to="/monitors" />}
|
element={<Navigate to="/monitors" />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A heading component that renders text with a specific heading level.
|
||||||
|
*
|
||||||
|
* @param {Object} props - The properties passed to the Heading component.
|
||||||
|
* @param {('h1'|'h2'|'h3')} props.component - The heading level for the component.
|
||||||
|
* @param {string} props.children - The content to display inside the heading.
|
||||||
|
* @returns {JSX.Element} The Typography component with specified heading properties.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Heading({ component, children }) {
|
||||||
|
return (
|
||||||
|
<Typography
|
||||||
|
component={component}
|
||||||
|
variant="h2"
|
||||||
|
fontWeight={600}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Heading.propTypes = {
|
||||||
|
component: PropTypes.oneOf(["h1", "h2", "h3"]).isRequired,
|
||||||
|
children: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
export { Heading };
|
||||||
@@ -150,6 +150,8 @@ function Sidebar() {
|
|||||||
}
|
}
|
||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
|
/* TODO refactor this, there are a some ternaries and comments in the return */
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
component="aside"
|
component="aside"
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
|
import { Box, Button } from "@mui/material";
|
||||||
|
import { Heading } from "../../Components/Heading";
|
||||||
|
|
||||||
function Infrastructure() {
|
function Infrastructure() {
|
||||||
return <h1>Infrastructure monitors</h1>;
|
return (
|
||||||
|
<Box component="main">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => {
|
||||||
|
// navigate("/monitors/create");
|
||||||
|
}}
|
||||||
|
sx={{ fontWeight: 500 }}
|
||||||
|
>
|
||||||
|
Create monitor
|
||||||
|
</Button>
|
||||||
|
<Heading component="h2">Infrastructure monitors</Heading>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Infrastructure };
|
export { Infrastructure };
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack } from "@mui/material";
|
||||||
import Search from "../../../../Components/Inputs/Search";
|
import Search from "../../../../Components/Inputs/Search";
|
||||||
import MemoizedMonitorTable from "../MonitorTable";
|
import MemoizedMonitorTable from "../MonitorTable";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import useDebounce from "../../../../Utils/debounce";
|
import useDebounce from "../../../../Utils/debounce";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import { Heading } from "../../../../Components/Heading";
|
||||||
|
|
||||||
const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -25,14 +26,8 @@ const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
mb={theme.spacing(8)}
|
mb={theme.spacing(8)}
|
||||||
>
|
>
|
||||||
<Typography
|
<Heading component="h2">Actively monitoring</Heading>
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
fontWeight={500}
|
|
||||||
letterSpacing={-0.2}
|
|
||||||
>
|
|
||||||
Actively monitoring
|
|
||||||
</Typography>
|
|
||||||
<Box
|
<Box
|
||||||
className="current-monitors-counter"
|
className="current-monitors-counter"
|
||||||
color={theme.palette.text.primary}
|
color={theme.palette.text.primary}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* TODO take these from here and declare using emotion. Plus, the values should live in the theme */
|
||||||
.monitors .MuiStack-root > button:not(.MuiIconButton-root) {
|
.monitors .MuiStack-root > button:not(.MuiIconButton-root) {
|
||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
height: var(--env-var-height-2);
|
height: var(--env-var-height-2);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
const typographyLevels = {
|
||||||
|
xs: ".625rem",
|
||||||
|
s: ".75rem",
|
||||||
|
m: ".875rem",
|
||||||
|
l: "1rem",
|
||||||
|
xl: "1.5rem",
|
||||||
|
};
|
||||||
|
|
||||||
|
const paletteLight = {
|
||||||
|
text: {
|
||||||
|
primary: "#1c2130",
|
||||||
|
secondary: "#344054",
|
||||||
|
tertiary: "#475467",
|
||||||
|
accent: "#838c99",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { typographyLevels, paletteLight };
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
|
import { baseTheme } from "./globalTheme";
|
||||||
|
|
||||||
const text = {
|
const text = {
|
||||||
primary: "#fafafa",
|
primary: "#fafafa",
|
||||||
@@ -15,20 +16,21 @@ const background = {
|
|||||||
};
|
};
|
||||||
const border = { light: "#27272a", dark: "#36363e" };
|
const border = { light: "#27272a", dark: "#36363e" };
|
||||||
|
|
||||||
const fontFamilyDefault =
|
/* const fontFamilyDefault =
|
||||||
'"Inter","system-ui", "Avenir", "Helvetica", "Arial", sans-serif';
|
'"Inter","system-ui", "Avenir", "Helvetica", "Arial", sans-serif'; */
|
||||||
const shadow =
|
const shadow =
|
||||||
"0px 4px 24px -4px rgba(255, 255, 255, 0.03), 0px 3px 3px -3px rgba(255, 255, 255, 0.01)";
|
"0px 4px 24px -4px rgba(255, 255, 255, 0.03), 0px 3px 3px -3px rgba(255, 255, 255, 0.01)";
|
||||||
|
|
||||||
const darkTheme = createTheme({
|
const darkTheme = createTheme({
|
||||||
typography: {
|
...baseTheme,
|
||||||
fontFamily: fontFamilyDefault,
|
// typography: {
|
||||||
fontSize: 13,
|
// /* fontFamily: fontFamilyDefault, */
|
||||||
h1: { fontSize: 22, color: text.primary, fontWeight: 500 },
|
// fontSize: 13,
|
||||||
h2: { fontSize: 14.5, color: text.secondary, fontWeight: 400 },
|
// h1: { fontSize: 22, color: text.primary, fontWeight: 500 },
|
||||||
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
// h2: { fontSize: 16, color: text.secondary, fontWeight: 400 },
|
||||||
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
// body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
||||||
},
|
// body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
||||||
|
// },
|
||||||
chart: {
|
chart: {
|
||||||
header: {
|
header: {
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { paletteLight, typographyLevels } from "./constants";
|
||||||
|
|
||||||
|
const fontFamilyPrimary = '"Inter" , sans-serif';
|
||||||
|
// const fontFamilySecondary = '"Avenir", sans-serif';
|
||||||
|
|
||||||
|
const baseTheme = {
|
||||||
|
typography: {
|
||||||
|
fontFamily: fontFamilyPrimary,
|
||||||
|
fontSize: typographyLevels.m,
|
||||||
|
h1: {
|
||||||
|
fontSize: typographyLevels.xl,
|
||||||
|
color: paletteLight.text.primary,
|
||||||
|
fontWeight: 500,
|
||||||
|
},
|
||||||
|
h2: {
|
||||||
|
fontSize: typographyLevels.l,
|
||||||
|
color: paletteLight.text.secondary,
|
||||||
|
fontWeight: 400,
|
||||||
|
},
|
||||||
|
body1: {
|
||||||
|
fontSize: typographyLevels.m,
|
||||||
|
color: paletteLight.text.tertiary,
|
||||||
|
fontWeight: 400,
|
||||||
|
},
|
||||||
|
body2: {
|
||||||
|
fontSize: typographyLevels.s,
|
||||||
|
color: paletteLight.text.tertiary,
|
||||||
|
fontWeight: 400,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { baseTheme };
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
|
import { typographyLevels } from "./constants";
|
||||||
|
import { baseTheme } from "./globalTheme";
|
||||||
|
|
||||||
const text = {
|
const text = {
|
||||||
primary: "#1c2130",
|
primary: "#1c2130",
|
||||||
@@ -15,30 +17,34 @@ const background = {
|
|||||||
|
|
||||||
const border = { light: "#eaecf0", dark: "#d0d5dd" };
|
const border = { light: "#eaecf0", dark: "#d0d5dd" };
|
||||||
|
|
||||||
const fontFamilyDefault =
|
/* TODO stop using mui for fonts. Create text component based on emotion */
|
||||||
'"Inter","system-ui", "Avenir", "Helvetica", "Arial", sans-serif';
|
|
||||||
|
/* const fontFamilyDefault =
|
||||||
|
'"Inter","system-ui", "Avenir", "Helvetica", "Arial", sans-serif'; */
|
||||||
|
|
||||||
const shadow =
|
const shadow =
|
||||||
"0px 4px 24px -4px rgba(16, 24, 40, 0.08), 0px 3px 3px -3px rgba(16, 24, 40, 0.03)";
|
"0px 4px 24px -4px rgba(16, 24, 40, 0.08), 0px 3px 3px -3px rgba(16, 24, 40, 0.03)";
|
||||||
|
|
||||||
const lightTheme = createTheme({
|
const lightTheme = createTheme({
|
||||||
typography: {
|
...baseTheme,
|
||||||
fontFamily: fontFamilyDefault,
|
// typography: {
|
||||||
fontSize: 13,
|
// /* fontFamily: fontFamilyDefault, */
|
||||||
h1: { fontSize: 22, color: text.primary, fontWeight: 500 },
|
// fontSize: typographyLevels.m,
|
||||||
h2: { fontSize: 14.5, color: text.secondary, fontWeight: 400 },
|
// h1: { fontSize: typographyLevels.xl, color: text.primary, fontWeight: 500 },
|
||||||
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
// h2: { fontSize: typographyLevels.l, color: text.secondary, fontWeight: 400 },
|
||||||
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
// body1: { fontSize: typographyLevels.m, color: text.tertiary, fontWeight: 400 },
|
||||||
},
|
// body2: { fontSize: typographyLevels.s, color: text.tertiary, fontWeight: 400 },
|
||||||
|
// },
|
||||||
chart: {
|
chart: {
|
||||||
header: {
|
header: {
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
fill: text.tertiary,
|
fill: text.tertiary,
|
||||||
fontSize: 11,
|
fontSize: typographyLevels.m,
|
||||||
},
|
},
|
||||||
subheader: {
|
subheader: {
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
fill: text.tertiary,
|
fill: text.tertiary,
|
||||||
fontSize: 9,
|
fontSize: typographyLevels.xs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
palette: {
|
palette: {
|
||||||
|
|||||||
Reference in new issue
Block a user