feat: fixing lots of colors

This commit is contained in:
Caio Cabral committed 2025-01-12 12:28:13 -05:00
1 parent 61aaa8489a
commit 541a5b3f12
33 files changed
+194 -331

No files matched your search

+2 -2
View File
@@ -94,8 +94,8 @@ const CheckEmail = () => {
fontWeight: 600,
fontSize: 22,
},
/* TODO set color */
"& p": { color: "red" /* theme.palette.text.accent */, fontSize: 13.5 },
/* TODO font size from theme */
"& p": { color: theme.palette.primary.contrastTextSecondary, fontSize: 13.5 },
"& span": { fontSize: "inherit" },
}}
>
+2 -2
View File
@@ -95,9 +95,9 @@ const ForgotPassword = () => {
fontSize: 21,
},
"& p": {
/* TODO font size from theme */
fontSize: 14,
/* TODO set color */
color: "red" /* theme.palette.text.accent */,
color: theme.palette.primary.contrastTextSecondary,
},
}}
>
+2 -1
View File
@@ -145,7 +145,8 @@ const Login = () => {
fontWeight: 600,
fontSize: 28,
},
"& p": { fontSize: 14, color: "red" /* theme.palette.text.accent */ },
/* TODO set font size from theme */
"& p": { fontSize: 14, color: theme.palette.primary.contrastTextSecondary },
"& span": { fontSize: "inherit" },
}}
>
@@ -31,8 +31,8 @@ const NewPasswordConfirmed = () => {
fontWeight: 600,
fontSize: 21,
},
/* TODO set color and font size*/
"& p": { fontSize: 13.5, color: "red" /* theme.palette.text.accent */ },
/* TODO font size from theme*/
"& p": { fontSize: 13.5, color: theme.palette.primary.contrastTextSecondary },
}}
>
<Box
+2 -2
View File
@@ -285,8 +285,8 @@ const Register = ({ isSuperAdmin }) => {
fontWeight: 600,
fontSize: 28,
},
/* TODO set color */
"& p": { fontSize: 14, color: "red" /* theme.palette.text.accent */ },
/* TODO set fontsize from theme */
"& p": { fontSize: 14, color: theme.palette.primary.contrastTextSecondary },
"& span": { fontSize: "inherit" },
}}
>
@@ -134,7 +134,7 @@ function StepThree({ onSubmit, onBack }) {
mr: theme.spacing(3),
},
":focus-visible": {
outline: `2px solid ${theme.palette.primary.dark}`,
outline: `2px solid ${theme.palette.primary.lowContrast}`,
outlineOffset: "4px",
},
}}
+2 -2
View File
@@ -74,9 +74,9 @@ const SetNewPassword = () => {
fontSize: 24,
},
"& p": {
/* TODO font size from theme */
fontSize: 14,
/* TODO set color */
color: "red" /* theme.palette.text.accent */,
color: theme.palette.primary.contrastTextSecondary,
},
}}
>
+1 -1
View File
@@ -202,7 +202,7 @@ function Infrastructure() {
{isAdmin && (
<Button
variant="contained"
color="primary"
color="accent"
onClick={navigateToCreate}
sx={{ fontWeight: 500, whiteSpace: "nowrap" }}
>
@@ -260,8 +260,9 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
/>
<defs>
{Object.values(filteredConfig).map(({ id, color }) => {
/* TODO not working? */
const startColor = theme.palette[color].main;
const endColor = theme.palette[color].light;
const endColor = theme.palette[color].lowContrast;
return (
<linearGradient
@@ -126,29 +126,29 @@ const PieChart = ({ audits }) => {
if (value >= 90 && value <= 100)
return {
stroke: theme.palette.success.main,
strokeBg: theme.palette.success.light,
strokeBg: theme.palette.success.lowContrast,
text: theme.palette.success.contrastText,
bg: theme.palette.success.light,
bg: theme.palette.success.lowContrast,
};
else if (value >= 50 && value < 90)
return {
stroke: theme.palette.warning.main,
strokeBg: theme.palette.warning.light,
strokeBg: theme.palette.warning.lowContrast,
text: theme.palette.warning.contrastText,
bg: theme.palette.warning.dark,
bg: theme.palette.warning.lowContrast,
};
else if (value >= 0 && value < 50)
return {
stroke: theme.palette.error.contrastText,
strokeBg: theme.palette.error.light,
strokeBg: theme.palette.error.lowContrast,
text: theme.palette.error.contrastText,
bg: theme.palette.error.dark,
bg: theme.palette.error.lowContrast,
};
return {
stroke: theme.palette.unresolved.main,
strokeBg: theme.palette.unresolved.light,
text: theme.palette.unresolved.main,
bg: theme.palette.primary.lowContrast,
stroke: theme.palette.tertiary.contrastText,
strokeBg: theme.palette.tertiary.contrastText,
text: theme.palette.tertiary.contrastText,
bg: theme.palette.tertiary.main,
};
};
+1 -1
View File
@@ -372,7 +372,7 @@ const PageSpeedDetails = () => {
? theme.palette.warning.main
: score >= 0
? theme.palette.error.contrastText
: theme.palette.unresolved.main;
: theme.palette.tertiary.main;
// Find the position where the number ends and the unit begins
const match = audit.displayValue.match(/(\d+\.?\d*)\s*([a-zA-Z]+)/);
+12 -7
View File
@@ -81,6 +81,7 @@ CustomToolTip.propTypes = {
payload: PropTypes.array,
};
/* TODO separate utils in folder*/
/**
* Processes the raw data to include a score for each entry.
* @param {Array<Object>} data - The raw data array.
@@ -104,6 +105,7 @@ const processData = (data) => {
return formattedData;
};
/* TODO separate component*/
/**
* Renders an area chart displaying page speed scores.
* @param {Object} props
@@ -114,7 +116,9 @@ const processData = (data) => {
const PagespeedAreaChart = ({ data, status }) => {
const theme = useTheme();
const [isHovered, setIsHovered] = useState(false);
const { pagespeedStyles } = useUtils();
const { statusToTheme } = useUtils();
const themeColor = statusToTheme[status];
const formattedData = processData(data);
@@ -154,24 +158,24 @@ const PagespeedAreaChart = ({ data, status }) => {
>
<stop
offset="0%"
stopColor={pagespeedStyles[status].stroke}
stopColor={theme.palette[themeColor].lowContrast}
stopOpacity={0.8}
/>
<stop
offset="100%"
stopColor={pagespeedStyles[status].light}
stopColor={theme.palette[themeColor].main}
stopOpacity={0}
/>
</linearGradient>
</defs>
<Area
dataKey="score"
stroke={pagespeedStyles[status].stroke}
stroke={theme.palette[themeColor].lowContrast}
strokeWidth={isHovered ? 2.5 : 1.5}
fill={`url(#pagespeed-chart-${status})`}
activeDot={{
stroke: pagespeedStyles[status].light,
fill: pagespeedStyles[status].stroke,
stroke: theme.palette[themeColor].main,
fill: theme.palette[themeColor].lowContrast,
r: 4.5,
}}
/>
@@ -192,6 +196,7 @@ PagespeedAreaChart.propTypes = {
status: PropTypes.string.isRequired,
};
/* TODO separate component */
/**
* Renders a card displaying monitor details and an area chart.
* @param {Object} props
@@ -289,7 +294,7 @@ const Card = ({ monitor }) => {
>
<Typography
fontSize={11}
color={"red" /* theme.palette.text.accent */}
color={theme.palette.primary.contrastTextSecondary}
>
Checking every{" "}
{(() => {
+1 -1
View File
@@ -91,7 +91,7 @@ const PageSpeed = () => {
{isAdmin && (
<Button
variant="contained"
color="primary"
color="accent"
onClick={() => navigate("/pagespeed/create")}
sx={{ fontWeight: 500, whiteSpace: "nowrap" }}
>
@@ -58,7 +58,7 @@ const DownBarChart = memo(({ stats, type, onBarHover }) => {
hoveredBarIndex === index
? theme.palette.error.main
: chartHovered
? theme.palette.error.light
? theme.palette.error.contrastText
: theme.palette.error.main
}
onMouseEnter={() => {
@@ -29,12 +29,12 @@ const ResponseGaugeChart = ({ avgResponseTime }) => {
? {
category: "Acceptable",
main: theme.palette.warning.main,
bg: theme.palette.warning.dark,
bg: theme.palette.warning.lowContrast,
}
: {
category: "Poor",
main: theme.palette.error.main,
bg: theme.palette.error.light,
bg: theme.palette.error.contrastText,
};
return (
@@ -4,18 +4,28 @@ import { ResponsiveContainer, BarChart, XAxis, Bar, Cell } from "recharts";
import PropTypes from "prop-types";
import CustomLabels from "./CustomLabels";
const getThemeColor = (responseTime) => {
if (responseTime < 200) {
return "success";
} else if (responseTime < 300) {
return "warning";
} else {
return "error";
}
};
const UpBarChart = memo(({ stats, type, onBarHover }) => {
const theme = useTheme();
const [chartHovered, setChartHovered] = useState(false);
const [hoveredBarIndex, setHoveredBarIndex] = useState(null);
const getColorRange = (responseTime) => {
/* const getColorRange = (responseTime) => {
return responseTime < 200
? { main: theme.palette.success.main, light: theme.palette.success.light }
: responseTime < 300
? { main: theme.palette.warning.main, light: theme.palette.warning.light }
: { main: theme.palette.error.main, light: theme.palette.error.light };
};
}; */
return (
<ResponsiveContainer
@@ -59,11 +69,19 @@ const UpBarChart = memo(({ stats, type, onBarHover }) => {
background={{ fill: "transparent" }}
>
{stats.upChecks.map((entry, index) => {
let { main, light } = getColorRange(entry.avgResponseTime);
/* let { main, light } = getColorRange(entry.avgResponseTime); */
const themeColor = getThemeColor(entry.avgResponseTime);
console.log(themeColor);
return (
<Cell
key={`cell-${entry.time}`}
fill={hoveredBarIndex === index ? main : chartHovered ? light : main}
fill={
hoveredBarIndex === index
? theme.palette[themeColor].main
: chartHovered
? theme.palette[themeColor].accent
: theme.palette[themeColor].main
}
onMouseEnter={() => {
setHoveredBarIndex(index);
onBarHover(entry);
+5 -2
View File
@@ -33,7 +33,7 @@ import ResponseGaugeChart from "./Charts/ResponseGaugeChart";
*/
const DetailsPage = () => {
const theme = useTheme();
const { statusColor, statusStyles, statusMsg, determineState } = useUtils();
const { statusColor, statusMsg, determineState } = useUtils();
const isAdmin = useIsAdmin();
const [monitor, setMonitor] = useState({});
const { monitorId } = useParams();
@@ -236,7 +236,10 @@ const DetailsPage = () => {
gap={theme.spacing(8)}
>
<StatBox
sx={statusStyles[determineState(monitor)]}
/* sx={getStatusStyles(determineState(monitor))} */
/* statusStyles[determineState(monitor)] */
gradient={true}
status={determineState(monitor)}
heading={"active for"}
subHeading={splitDuration(monitor?.stats?.timeSinceLastFalseCheck)}
/>
@@ -26,7 +26,12 @@ const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin, handlePause }) =>
alignItems="center"
mb={theme.spacing(8)}
>
<Heading component="h2">Uptime monitors</Heading>
<Heading
component="h2"
style={{ color: theme.palette.primary.contrastTextSecondary }}
>
Uptime monitors
</Heading>
<Box
className="current-monitors-counter"
-39
View File
@@ -72,45 +72,6 @@ const UptimeMonitors = () => {
>
Create new
</Button>
<Button
variant="contained"
color="success"
onClick={() => {
navigate("/uptime/create");
}}
sx={{
fontWeight: 500,
whiteSpace: "nowrap",
}}
>
Create new
</Button>
<Button
variant="contained"
color="warning"
onClick={() => {
navigate("/uptime/create");
}}
sx={{
fontWeight: 500,
whiteSpace: "nowrap",
}}
>
Create new
</Button>
<Button
variant="contained"
color="error"
onClick={() => {
navigate("/uptime/create");
}}
sx={{
fontWeight: 500,
whiteSpace: "nowrap",
}}
>
Create new
</Button>
</>
)}
</Stack>
+29 -24
View File
@@ -32,8 +32,34 @@ const useUtils = () => {
/* This is used on
1) Details > Gradient card */
/* These are rediections. We should do something that maps up to success, down to error, and get the theme by that
See Client\src\Components\Label\index.jsx
*/
const statusToTheme = {
up: "success",
down: "error",
paused: "warning",
pending: "secondary",
"cannot resolve": "tertiary",
};
const getStatusStyles = (status) => {
const themeColor = statusToTheme[status];
return {
backgroundColor: theme.palette[themeColor].lowContrast,
background: `linear-gradient(340deg, ${theme.palette[themeColor].main} -60%, ${theme.palette[themeColor].lowContrast} 35%)`,
borderColor: theme.palette[themeColor].lowContrast,
"& h2": {
color: theme.palette[themeColor].contrastText,
textTransform: "uppercase",
},
"& p": {
color: theme.palette[themeColor].contrastText,
},
};
};
const statusStyles = {
up: {
backgroundColor: theme.palette.success.lowContrast,
@@ -64,36 +90,15 @@ const useUtils = () => {
/* These are rediections. We should do something that maps up to success, down to error, and get the theme by that
*/
const pagespeedStyles = {
up: {
bg: theme.palette.success.dark,
light: theme.palette.success.light,
stroke: theme.palette.success.main,
},
down: {
bg: theme.palette.error.dark,
light: theme.palette.error.light,
stroke: theme.palette.error.main,
},
paused: {
bg: theme.palette.warning.dark,
light: theme.palette.warning.light,
stroke: theme.palette.warning.main,
},
pending: {
bg: theme.palette.warning.dark,
light: theme.palette.warning.light,
stroke: theme.palette.warning.main,
},
};
return {
determineState,
statusColor,
statusMsg,
pagespeedStatusMsg,
pagespeedStyles,
statusStyles,
statusToTheme,
getStatusStyles,
};
};