From 3adb73fe9627537fdc6b592ac82d73e35c06500e Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Fri, 12 Jul 2024 19:27:47 -0400 Subject: [PATCH] Replaced textfield components in profile and password panels --- .../TabPanels/Account/PasswordPanel.jsx | 95 +++++++------------ .../TabPanels/Account/ProfilePanel.jsx | 83 +++++----------- .../src/Components/TextFields/Field/index.css | 20 ++-- .../src/Components/TextFields/Field/index.jsx | 73 ++++++-------- Client/src/Pages/Account/index.css | 8 +- Client/src/Pages/Demo/Demo.jsx | 2 +- 6 files changed, 105 insertions(+), 176 deletions(-) diff --git a/Client/src/Components/TabPanels/Account/PasswordPanel.jsx b/Client/src/Components/TabPanels/Account/PasswordPanel.jsx index 0e035f5cf..1ef7a07e3 100644 --- a/Client/src/Components/TabPanels/Account/PasswordPanel.jsx +++ b/Client/src/Components/TabPanels/Account/PasswordPanel.jsx @@ -3,7 +3,7 @@ import React, { useState } from "react"; import { useTheme } from "@emotion/react"; import { Box, Divider, Stack, Typography } from "@mui/material"; import ButtonSpinner from "../../ButtonSpinner"; -import PasswordTextField from "../../TextFields/Password/PasswordTextField"; +import Field from "../../TextFields/Field"; import { editPasswordValidation } from "../../../Validation/validation"; import Alert from "../../Alert"; import { update } from "../../../Features/Auth/authSlice"; @@ -120,76 +120,49 @@ const PasswordPanel = () => { Current password - - - {errors[idToName["edit-current-password"]] ? ( - - {errors[idToName["edit-current-password"]]} - - ) : ( - "" - )} - +
New password - - - {errors[idToName["edit-new-password"]] ? ( - - {errors[idToName["edit-new-password"]]} - - ) : ( - "" - )} - +
Confirm new password - - - {errors[idToName["edit-confirm-password"]] ? ( - - {errors[idToName["edit-confirm-password"]]} - - ) : ( - "" - )} - +
diff --git a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx index e96f507d9..d56bd5f4e 100644 --- a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx +++ b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx @@ -4,9 +4,8 @@ import TabPanel from "@mui/lab/TabPanel"; import { Box, Divider, Modal, Stack, Typography } from "@mui/material"; import ButtonSpinner from "../../ButtonSpinner"; import Button from "../../Button"; -import EmailTextField from "../../TextFields/Email/EmailTextField"; -import StringTextField from "../../TextFields/Text/TextField"; import Avatar from "../../Avatar"; +import Field from "../../TextFields/Field"; import { editProfileValidation, imageValidation, @@ -219,47 +218,27 @@ const ProfilePanel = () => { First name - - - {errors[idToName["edit-first-name"]] ? ( - - {errors[idToName["edit-first-name"]]} - - ) : ( - "" - )} - +
Last name - - - {errors[idToName["edit-last-name"]] ? ( - - {errors[idToName["edit-last-name"]]} - - ) : ( - "" - )} - +
@@ -268,25 +247,15 @@ const ProfilePanel = () => { This is your current email address — it cannot be changed. - - - {errors[idToName["edit-email"]] ? ( - - {errors[idToName["edit-email"]]} - - ) : ( - "" - )} - +
diff --git a/Client/src/Components/TextFields/Field/index.css b/Client/src/Components/TextFields/Field/index.css index 10d4c6720..8c51c81ee 100644 --- a/Client/src/Components/TextFields/Field/index.css +++ b/Client/src/Components/TextFields/Field/index.css @@ -1,21 +1,21 @@ .field { min-width: 250px; } -.field h1.MuiTypography-root, +.field h3.MuiTypography-root, .field h5.MuiTypography-root, .field input, .field .input-error { font-size: var(--env-var-font-size-medium); } -.field h1.MuiTypography-root, +.field h3.MuiTypography-root, .field h5.MuiTypography-root, .field input { color: var(--env-var-color-5); } -.field h1.MuiTypography-root { - font-weight: 600; +.field h3.MuiTypography-root { + font-weight: 500; } -.field h1.MuiTypography-root span { +.field h3.MuiTypography-root span { color: var(--env-var-color-19); margin-left: 1px; } @@ -27,19 +27,19 @@ border-right: solid 1px var(--env-var-color-29); } .field .MuiInputBase-root { - height: 39px; + height: 35px; + overflow: hidden; +} +.field .MuiInputBase-root:has(.MuiInputAdornment-root) { padding-right: var(--env-var-spacing-1-minus); } .field input { - padding: var(--env-var-spacing-1-minus); + padding: 0 var(--env-var-spacing-1-minus); } .field .MuiOutlinedInput-root fieldset { border-color: var(--env-var-color-29); border-radius: var(--env-var-radius-1); } -.field .MuiOutlinedInput-root:hover fieldset { - border-color: var(--env-var-color-25); -} .field .input-error { color: var(--env-var-color-24); opacity: 0.8; diff --git a/Client/src/Components/TextFields/Field/index.jsx b/Client/src/Components/TextFields/Field/index.jsx index 811146faa..b02f9891b 100644 --- a/Client/src/Components/TextFields/Field/index.jsx +++ b/Client/src/Components/TextFields/Field/index.jsx @@ -11,7 +11,7 @@ import Visibility from "@mui/icons-material/Visibility"; import "./index.css"; const Field = ({ - type, + type = "text", id, label, isRequired, @@ -29,60 +29,49 @@ const Field = ({ return ( {label && ( - + {label} {isRequired ? * : ""} )} http://, - } - : type === "password" && { - endAdornment: ( - - setVisibility((show) => !show)} - tabIndex={-1} - sx={{ - color: theme.palette.section.borderColor, - padding: theme.gap.xs, - "&:focus": { - outline: "none", - }, - "& .MuiTouchRipple-root": { - pointerEvents: "none", - display: "none", - }, - }} - > - {!isVisible ? : } - - - ), - } - } + InputProps={{ + startAdornment: type === "url" && ( + https:// + ), + endAdornment: type === "password" && ( + + setVisibility((show) => !show)} + tabIndex={-1} + sx={{ + color: theme.palette.section.borderColor, + padding: theme.gap.xs, + "&:focus": { + outline: "none", + }, + "& .MuiTouchRipple-root": { + pointerEvents: "none", + display: "none", + }, + }} + > + {!isVisible ? : } + + + ), + }} /> {error && ( - + {error} )} diff --git a/Client/src/Pages/Account/index.css b/Client/src/Pages/Account/index.css index acf71988b..608e08b94 100644 --- a/Client/src/Pages/Account/index.css +++ b/Client/src/Pages/Account/index.css @@ -139,7 +139,7 @@ } } -.account .MuiStack-root:has(p.MuiTypography-root.input-error) { +.account .MuiStack-root:has(span.MuiTypography-root.input-error) { position: relative; } .account .text-field-icon { @@ -150,11 +150,9 @@ height: 18px !important; opacity: 0.8; } -.account p.MuiTypography-root.input-error { - color: var(--env-var-color-24); - opacity: 0.8; +.account span.MuiTypography-root.input-error { position: absolute; - top: calc(100% + 5px); + top: 100%; } .account .email-text-field, .account .password-text-field { diff --git a/Client/src/Pages/Demo/Demo.jsx b/Client/src/Pages/Demo/Demo.jsx index 9d3cea52d..c95dcc7a1 100644 --- a/Client/src/Pages/Demo/Demo.jsx +++ b/Client/src/Pages/Demo/Demo.jsx @@ -512,7 +512,7 @@ const Demo = () => { placeholder="Create a password" />