From edeaf2ede90e5c06288252b9f26ea2b5e17b7e94 Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Tue, 27 Aug 2024 17:01:28 -0400 Subject: [PATCH] Refactored components styling 2/2 --- Client/src/Components/Check/Check.jsx | 38 ++- Client/src/Components/Check/check.css | 18 +- Client/src/Components/Fallback/index.css | 4 - Client/src/Components/Fallback/index.jsx | 10 +- .../src/Components/Inputs/Checkbox/index.css | 14 -- .../src/Components/Inputs/Checkbox/index.jsx | 20 +- Client/src/Components/Inputs/Field/index.css | 53 +---- Client/src/Components/Inputs/Field/index.jsx | 130 ++++++----- Client/src/Components/Inputs/Image/index.css | 11 - Client/src/Components/Inputs/Image/index.jsx | 42 +++- Client/src/Components/Inputs/Radio/index.css | 1 + .../{RadioButton => Inputs/Radio}/index.jsx | 53 +++-- Client/src/Components/Inputs/Select/index.css | 38 +-- Client/src/Components/Inputs/Select/index.jsx | 55 ++++- Client/src/Components/Label/index.jsx | 28 ++- Client/src/Components/Link/index.jsx | 14 +- Client/src/Components/ProgressBars/index.css | 22 -- Client/src/Components/ProgressBars/index.jsx | 63 +++-- Client/src/Components/RadioButton/index.css | 15 -- Client/src/Components/Sidebar/index.css | 80 ------- Client/src/Components/Sidebar/index.jsx | 221 +++++++++++++----- .../Pages/Monitors/CreateMonitor/index.jsx | 6 +- Client/src/assets/icons/radio-checked.svg | 4 + 23 files changed, 481 insertions(+), 459 deletions(-) create mode 100644 Client/src/Components/Inputs/Radio/index.css rename Client/src/Components/{RadioButton => Inputs/Radio}/index.jsx (53%) delete mode 100644 Client/src/Components/RadioButton/index.css create mode 100644 Client/src/assets/icons/radio-checked.svg diff --git a/Client/src/Components/Check/Check.jsx b/Client/src/Components/Check/Check.jsx index 645e0b5e2..9eaba846e 100644 --- a/Client/src/Components/Check/Check.jsx +++ b/Client/src/Components/Check/Check.jsx @@ -2,7 +2,7 @@ import "./check.css"; import PropTypes from "prop-types"; import CheckGrey from "../../assets/icons/check.svg?react"; import CheckOutlined from "../../assets/icons/check-outlined.svg?react"; -import { Stack, Typography } from "@mui/material"; +import { Box, Stack, Typography } from "@mui/material"; import { useTheme } from "@emotion/react"; /** @@ -22,25 +22,41 @@ import { useTheme } from "@emotion/react"; */ const Check = ({ text, variant = "info", outlined = false }) => { const theme = useTheme(); + const colors = { + success: theme.palette.success.main, + error: theme.palette.error.text, + info: theme.palette.info.border, + }; + return ( {outlined ? ( ) : ( - + path": { fill: colors[variant] }, + }} + > + + )} - {text} + + {text} + ); }; diff --git a/Client/src/Components/Check/check.css b/Client/src/Components/Check/check.css index 8d9bbc24e..8b1378917 100644 --- a/Client/src/Components/Check/check.css +++ b/Client/src/Components/Check/check.css @@ -1,17 +1 @@ -.check > span.MuiTypography-root { - font-size: var(--env-var-font-size-small-plus); - color: var(--secondary-color-light); - opacity: 0.8; -} -.check-error span.MuiTypography-root { - color: var(--error-color); -} -.check-error svg > path { - fill: var(--error-color); -} -.check-success span.MuiTypography-root { - color: var(--success-color); -} -.check-success svg > path { - fill: var(--success-color); -} + diff --git a/Client/src/Components/Fallback/index.css b/Client/src/Components/Fallback/index.css index ea1925ff5..293eb13b3 100644 --- a/Client/src/Components/Fallback/index.css +++ b/Client/src/Components/Fallback/index.css @@ -7,10 +7,6 @@ font-size: var(--env-var-font-size-large); font-weight: 600; } -[class*="fallback__"] .check span.MuiTypography-root, -[class*="fallback__"] h1.MuiTypography-root { - color: var(--secondary-color); -} [class*="fallback__"] button.MuiButtonBase-root, [class*="fallback__"] .check { width: max-content; diff --git a/Client/src/Components/Fallback/index.jsx b/Client/src/Components/Fallback/index.jsx index 976440f7d..79053e539 100644 --- a/Client/src/Components/Fallback/index.jsx +++ b/Client/src/Components/Fallback/index.jsx @@ -27,15 +27,19 @@ const Fallback = ({ title, checks, link = "/" }) => { - - + + A {title} is used to: {checks.map((check, index) => ( diff --git a/Client/src/Components/Inputs/Checkbox/index.css b/Client/src/Components/Inputs/Checkbox/index.css index 130be8853..e69de29bb 100644 --- a/Client/src/Components/Inputs/Checkbox/index.css +++ b/Client/src/Components/Inputs/Checkbox/index.css @@ -1,14 +0,0 @@ -.checkbox-wrapper { - border-radius: var(--env-var-radius-1); -} -.checkbox-wrapper:not(:has(.Mui-disabled)):hover { - background-color: var(--unresolved-bg); -} -.checkbox-wrapper span.MuiTypography-root { - font-size: var(--env-var-font-size-medium); - color: var(--secondary-color-light); -} -.checkbox-wrapper .MuiButtonBase-root { - margin-right: var(--env-var-spacing-1); - padding: 0; -} diff --git a/Client/src/Components/Inputs/Checkbox/index.jsx b/Client/src/Components/Inputs/Checkbox/index.jsx index e454bbc6e..c48c59bf5 100644 --- a/Client/src/Components/Inputs/Checkbox/index.jsx +++ b/Client/src/Components/Inputs/Checkbox/index.jsx @@ -1,5 +1,6 @@ import PropTypes from "prop-types"; import { FormControlLabel, Checkbox as MuiCheckbox } from "@mui/material"; +import { useTheme } from "@emotion/react"; import CheckboxOutline from "../../../assets/icons/checkbox-outline.svg?react"; import CheckboxFilled from "../../../assets/icons/checkbox-filled.svg?react"; @@ -16,7 +17,7 @@ import "./index.css"; * @param {boolean} [props.isDisabled] - Whether the checkbox is disabled or not. * * @returns {JSX.Element} - * + * * @example * { const sizes = { small: "14px", medium: "16px", large: "18px" }; + const theme = useTheme(); return ( diff --git a/Client/src/Components/Inputs/Field/index.css b/Client/src/Components/Inputs/Field/index.css index 8c86f9e30..ab1812013 100644 --- a/Client/src/Components/Inputs/Field/index.css +++ b/Client/src/Components/Inputs/Field/index.css @@ -8,24 +8,6 @@ .field .input-error { font-size: var(--env-var-font-size-medium); } -.field h3.MuiTypography-root, -.field h5.MuiTypography-root, -.field input, -.field textarea { - color: var(--secondary-color); -} -.field h3.MuiTypography-root { - font-weight: 500; -} -.field h3.MuiTypography-root span.field-required { - color: var(--error-color); - margin-left: 2px; -} -.field h3.MuiTypography-root span.field-optional { - opacity: 0.6; - margin-left: 4px; - font-weight: 400; -} .field h5.MuiTypography-root { position: relative; opacity: 0.8; @@ -37,24 +19,7 @@ .field .MuiInputBase-root:has(.MuiInputAdornment-root) { padding-right: var(--env-var-spacing-1-minus); } -.field - .MuiInputBase-root:has(.copy.MuiInputAdornment-root > .MuiButtonBase-root) { - padding-right: 0; -} -.field .MuiInputBase-root .copy.MuiInputAdornment-root .MuiButtonBase-root { - padding: 0 var(--env-var-spacing-1-minus); - font-size: var(--env-var-font-size-medium); - border-radius: 0; - height: 34px; -} -.field .MuiInputBase-root .copy.MuiInputAdornment-root .MuiButtonBase-root svg { - width: 20px; - height: 20px; - margin-right: 5px; -} -.field .MuiInputBase-root .MuiInputAdornment-root .MuiButtonBase-root:hover { - border-color: var(--border-color-dark); -} + .field input { height: 100%; padding: 0 var(--env-var-spacing-1-minus); @@ -62,22 +27,6 @@ .field .MuiInputBase-root:has(textarea) { padding: var(--env-var-spacing-1-minus); } -.field .MuiOutlinedInput-root fieldset { - border-color: var(--border-color-dark); - border-radius: var(--env-var-radius-1); -} -.field:not(:has(.Mui-disabled)):not(:has(.input-error)) - .MuiOutlinedInput-root:hover:not(:has(input:focus)):not(:has(textarea:focus)) - fieldset { - border-color: var(--border-color-dark); -} -.field .input-error { - color: var(--error-color); - opacity: 0.8; -} -.field:has(.input-error) .MuiOutlinedInput-root fieldset { - border-color: var(--error-color); -} .register-page .field .MuiOutlinedInput-root fieldset, .register-page .field input, diff --git a/Client/src/Components/Inputs/Field/index.jsx b/Client/src/Components/Inputs/Field/index.jsx index 335ed178f..12ecc8775 100644 --- a/Client/src/Components/Inputs/Field/index.jsx +++ b/Client/src/Components/Inputs/Field/index.jsx @@ -23,7 +23,6 @@ import { forwardRef, useState } from "react"; * @param {boolean} [props.isRequired] - Indicates if the field is required, will display a red asterisk. * @param {boolean} [props.isOptional] - Indicates if the field is optional, will display optional text. * @param {string} [props.optionalLabel] - Optional label for the input field. - * @param {boolean} [props.hasCopy] - Indicates if the field supports copying. * @param {string} [props.autoComplete] - Autocomplete value for the input field. * @param {string} [props.placeholder] - Placeholder text for the input field. * @param {string} props.value - Value of the input field. @@ -43,7 +42,6 @@ const Field = forwardRef( isRequired, isOptional, optionalLabel, - hasCopy, autoComplete, placeholder, value, @@ -56,25 +54,54 @@ const Field = forwardRef( ) => { const theme = useTheme(); - // TODO - are we using this feature anywhere ? - const [copy, setCopy] = useState(false); - const handleCopy = () => { - setCopy(true); - setTimeout(() => setCopy(false), 1000); - }; - const [isVisible, setVisible] = useState(false); return ( - + {label && ( - + {label} - {isRequired ? * : ""} + {isRequired ? ( + + * + + ) : ( + "" + )} {isOptional ? ( - + {optionalLabel || "(optional)"} - + ) : ( "" )} @@ -115,60 +142,48 @@ const Field = forwardRef( pl: theme.gap.medium, }} > - + {https ? "https" : "http"}:// ), - endAdornment: - type === "password" ? ( - - setVisible((show) => !show)} - tabIndex={-1} - sx={{ - color: theme.palette.section.borderColor, - padding: `calc(${theme.gap.xs} / 2)`, - "&:focus": { - outline: "none", - }, - "& .MuiTouchRipple-root": { - pointerEvents: "none", - display: "none", - }, - }} - > - {!isVisible ? : } - - - ) : ( - hasCopy && ( - -