From 42f4cc8dddf8640f53f58b6dc6ada73e4ef8731f Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 18 Dec 2024 14:11:03 -0800 Subject: [PATCH 1/2] Create reusable IconBox --- Client/src/Components/IconBox/index.jsx | 77 +++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Client/src/Components/IconBox/index.jsx diff --git a/Client/src/Components/IconBox/index.jsx b/Client/src/Components/IconBox/index.jsx new file mode 100644 index 000000000..8000fbd64 --- /dev/null +++ b/Client/src/Components/IconBox/index.jsx @@ -0,0 +1,77 @@ +import { Box, styled } from "@mui/material"; +import PropTypes from "prop-types"; + +/** + * IconBox - A styled box component for rendering icons with consistent sizing and styling + * + * @component + * @param {Object} [props] - Configuration options for the IconBox + * @param {number} [props.height=34] - Height of the icon box + * @param {number} [props.width=34] - Width of the icon box + * @param {number} [props.minWidth=34] - Minimum width of the icon box + * @param {number} [props.borderRadius=4] - Border radius of the icon box + * @param {number} [props.svgWidth=20] - Width of the SVG icon + * @param {number} [props.svgHeight=20] - Height of the SVG icon + * + * @example + * // Basic usage + * + * + * + * + * @example + * // Customized usage + * + * + * + * + * @returns {React.ReactElement} A styled box containing an icon + */ +const IconBox = styled(Box)( + ({ + theme, + height = 34, + width = 34, + minWidth = 34, + borderRadius = 4, + svgWidth = 20, + svgHeight = 20, + }) => ({ + height: height, + minWidth: minWidth, + width: width, + position: "relative", + border: 1, + borderStyle: "solid", + borderColor: theme.palette.border.dark, + borderRadius: borderRadius, + backgroundColor: theme.palette.background.accent, + "& svg": { + position: "absolute", + top: "50%", + left: "50%", + transform: "translate(-50%, -50%)", + width: svgWidth, + height: svgHeight, + "& path": { + stroke: theme.palette.text.tertiary, + }, + }, + }) +); + +IconBox.propTypes = { + height: PropTypes.number, + width: PropTypes.number, + minWidth: PropTypes.number, + borderRadius: PropTypes.number, + svgWidth: PropTypes.number, + svgHeight: PropTypes.number, +}; + +export default IconBox; From 21b876a7231fc6359709ad0b326c77f54d42cf76 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 18 Dec 2024 14:11:11 -0800 Subject: [PATCH 2/2] Use IconBox consistently --- Client/src/Pages/Auth/CheckEmail.jsx | 21 ++++++++++++--- Client/src/Pages/Auth/ForgotPassword.jsx | 21 ++++++++++++--- .../src/Pages/Auth/NewPasswordConfirmed.jsx | 23 ++++++++++++---- Client/src/Pages/Auth/SetNewPassword.jsx | 22 ++++++++++++---- Client/src/Pages/Auth/styled.jsx | 26 ------------------- Client/src/Pages/PageSpeed/Details/index.jsx | 3 ++- Client/src/Pages/PageSpeed/Details/styled.jsx | 23 ---------------- Client/src/Pages/PageSpeed/card.jsx | 3 +-- Client/src/Pages/Uptime/Details/index.jsx | 4 +-- Client/src/Pages/Uptime/Details/styled.jsx | 23 ---------------- 10 files changed, 74 insertions(+), 95 deletions(-) delete mode 100644 Client/src/Pages/Auth/styled.jsx diff --git a/Client/src/Pages/Auth/CheckEmail.jsx b/Client/src/Pages/Auth/CheckEmail.jsx index b36cca7b0..70acbe72d 100644 --- a/Client/src/Pages/Auth/CheckEmail.jsx +++ b/Client/src/Pages/Auth/CheckEmail.jsx @@ -5,10 +5,10 @@ import { useDispatch } from "react-redux"; import { useNavigate } from "react-router"; import { createToast } from "../../Utils/toastUtils"; import { forgotPassword } from "../../Features/Auth/authSlice"; -import { IconBox } from "./styled"; import Background from "../../assets/Images/background-grid.svg?react"; import EmailIcon from "../../assets/icons/email.svg?react"; import Logo from "../../assets/icons/bwu-icon.svg?react"; +import IconBox from "../../Components/IconBox"; import "./index.css"; const CheckEmail = () => { @@ -144,9 +144,22 @@ const CheckEmail = () => { textAlign="center" > - - - + + + + + Check your email We sent a password reset link to{" "} diff --git a/Client/src/Pages/Auth/ForgotPassword.jsx b/Client/src/Pages/Auth/ForgotPassword.jsx index 1fd5f1b2f..7fcc19531 100644 --- a/Client/src/Pages/Auth/ForgotPassword.jsx +++ b/Client/src/Pages/Auth/ForgotPassword.jsx @@ -6,12 +6,12 @@ import { forgotPassword } from "../../Features/Auth/authSlice"; import { useEffect, useState } from "react"; import { credentials } from "../../Validation/validation"; import { useNavigate } from "react-router-dom"; -import { IconBox } from "./styled"; import TextInput from "../../Components/Inputs/TextInput"; import Logo from "../../assets/icons/bwu-icon.svg?react"; import Key from "../../assets/icons/key.svg?react"; import Background from "../../assets/Images/background-grid.svg?react"; import LoadingButton from "@mui/lab/LoadingButton"; +import IconBox from "../../Components/IconBox"; import "./index.css"; const ForgotPassword = () => { @@ -146,9 +146,22 @@ const ForgotPassword = () => { textAlign="center" > - - - + + + + + Forgot password? No worries, we'll send you reset instructions. diff --git a/Client/src/Pages/Auth/NewPasswordConfirmed.jsx b/Client/src/Pages/Auth/NewPasswordConfirmed.jsx index c380425c9..2c4ef0106 100644 --- a/Client/src/Pages/Auth/NewPasswordConfirmed.jsx +++ b/Client/src/Pages/Auth/NewPasswordConfirmed.jsx @@ -4,10 +4,10 @@ import { useNavigate } from "react-router"; import { useDispatch } from "react-redux"; import { clearAuthState } from "../../Features/Auth/authSlice"; import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice"; -import { IconBox } from "./styled"; import Background from "../../assets/Images/background-grid.svg?react"; import ConfirmIcon from "../../assets/icons/check-outlined.svg?react"; import Logo from "../../assets/icons/bwu-icon.svg?react"; +import IconBox from "../../Components/IconBox"; import "./index.css"; const NewPasswordConfirmed = () => { @@ -80,9 +80,22 @@ const NewPasswordConfirmed = () => { textAlign="center" > - - - + + + + + Password reset Your password has been successfully reset. Click below to log in magically. @@ -91,7 +104,7 @@ const NewPasswordConfirmed = () => {