feat: reoganizing color scheme

This commit is contained in:
Caio Cabral committed 2024-11-10 17:00:13 -05:00
1 parent 097b719159
commit 067400437f
19 files changed
+551 -416

No files matched your search

+1
View File
@@ -31,6 +31,7 @@ const icons = {
const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => { const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
const theme = useTheme(); const theme = useTheme();
/* TODO check if this still works. text bg and border not necessarilly exist. Text becomes contrastText. border becomes contrastText. bg becomes dark */
const { text, bg, border } = theme.palette[variant]; const { text, bg, border } = theme.palette[variant];
const icon = icons[variant]; const icon = icons[variant];
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
import "./index.css"; import "./index.css";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
/* TODO add prop validation and jsdocs */
const BarChart = ({ checks = [] }) => { const BarChart = ({ checks = [] }) => {
const theme = useTheme(); const theme = useTheme();
const [animate, setAnimate] = useState(false); const [animate, setAnimate] = useState(false);
@@ -65,7 +66,9 @@ const BarChart = ({ checks = [] }) => {
width={theme.spacing(4)} width={theme.spacing(4)}
height={theme.spacing(4)} height={theme.spacing(4)}
backgroundColor={ backgroundColor={
check.status ? theme.palette.success.main : theme.palette.error.text check.status
? theme.palette.success.main
: theme.palette.error.contrastText
} }
sx={{ borderRadius: "50%" }} sx={{ borderRadius: "50%" }}
/> />
@@ -138,7 +141,7 @@ const BarChart = ({ checks = [] }) => {
width="9px" width="9px"
height="100%" height="100%"
backgroundColor={ backgroundColor={
check.status ? theme.palette.success.bg : theme.palette.error.bg check.status ? theme.palette.success.dark : theme.palette.error.dark
} }
sx={{ sx={{
borderRadius: theme.spacing(1.5), borderRadius: theme.spacing(1.5),
@@ -153,7 +156,9 @@ const BarChart = ({ checks = [] }) => {
width="100%" width="100%"
height={`${animate ? check.responseTime : 0}%`} height={`${animate ? check.responseTime : 0}%`}
backgroundColor={ backgroundColor={
check.status ? theme.palette.success.main : theme.palette.error.text check.status
? theme.palette.success.main
: theme.palette.error.contrastText
} }
sx={{ sx={{
borderRadius: theme.spacing(1.5), borderRadius: theme.spacing(1.5),
+1 -1
View File
@@ -24,7 +24,7 @@ const Check = ({ text, noHighlightText, variant = "info", outlined = false }) =>
const theme = useTheme(); const theme = useTheme();
const colors = { const colors = {
success: theme.palette.success.main, success: theme.palette.success.main,
error: theme.palette.error.text, error: theme.palette.error.contrastText,
info: theme.palette.info.border, info: theme.palette.info.border,
}; };
+3 -3
View File
@@ -67,7 +67,7 @@ const Field = forwardRef(
borderColor: theme.palette.border.dark, borderColor: theme.palette.border.dark,
}, },
"&:has(.input-error) .MuiOutlinedInput-root fieldset": { "&:has(.input-error) .MuiOutlinedInput-root fieldset": {
borderColor: theme.palette.error.text, borderColor: theme.palette.error.contrastText,
}, },
display: hidden ? "none" : "", display: hidden ? "none" : "",
}} }}
@@ -83,7 +83,7 @@ const Field = forwardRef(
<Typography <Typography
component="span" component="span"
ml={theme.spacing(1)} ml={theme.spacing(1)}
color={theme.palette.error.text} color={theme.palette.error.contrastText}
> >
* *
</Typography> </Typography>
@@ -189,7 +189,7 @@ const Field = forwardRef(
<Typography <Typography
component="span" component="span"
className="input-error" className="input-error"
color={theme.palette.error.text} color={theme.palette.error.contrastText}
mt={theme.spacing(2)} mt={theme.spacing(2)}
sx={{ sx={{
opacity: 0.8, opacity: 0.8,
@@ -99,7 +99,7 @@ const Search = ({
<Typography <Typography
component="span" component="span"
className="input-error" className="input-error"
color={theme.palette.error.text} color={theme.palette.error.contrastText}
mt={theme.spacing(2)} mt={theme.spacing(2)}
sx={{ sx={{
opacity: 0.8, opacity: 0.8,
+5 -5
View File
@@ -127,22 +127,22 @@ const StatusLabel = ({ status, text, customStyles }) => {
const colors = { const colors = {
up: { up: {
dotColor: theme.palette.success.main, dotColor: theme.palette.success.main,
bgColor: theme.palette.success.bg, bgColor: theme.palette.success.dark,
borderColor: theme.palette.success.light, borderColor: theme.palette.success.light,
}, },
down: { down: {
dotColor: theme.palette.error.text, dotColor: theme.palette.error.contrastText,
bgColor: theme.palette.error.bg, bgColor: theme.palette.error.dark,
borderColor: theme.palette.error.light, borderColor: theme.palette.error.light,
}, },
paused: { paused: {
dotColor: theme.palette.warning.main, dotColor: theme.palette.warning.main,
bgColor: theme.palette.warning.bg, bgColor: theme.palette.warning.dark,
borderColor: theme.palette.warning.light, borderColor: theme.palette.warning.light,
}, },
pending: { pending: {
dotColor: theme.palette.warning.main, dotColor: theme.palette.warning.main,
bgColor: theme.palette.warning.bg, bgColor: theme.palette.warning.dark,
borderColor: theme.palette.warning.light, borderColor: theme.palette.warning.light,
}, },
"cannot resolve": { "cannot resolve": {
+3 -3
View File
@@ -34,11 +34,11 @@ const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) =>
backgroundColor: theme.palette.background.fill, backgroundColor: theme.palette.background.fill,
"&:has(.input-error)": { "&:has(.input-error)": {
borderColor: theme.palette.error.main, borderColor: theme.palette.error.main,
backgroundColor: theme.palette.error.bg, backgroundColor: theme.palette.error.dark,
py: theme.spacing(4), py: theme.spacing(4),
px: theme.spacing(8), px: theme.spacing(8),
"& > .MuiStack-root > svg": { "& > .MuiStack-root > svg": {
fill: theme.palette.error.text, fill: theme.palette.error.contrastText,
width: "20px", width: "20px",
height: "20px", height: "20px",
}, },
@@ -85,7 +85,7 @@ const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) =>
<Typography <Typography
component="p" component="p"
className="input-error" className="input-error"
color={theme.palette.error.text} color={theme.palette.error.contrastText}
> >
{error} {error}
</Typography> </Typography>
@@ -114,7 +114,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
"& ul": { p: theme.spacing(2.5) }, "& ul": { p: theme.spacing(2.5) },
"& li": { m: 0 }, "& li": { m: 0 },
"& li:last-of-type": { "& li:last-of-type": {
color: theme.palette.error.text, color: theme.palette.error.contrastText,
}, },
}, },
}, },
@@ -1,10 +1,10 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material"; import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
import LoadingButton from '@mui/lab/LoadingButton'; import LoadingButton from "@mui/lab/LoadingButton";
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { monitorValidation } from "../../../Validation/validation"; import { monitorValidation } from "../../../Validation/validation";
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice" import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
@@ -19,12 +19,12 @@ import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMon
import "./index.css"; import "./index.css";
const CreateMonitor = () => { const CreateMonitor = () => {
const MS_PER_MINUTE = 60000; const MS_PER_MINUTE = 60000;
const { user, authToken } = useSelector((state) => state.auth); const { user, authToken } = useSelector((state) => state.auth);
const { monitors, isLoading } = useSelector((state) => state.uptimeMonitors); const { monitors, isLoading } = useSelector((state) => state.uptimeMonitors);
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const theme = useTheme(); const theme = useTheme();
const idMap = { const idMap = {
"monitor-url": "url", "monitor-url": "url",
@@ -148,16 +148,18 @@ const CreateMonitor = () => {
setErrors(newErrors); setErrors(newErrors);
createToast({ body: "Error validation data." }); createToast({ body: "Error validation data." });
} else { } else {
if (monitor.type === "http") { if (monitor.type === "http") {
const checkEndpointAction = await dispatch( const checkEndpointAction = await dispatch(
checkEndpointResolution({ authToken, monitorURL: form.url }) checkEndpointResolution({ authToken, monitorURL: form.url })
) );
if (checkEndpointAction.meta.requestStatus === "rejected") { if (checkEndpointAction.meta.requestStatus === "rejected") {
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." }); createToast({
setErrors({ url: "The entered URL is not reachable." }); body: "The endpoint you entered doesn't resolve. Check the URL again.",
return; });
} setErrors({ url: "The entered URL is not reachable." });
} return;
}
}
form = { form = {
...form, ...form,
@@ -304,7 +306,7 @@ const CreateMonitor = () => {
<Typography <Typography
component="p" component="p"
className="input-error" className="input-error"
color={theme.palette.error.text} color={theme.palette.error.contrastText}
> >
{errors["type"]} {errors["type"]}
</Typography> </Typography>
@@ -386,19 +388,19 @@ const CreateMonitor = () => {
direction="row" direction="row"
justifyContent="flex-end" justifyContent="flex-end"
> >
<LoadingButton <LoadingButton
variant="contained" variant="contained"
color="primary" color="primary"
onClick={handleCreateMonitor} onClick={handleCreateMonitor}
disabled={Object.keys(errors).length !== 0 && true} disabled={Object.keys(errors).length !== 0 && true}
loading={isLoading} loading={isLoading}
> >
Create monitor Create monitor
</LoadingButton> </LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</Box> </Box>
); );
}; };
export default CreateMonitor; export default CreateMonitor;
@@ -61,7 +61,7 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
? { main: theme.palette.success.main, light: theme.palette.success.light } ? { main: theme.palette.success.main, light: theme.palette.success.light }
: uptime > 50 : uptime > 50
? { main: theme.palette.warning.main, light: theme.palette.warning.light } ? { main: theme.palette.warning.main, light: theme.palette.warning.light }
: { main: theme.palette.error.text, light: theme.palette.error.light }; : { main: theme.palette.error.contrastText, light: theme.palette.error.light };
}; };
// TODO - REMOVE THIS LATER // TODO - REMOVE THIS LATER
@@ -201,10 +201,10 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
key={`cell-${entry.time}`} key={`cell-${entry.time}`}
fill={ fill={
hoveredBarIndex === index hoveredBarIndex === index
? theme.palette.error.text ? theme.palette.error.contrastText
: chartHovered : chartHovered
? theme.palette.error.light ? theme.palette.error.light
: theme.palette.error.text : theme.palette.error.contrastText
} }
onMouseEnter={() => { onMouseEnter={() => {
setHoveredBarIndex(index); setHoveredBarIndex(index);
@@ -246,24 +246,24 @@ const ResponseGaugeChart = ({ data }) => {
? { ? {
category: "Excellent", category: "Excellent",
main: theme.palette.success.main, main: theme.palette.success.main,
bg: theme.palette.success.bg, bg: theme.palette.success.dark,
} }
: responseTime <= 500 : responseTime <= 500
? { ? {
category: "Fair", category: "Fair",
main: theme.palette.success.main, main: theme.palette.success.main,
bg: theme.palette.success.bg, bg: theme.palette.success.dark,
} }
: responseTime <= 600 : responseTime <= 600
? { ? {
category: "Acceptable", category: "Acceptable",
main: theme.palette.warning.main, main: theme.palette.warning.main,
bg: theme.palette.warning.bg, bg: theme.palette.warning.dark,
} }
: { : {
category: "Poor", category: "Poor",
main: theme.palette.error.text, main: theme.palette.error.contrastText,
bg: theme.palette.error.bg, bg: theme.palette.error.dark,
}; };
return ( return (
+1 -1
View File
@@ -25,7 +25,7 @@ const StatusBox = ({ title, value }) => {
</Box> </Box>
); );
} else if (title === "down") { } else if (title === "down") {
color = theme.palette.error.text; color = theme.palette.error.contrastText;
icon = ( icon = (
<Box sx={{ ...sharedStyles, transform: "rotate(180deg)", top: 5 }}> <Box sx={{ ...sharedStyles, transform: "rotate(180deg)", top: 5 }}>
<Arrow /> <Arrow />
@@ -109,7 +109,7 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
"& ul": { p: theme.spacing(2.5) }, "& ul": { p: theme.spacing(2.5) },
"& li": { m: 0 }, "& li": { m: 0 },
"& li:last-of-type": { "& li:last-of-type": {
color: theme.palette.error.text, color: theme.palette.error.contrastText,
}, },
}, },
}, },
+10 -10
View File
@@ -28,20 +28,20 @@ const useUtils = () => {
}; };
const statusStyles = { const statusStyles = {
up: { up: {
backgroundColor: theme.palette.success.bg, backgroundColor: theme.palette.success.dark,
background: `linear-gradient(340deg, ${theme.palette.success.light} -60%, ${theme.palette.success.bg} 35%)`, background: `linear-gradient(340deg, ${theme.palette.success.light} -60%, ${theme.palette.success.dark} 35%)`,
borderColor: theme.palette.success.light, borderColor: theme.palette.success.light,
"& h2": { color: theme.palette.success.main }, "& h2": { color: theme.palette.success.main },
}, },
down: { down: {
backgroundColor: theme.palette.error.bg, backgroundColor: theme.palette.error.dark,
background: `linear-gradient(340deg, ${theme.palette.error.light} -60%, ${theme.palette.error.bg} 35%)`, background: `linear-gradient(340deg, ${theme.palette.error.light} -60%, ${theme.palette.error.dark} 35%)`,
borderColor: theme.palette.error.light, borderColor: theme.palette.error.light,
"& h2": { color: theme.palette.error.main }, "& h2": { color: theme.palette.error.main },
}, },
paused: { paused: {
backgroundColor: theme.palette.warning.bg, backgroundColor: theme.palette.warning.dark,
background: `linear-gradient(340deg, ${theme.palette.warning.light} -60%, ${theme.palette.warning.bg} 35%)`, background: `linear-gradient(340deg, ${theme.palette.warning.light} -60%, ${theme.palette.warning.dark} 35%)`,
borderColor: theme.palette.warning.light, borderColor: theme.palette.warning.light,
"& h2": { color: theme.palette.warning.main }, "& h2": { color: theme.palette.warning.main },
}, },
@@ -54,22 +54,22 @@ const useUtils = () => {
}; };
const pagespeedStyles = { const pagespeedStyles = {
up: { up: {
bg: theme.palette.success.bg, bg: theme.palette.success.dark,
light: theme.palette.success.light, light: theme.palette.success.light,
stroke: theme.palette.success.main, stroke: theme.palette.success.main,
}, },
down: { down: {
bg: theme.palette.error.bg, bg: theme.palette.error.dark,
light: theme.palette.error.light, light: theme.palette.error.light,
stroke: theme.palette.error.main, stroke: theme.palette.error.main,
}, },
paused: { paused: {
bg: theme.palette.warning.bg, bg: theme.palette.warning.dark,
light: theme.palette.warning.light, light: theme.palette.warning.light,
stroke: theme.palette.warning.main, stroke: theme.palette.warning.main,
}, },
pending: { pending: {
bg: theme.palette.warning.bg, bg: theme.palette.warning.dark,
light: theme.palette.warning.light, light: theme.palette.warning.light,
stroke: theme.palette.warning.main, stroke: theme.palette.warning.main,
}, },
@@ -1,11 +1,14 @@
import { useState } from "react"; import { useState } from "react";
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material"; import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
import LoadingButton from '@mui/lab/LoadingButton'; import LoadingButton from "@mui/lab/LoadingButton";
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { monitorValidation } from "../../../Validation/validation"; import { monitorValidation } from "../../../Validation/validation";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { createPageSpeed, checkEndpointResolution } from "../../../Features/PageSpeedMonitor/pageSpeedMonitorSlice"; import {
createPageSpeed,
checkEndpointResolution,
} from "../../../Features/PageSpeedMonitor/pageSpeedMonitorSlice";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger"; import { logger } from "../../../Utils/Logger";
import { ConfigBox } from "../../Monitors/styled"; import { ConfigBox } from "../../Monitors/styled";
@@ -17,12 +20,12 @@ import Breadcrumbs from "../../../Components/Breadcrumbs";
import "./index.css"; import "./index.css";
const CreatePageSpeed = () => { const CreatePageSpeed = () => {
const MS_PER_MINUTE = 60000; const MS_PER_MINUTE = 60000;
const { user, authToken } = useSelector((state) => state.auth); const { user, authToken } = useSelector((state) => state.auth);
const { isLoading } = useSelector((state) => state.pageSpeedMonitors); const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const theme = useTheme(); const theme = useTheme();
const idMap = { const idMap = {
"monitor-url": "url", "monitor-url": "url",
@@ -105,252 +108,260 @@ const CreatePageSpeed = () => {
abortEarly: false, abortEarly: false,
}); });
if (error) { if (error) {
const newErrors = {}; const newErrors = {};
error.details.forEach((err) => { error.details.forEach((err) => {
newErrors[err.path[0]] = err.message; newErrors[err.path[0]] = err.message;
}); });
setErrors(newErrors); setErrors(newErrors);
createToast({ body: "Error validation data." }); createToast({ body: "Error validation data." });
} else { } else {
const checkEndpointAction = await dispatch( const checkEndpointAction = await dispatch(
checkEndpointResolution({ authToken, monitorURL: form.url }) checkEndpointResolution({ authToken, monitorURL: form.url })
) );
if (checkEndpointAction.meta.requestStatus === "rejected") { if (checkEndpointAction.meta.requestStatus === "rejected") {
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." }); createToast({
setErrors({ url: "The entered URL is not reachable." }); body: "The endpoint you entered doesn't resolve. Check the URL again.",
return; });
} setErrors({ url: "The entered URL is not reachable." });
return;
}
form = { form = {
...form, ...form,
description: form.name, description: form.name,
teamId: user.teamId, teamId: user.teamId,
userId: user._id, userId: user._id,
notifications: monitor.notifications, notifications: monitor.notifications,
}; };
const action = await dispatch( const action = await dispatch(createPageSpeed({ authToken, monitor: form }));
createPageSpeed({ authToken, monitor: form }) if (action.meta.requestStatus === "fulfilled") {
); createToast({ body: "Monitor created successfully!" });
if (action.meta.requestStatus === "fulfilled") { navigate("/pagespeed");
createToast({ body: "Monitor created successfully!" }); } else {
navigate("/pagespeed"); createToast({ body: "Failed to create monitor." });
} else { }
createToast({ body: "Failed to create monitor." }); }
} };
}
};
//select values //select values
const frequencies = [ const frequencies = [
{ _id: 3, name: "3 minutes" }, { _id: 3, name: "3 minutes" },
{ _id: 5, name: "5 minutes" }, { _id: 5, name: "5 minutes" },
{ _id: 10, name: "10 minutes" }, { _id: 10, name: "10 minutes" },
{ _id: 20, name: "20 minutes" }, { _id: 20, name: "20 minutes" },
{ _id: 60, name: "1 hour" }, { _id: 60, name: "1 hour" },
{ _id: 1440, name: "1 day" }, { _id: 1440, name: "1 day" },
{ _id: 10080, name: "1 week" }, { _id: 10080, name: "1 week" },
]; ];
return ( return (
<Box <Box
className="create-monitor" className="create-monitor"
sx={{ sx={{
"& h1": { "& h1": {
color: theme.palette.text.primary, color: theme.palette.text.primary,
}, },
}} }}
> >
<Breadcrumbs <Breadcrumbs
list={[ list={[
{ name: "pagespeed", path: "/pagespeed" }, { name: "pagespeed", path: "/pagespeed" },
{ name: "create", path: `/pagespeed/create` }, { name: "create", path: `/pagespeed/create` },
]} ]}
/> />
<Stack <Stack
component="form" component="form"
className="create-monitor-form" className="create-monitor-form"
onSubmit={handleCreateMonitor} onSubmit={handleCreateMonitor}
noValidate noValidate
spellCheck="false" spellCheck="false"
gap={theme.spacing(12)} gap={theme.spacing(12)}
mt={theme.spacing(6)} mt={theme.spacing(6)}
> >
<Typography component="h1" variant="h1"> <Typography
<Typography component="span" fontSize="inherit"> component="h1"
Create your{" "} variant="h1"
</Typography> >
<Typography <Typography
component="span" component="span"
fontSize="inherit" fontSize="inherit"
fontWeight="inherit" >
color={theme.palette.text.secondary} Create your{" "}
> </Typography>
pagespeed monitor <Typography
</Typography> component="span"
</Typography> fontSize="inherit"
<ConfigBox> fontWeight="inherit"
<Box> color={theme.palette.text.secondary}
<Typography component="h2">General settings</Typography> >
<Typography component="p"> pagespeed monitor
Here you can select the URL of the host, together with the type of </Typography>
monitor. </Typography>
</Typography> <ConfigBox>
</Box> <Box>
<Stack gap={theme.spacing(15)}> <Typography component="h2">General settings</Typography>
<Field <Typography component="p">
type={"url"} Here you can select the URL of the host, together with the type of monitor.
id="monitor-url" </Typography>
label="URL to monitor" </Box>
https={https} <Stack gap={theme.spacing(15)}>
placeholder="google.com" <Field
value={monitor.url} type={"url"}
onChange={handleChange} id="monitor-url"
error={errors["url"]} label="URL to monitor"
/> https={https}
<Field placeholder="google.com"
type="text" value={monitor.url}
id="monitor-name" onChange={handleChange}
label="Display name" error={errors["url"]}
isOptional={true} />
placeholder="Google" <Field
value={monitor.name} type="text"
onChange={handleChange} id="monitor-name"
error={errors["name"]} label="Display name"
/> isOptional={true}
</Stack> placeholder="Google"
</ConfigBox> value={monitor.name}
<ConfigBox> onChange={handleChange}
<Box> error={errors["name"]}
<Typography component="h2">Checks to perform</Typography> />
<Typography component="p"> </Stack>
You can always add or remove checks after adding your site. </ConfigBox>
</Typography> <ConfigBox>
</Box> <Box>
<Stack gap={theme.spacing(12)}> <Typography component="h2">Checks to perform</Typography>
<Stack gap={theme.spacing(6)}> <Typography component="p">
<Radio You can always add or remove checks after adding your site.
id="monitor-checks-http" </Typography>
title="Website monitoring" </Box>
desc="Use HTTP(s) to monitor your website or API endpoint." <Stack gap={theme.spacing(12)}>
size="small" <Stack gap={theme.spacing(6)}>
value="http" <Radio
checked={monitor.type === "pagespeed"} id="monitor-checks-http"
onChange={(event) => handleChange(event)} title="Website monitoring"
/> desc="Use HTTP(s) to monitor your website or API endpoint."
<ButtonGroup sx={{ ml: "32px" }}> size="small"
<Button value="http"
variant="group" checked={monitor.type === "pagespeed"}
filled={https.toString()} onChange={(event) => handleChange(event)}
onClick={() => setHttps(true)} />
> <ButtonGroup sx={{ ml: "32px" }}>
HTTPS <Button
</Button> variant="group"
<Button filled={https.toString()}
variant="group" onClick={() => setHttps(true)}
filled={(!https).toString()} >
onClick={() => setHttps(false)} HTTPS
> </Button>
HTTP <Button
</Button> variant="group"
</ButtonGroup> filled={(!https).toString()}
</Stack> onClick={() => setHttps(false)}
{errors["type"] ? ( >
<Box className="error-container"> HTTP
<Typography </Button>
component="p" </ButtonGroup>
className="input-error" </Stack>
color={theme.palette.error.text} {errors["type"] ? (
> <Box className="error-container">
{errors["type"]} <Typography
</Typography> component="p"
</Box> className="input-error"
) : ( color={theme.palette.error.contrastText}
"" >
)} {errors["type"]}
</Stack> </Typography>
</ConfigBox> </Box>
<ConfigBox> ) : (
<Box> ""
<Typography component="h2">Incident notifications</Typography> )}
<Typography component="p"> </Stack>
When there is an incident, notify users. </ConfigBox>
</Typography> <ConfigBox>
</Box> <Box>
<Stack gap={theme.spacing(6)}> <Typography component="h2">Incident notifications</Typography>
<Typography component="p">When there is a new incident,</Typography> <Typography component="p">
<Checkbox When there is an incident, notify users.
id="notify-sms" </Typography>
label="Notify via SMS (coming soon)" </Box>
isChecked={false} <Stack gap={theme.spacing(6)}>
value="" <Typography component="p">When there is a new incident,</Typography>
onChange={() => logger.warn("disabled")} <Checkbox
isDisabled={true} id="notify-sms"
/> label="Notify via SMS (coming soon)"
<Checkbox isChecked={false}
id="notify-email-default" value=""
label={`Notify via email (to ${user.email})`} onChange={() => logger.warn("disabled")}
isChecked={monitor.notifications.some( isDisabled={true}
(notification) => notification.type === "email" />
)} <Checkbox
value={user?.email} id="notify-email-default"
onChange={(event) => handleChange(event)} label={`Notify via email (to ${user.email})`}
/> isChecked={monitor.notifications.some(
<Checkbox (notification) => notification.type === "email"
id="notify-email" )}
label="Also notify via email to multiple addresses (coming soon)" value={user?.email}
isChecked={false} onChange={(event) => handleChange(event)}
value="" />
onChange={() => logger.warn("disabled")} <Checkbox
isDisabled={true} id="notify-email"
/> label="Also notify via email to multiple addresses (coming soon)"
{monitor.notifications.some( isChecked={false}
(notification) => notification.type === "emails" value=""
) ? ( onChange={() => logger.warn("disabled")}
<Box mx={theme.spacing(16)}> isDisabled={true}
<Field />
id="notify-email-list" {monitor.notifications.some(
type="text" (notification) => notification.type === "emails"
placeholder="name@gmail.com" ) ? (
value="" <Box mx={theme.spacing(16)}>
onChange={() => logger.warn("disabled")} <Field
/> id="notify-email-list"
<Typography mt={theme.spacing(4)}> type="text"
You can separate multiple emails with a comma placeholder="name@gmail.com"
</Typography> value=""
</Box> onChange={() => logger.warn("disabled")}
) : ( />
"" <Typography mt={theme.spacing(4)}>
)} You can separate multiple emails with a comma
</Stack> </Typography>
</ConfigBox> </Box>
<ConfigBox> ) : (
<Box> ""
<Typography component="h2">Advanced settings</Typography> )}
</Box> </Stack>
<Stack gap={theme.spacing(12)}> </ConfigBox>
<Select <ConfigBox>
id="monitor-interval" <Box>
label="Check frequency" <Typography component="h2">Advanced settings</Typography>
value={monitor.interval || 3} </Box>
onChange={(event) => handleChange(event, "interval")} <Stack gap={theme.spacing(12)}>
items={frequencies} <Select
/> id="monitor-interval"
</Stack> label="Check frequency"
</ConfigBox> value={monitor.interval || 3}
<Stack direction="row" justifyContent="flex-end"> onChange={(event) => handleChange(event, "interval")}
<LoadingButton items={frequencies}
variant="contained" />
color="primary" </Stack>
onClick={handleCreateMonitor} </ConfigBox>
disabled={Object.keys(errors).length !== 0 && true} <Stack
loading={isLoading} direction="row"
> justifyContent="flex-end"
Create monitor >
</LoadingButton> <LoadingButton
</Stack> variant="contained"
</Stack> color="primary"
</Box> onClick={handleCreateMonitor}
); disabled={Object.keys(errors).length !== 0 && true}
loading={isLoading}
>
Create monitor
</LoadingButton>
</Stack>
</Stack>
</Box>
);
}; };
export default CreatePageSpeed; export default CreatePageSpeed;
@@ -127,22 +127,22 @@ const PieChart = ({ audits }) => {
return { return {
stroke: theme.palette.success.main, stroke: theme.palette.success.main,
strokeBg: theme.palette.success.light, strokeBg: theme.palette.success.light,
text: theme.palette.success.text, text: theme.palette.success.contrastText,
bg: theme.palette.success.bg, bg: theme.palette.success.dark,
}; };
else if (value >= 50 && value < 90) else if (value >= 50 && value < 90)
return { return {
stroke: theme.palette.warning.main, stroke: theme.palette.warning.main,
strokeBg: theme.palette.warning.light, strokeBg: theme.palette.warning.light,
text: theme.palette.warning.text, text: theme.palette.warning.contrastText,
bg: theme.palette.warning.bg, bg: theme.palette.warning.dark,
}; };
else if (value >= 0 && value < 50) else if (value >= 0 && value < 50)
return { return {
stroke: theme.palette.error.text, stroke: theme.palette.error.contrastText,
strokeBg: theme.palette.error.light, strokeBg: theme.palette.error.light,
text: theme.palette.error.text, text: theme.palette.error.contrastText,
bg: theme.palette.error.bg, bg: theme.palette.error.dark,
}; };
return { return {
stroke: theme.palette.unresolved.main, stroke: theme.palette.unresolved.main,
+1 -1
View File
@@ -362,7 +362,7 @@ const PageSpeedDetails = ({ isAdmin }) => {
: score >= 50 : score >= 50
? theme.palette.warning.main ? theme.palette.warning.main
: score >= 0 : score >= 0
? theme.palette.error.text ? theme.palette.error.contrastText
: theme.palette.unresolved.main; : theme.palette.unresolved.main;
// Find the position where the number ends and the unit begins // Find the position where the number ends and the unit begins
+112 -19
View File
@@ -27,34 +27,127 @@ const paletteColors = {
gray70: "#FDFDFD", gray70: "#FDFDFD",
gray80: "#FDFCFD", gray80: "#FDFCFD",
gray90: "#FCFCFD", gray90: "#FCFCFD",
gray100: "#F4F4F4",
gray200: "#E3E3E3",
gray800: "#2D2D33",
gray830: "#262115",
gray850: "#131315", gray850: "#131315",
gray860: "#111113", gray860: "#111113",
gray870: "#0F0F11", gray870: "#0F0F11",
gray880: "#0C0C0E", gray880: "#0C0C0E",
gray890: "#09090B", gray890: "#09090B",
black: "#000000", black: "#000000",
blueBlueWave: "#1570EF",
blue700: "#475467",
green20: "#ECFDF3",
green50: "#D4F4E1",
green150: "#45BB7A",
green200: "#17B26A",
green400: "#079455",
green800: "#1C4428",
green900: "#12261E",
red50: "#F9ECED",
red100: "#FBD1D1",
red200: "#F04438",
red300: "#D32F2F",
red700: "#542426",
red800: "#301A1F",
orange50: "#FEF8EA",
orange100: "#FFECBC",
orange200: "#FEC84B",
orange300: "#FDB022",
orange400: "#FF9F00",
orange500: "#E88C30",
orange600: "#DC6803",
orange800: "#624711",
}; };
/* TODO Export this as colors */
/* primary: {
main: {
light:,
dark:
},
light:{
light:,
dark:
},
dark:{
light:,
dark:
},
contrastText: {
light:,
dark:
},
} */
const semanticColors = { const semanticColors = {
primary: {
main: {
light: paletteColors.blueBlueWave,
dark: paletteColors.blueBlueWave,
},
// TODO we dont have primary light, dark or contrast text
},
secondary: {
main: {
light: paletteColors.gray100,
dark: paletteColors.gray800,
},
// TODO we dont have secondary light
dark: {
light: paletteColors.gray200,
//TODO we dont have secondary dark for dark mode
},
constrastText: {
light: paletteColors.blue700,
//TODO we dont have secondary contrastText for dark mode
},
},
success: {
main: {
light: paletteColors.green200,
dark: paletteColors.green150,
},
contrastText: {
//TODO values are equal (confirm)
//TODO contrasttext semantically should be something that contrasts with the main
light: paletteColors.green400,
dark: paletteColors.green400,
},
light: {
light: paletteColors.green50,
//TODO dark mode light success is darker than the main success
dark: paletteColors.green800,
},
dark: {
light: paletteColors.green20,
dark: paletteColors.green900,
},
},
error: {
main: {
light: paletteColors.red300,
dark: paletteColors.red300,
},
contrastText: {
//TODO contrasttext semantically should be something that contrasts with the main
light: paletteColors.red200,
dark: paletteColors.red200,
},
light: {
light: paletteColors.red100,
dark: paletteColors.red700,
},
dark: {
light: paletteColors.red50,
dark: paletteColors.red800,
},
},
warning: {
main: {
light: paletteColors.orange300,
dark: paletteColors.orange400,
},
text: {
light: paletteColors.orange600,
dark: paletteColors.orange500,
},
light: {
light: paletteColors.orange100,
dark: paletteColors.orange800,
},
bg: {
light: paletteColors.orange50,
dark: paletteColors.gray830,
},
border: {
light: paletteColors.orange200,
dark: paletteColors.orange500,
},
},
gradient: { gradient: {
color1: { color1: {
light: paletteColors.gray90, light: paletteColors.gray90,
+45 -36
View File
@@ -17,51 +17,43 @@ const background = {
}; };
const border = { light: "#27272a", dark: "#36363e" }; const border = { light: "#27272a", dark: "#36363e" };
const { gradient } = colors; const {
/* const gradient = { primary,
color1: "#09090b", secondary,
color2: "#0c0c0e", success,
color3: "#0f0f11", error,
color4: "#111113", warning,
color5: "#131315", gradient: {
}; */ color1: { dark: color1 },
color2: { dark: color2 },
color3: { dark: color3 },
color4: { dark: color4 },
color5: { dark: color5 },
},
} = colors;
const darkTheme = createTheme({ const darkTheme = createTheme({
...baseTheme, ...baseTheme,
palette: { palette: {
primary: { main: "#1570ef" }, primary: { main: primary.main.dark },
secondary: { main: "#2D2D33" }, secondary: { main: secondary.main.dark },
text: text,
background: background,
border: border,
info: {
text: text.primary,
main: text.secondary,
bg: background.main,
light: background.main,
border: border.light,
},
gradient,
success: { success: {
text: "#079455", main: success.main.dark,
main: "#45bb7a", contrastText: success.contrastText.dark,
light: "#1c4428", light: success.light.dark,
bg: "#12261e", dark: success.dark.dark,
}, },
error: { error: {
text: "#f04438", main: error.main.dark,
main: "#d32f2f", contrastText: error.contrastText.dark,
light: "#542426", light: error.light.dark,
bg: "#301a1f", dark: error.dark.dark,
dark: "#932020",
border: "#f04438",
}, },
warning: { warning: {
text: "#e88c30", main: warning.main.dark,
main: "#FF9F00", light: warning.light.dark,
light: "#624711", contrastText: warning.contrastText.dark,
bg: "#262115", dark: warning.dark.dark,
border: "#e88c30",
}, },
percentage: { percentage: {
uptimePoor: "#d32f2f", uptimePoor: "#d32f2f",
@@ -78,6 +70,23 @@ const darkTheme = createTheme({
grid: "#454546", grid: "#454546",
autofill: "#2d2d33", autofill: "#2d2d33",
}, },
gradient: {
color1,
color2,
color3,
color4,
color5,
},
text: text,
background: background,
border: border,
info: {
text: text.primary,
main: text.secondary,
bg: background.main,
light: background.main,
border: border.light,
},
}, },
}); });
+49 -35
View File
@@ -15,52 +15,49 @@ const background = {
accent: "#f9fafb", accent: "#f9fafb",
}; };
const { gradient } = colors;
/* const gradient = {
color1: "#fcfcfd",
color2: "#fdfcfd",
color3: "#fdfdfd",
color4: "#fefdfe",
color5: "#fefefe",
}; */
const border = { light: "#eaecf0", dark: "#d0d5dd" }; const border = { light: "#eaecf0", dark: "#d0d5dd" };
const {
primary,
secondary,
success,
error,
warning,
gradient: {
color1: { light: color1 },
color2: { light: color2 },
color3: { light: color3 },
color4: { light: color4 },
color5: { light: color5 },
},
} = colors;
const lightTheme = createTheme({ const lightTheme = createTheme({
...baseTheme, ...baseTheme,
palette: { palette: {
primary: { main: "#1570EF" }, primary: { main: primary.main.light },
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" }, secondary: {
text: text, main: secondary.main.light,
background: background, dark: secondary.dark.light,
border: border, contrastText: secondary.constrastText.light,
info: {
text: text.primary,
main: text.tertiary,
bg: background.main,
light: background.main,
border: border.dark,
}, },
gradient,
success: { success: {
text: "#079455", main: success.main.light,
main: "#17b26a", contrastText: success.contrastText.light,
light: "#d4f4e1", light: success.light.light,
bg: "#ecfdf3", dark: success.dark.light,
}, },
error: { error: {
text: "#f04438", main: error.main.light,
main: "#d32f2f", contrastText: error.contrastText.light,
light: "#fbd1d1", light: error.light.light,
bg: "#f9eced", dark: error.dark.light,
border: "#f04438",
}, },
warning: { warning: {
text: "#DC6803", main: warning.main.light,
main: "#fdb022", light: warning.light.light,
light: "#ffecbc", contrastText: warning.contrastText.light,
bg: "#fef8ea", dark: warning.dark.light,
border: "#fec84b",
}, },
percentage: { percentage: {
uptimePoor: "#d32f2f", uptimePoor: "#d32f2f",
@@ -77,6 +74,23 @@ const lightTheme = createTheme({
grid: "#a2a3a3", grid: "#a2a3a3",
autofill: "#e8f0fe", autofill: "#e8f0fe",
}, },
gradient: {
color1,
color2,
color3,
color4,
color5,
},
text: text,
background: background,
border: border,
info: {
text: text.primary,
main: text.tertiary,
bg: background.main,
light: background.main,
border: border.dark,
},
}, },
}); });