From 623a2b65b99de9456ec764dd3773f8de7efbf8bd Mon Sep 17 00:00:00 2001 From: mohadeseh safari Date: Sun, 6 Apr 2025 14:43:40 -0400 Subject: [PATCH] Add warning for missing Google PageSpeed API key --- src/Components/Alert/index.jsx | 25 +++++++++-- src/Components/Fallback/index.jsx | 71 +++++++++++++++++++++++++++---- src/Utils/Theme/constants.js | 18 +++++++- 3 files changed, 100 insertions(+), 14 deletions(-) diff --git a/src/Components/Alert/index.jsx b/src/Components/Alert/index.jsx index 0b32fe2b1..4737954fa 100644 --- a/src/Components/Alert/index.jsx +++ b/src/Components/Alert/index.jsx @@ -26,18 +26,32 @@ const icons = { * @param {boolean} [props.isToast] - Indicates if the alert is used as a toast notification. * @param {boolean} [props.hasIcon] - Whether to display an icon in the alert. * @param {function} props.onClick - Toast dismiss function. + * @param {string} [props.customBgColor] - Custom background color for the alert. + * @param {string} [props.customTextColor] - Custom text color for the alert. + * @param {string} [props.customBorderColor] - Custom border color for the alert. * @returns {JSX.Element} */ -const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => { +const Alert = ({ + variant, + title, + body, + isToast, + hasIcon = true, + onClick, + customBgColor, + customTextColor, + customBorderColor +}) => { const theme = useTheme(); /* TODO Do we need other variants for alert? */ - const text = theme.palette.secondary.contrastText; - const border = theme.palette.alert.contrastText; - const bg = theme.palette.alert.main; + // Use custom colors if provided, otherwise use theme colors + const text = customTextColor || theme.palette.secondary.contrastText; + const border = customBorderColor || theme.palette.alert.contrastText; + const bg = customBgColor || theme.palette.alert.main; const icon = icons[variant]; return ( @@ -114,6 +128,9 @@ Alert.propTypes = { body: PropTypes.string, isToast: PropTypes.bool, hasIcon: PropTypes.bool, + customBgColor: PropTypes.string, + customTextColor: PropTypes.string, + customBorderColor: PropTypes.string, onClick: function (props, propName, componentName) { if (props.isToast && !props[propName]) { return new Error( diff --git a/src/Components/Fallback/index.jsx b/src/Components/Fallback/index.jsx index bdee376c5..6eae9915d 100644 --- a/src/Components/Fallback/index.jsx +++ b/src/Components/Fallback/index.jsx @@ -1,12 +1,14 @@ import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; -import { Box, Button, Stack, Typography } from "@mui/material"; +import { Box, Button, Stack, Typography, Link } from "@mui/material"; import Skeleton from "../../assets/Images/create-placeholder.svg?react"; import SkeletonDark from "../../assets/Images/create-placeholder-dark.svg?react"; import Background from "../../assets/Images/background-grid.svg?react"; import Check from "../Check/Check"; import { useNavigate } from "react-router-dom"; import { useSelector } from "react-redux"; +import { paletteColors } from "../../Utils/Theme/constants"; +import Alert from "../Alert"; import "./index.css"; /** @@ -25,6 +27,29 @@ const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false }) => const navigate = useNavigate(); const mode = useSelector((state) => state.ui.mode); + // Custom warning message with clickable link + const renderWarningMessage = () => { + return ( + <> + Warning: You haven't added a Google PageSpeed API key. Without it, the PageSpeed monitor won't function. {" "} + + Click here to learn + + {" "}how to add your API key. + + ); + }; + return ( {/* TODO - display a different fallback if user is not an admin*/} {isAdmin && ( - + <> + + + {/* Warning box for PageSpeed monitor */} + {title === "pagespeed monitor" && ( + + +
+ +
+
+ )} + )}
diff --git a/src/Utils/Theme/constants.js b/src/Utils/Theme/constants.js index 239d36e36..f7d596aae 100644 --- a/src/Utils/Theme/constants.js +++ b/src/Utils/Theme/constants.js @@ -63,6 +63,8 @@ const paletteColors = { orange500: "#E88C30", orange600: "#DC6803", orange800: "#624711", + yellow50: "#FFFCF5", + yellow300: "#FEC84B", }; const semanticColors = { @@ -248,6 +250,20 @@ const newSemanticColors = { dark: newColors.red600, }, }, + pageSpeedWarning: { + main: { + light: newColors.yellow50, + dark: newColors.yellow300, + }, + contrastText: { + light: newColors.offBlack, + dark: newColors.offWhite, + }, + lowContrast: { + light: newColors.yellow300, + dark: newColors.yellow50, + }, + }, /* These are temporary, just for everything not to break */ gradient: { color1: { @@ -308,4 +324,4 @@ const newSemanticColors = { }, }; -export { typographyLevels, semanticColors as colors, newSemanticColors }; +export { typographyLevels, semanticColors as colors, newSemanticColors, paletteColors };