Replaced textfield components in profile and password panels
This commit is contained in:
1 parent
3855d4e4d5
commit
3adb73fe96
6 files changed
+105
-176
No files matched your search
@@ -3,7 +3,7 @@ import React, { useState } from "react";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Divider, Stack, Typography } from "@mui/material";
|
import { Box, Divider, Stack, Typography } from "@mui/material";
|
||||||
import ButtonSpinner from "../../ButtonSpinner";
|
import ButtonSpinner from "../../ButtonSpinner";
|
||||||
import PasswordTextField from "../../TextFields/Password/PasswordTextField";
|
import Field from "../../TextFields/Field";
|
||||||
import { editPasswordValidation } from "../../../Validation/validation";
|
import { editPasswordValidation } from "../../../Validation/validation";
|
||||||
import Alert from "../../Alert";
|
import Alert from "../../Alert";
|
||||||
import { update } from "../../../Features/Auth/authSlice";
|
import { update } from "../../../Features/Auth/authSlice";
|
||||||
@@ -120,76 +120,49 @@ const PasswordPanel = () => {
|
|||||||
<Stack>
|
<Stack>
|
||||||
<Typography component="h1">Current password</Typography>
|
<Typography component="h1">Current password</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Field
|
||||||
<PasswordTextField
|
type="password"
|
||||||
id="edit-current-password"
|
id="edit-current-password"
|
||||||
label={null}
|
placeholder="Enter your current password"
|
||||||
placeholder="Enter your current password"
|
autoComplete="current-password"
|
||||||
autoComplete="current-password"
|
isVisible={showPassword}
|
||||||
visibility={showPassword}
|
setVisibility={setShowPassword}
|
||||||
setVisibility={setShowPassword}
|
value={localData.password}
|
||||||
value={localData.password}
|
onChange={handleChange}
|
||||||
onChange={handleChange}
|
error={errors[idToName["edit-current-password"]]}
|
||||||
error={errors[idToName["edit-current-password"]] ? true : false}
|
/>
|
||||||
/>
|
|
||||||
{errors[idToName["edit-current-password"]] ? (
|
|
||||||
<Typography component="p" className="input-error">
|
|
||||||
{errors[idToName["edit-current-password"]]}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-password-form__wrapper">
|
<div className="edit-password-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography component="h1">New password</Typography>
|
<Typography component="h1">New password</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Field
|
||||||
<PasswordTextField
|
type="password"
|
||||||
id="edit-new-password"
|
id="edit-new-password"
|
||||||
label={null}
|
placeholder="Enter your new password"
|
||||||
placeholder="Enter your new password"
|
autoComplete="new-password"
|
||||||
autoComplete="new-password"
|
isVisible={showPassword}
|
||||||
visibility={showPassword}
|
setVisibility={setShowPassword}
|
||||||
setVisibility={setShowPassword}
|
value={localData.newPassword}
|
||||||
value={localData.newPassword}
|
onChange={handleChange}
|
||||||
onChange={handleChange}
|
error={errors[idToName["edit-new-password"]]}
|
||||||
error={errors[idToName["edit-new-password"]] ? true : false}
|
/>
|
||||||
/>
|
|
||||||
{errors[idToName["edit-new-password"]] ? (
|
|
||||||
<Typography component="p" className="input-error">
|
|
||||||
{errors[idToName["edit-new-password"]]}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-password-form__wrapper">
|
<div className="edit-password-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography component="h1">Confirm new password</Typography>
|
<Typography component="h1">Confirm new password</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Field
|
||||||
<PasswordTextField
|
type="password"
|
||||||
id="edit-confirm-password"
|
id="edit-confirm-password"
|
||||||
label={null}
|
placeholder="Reenter your new password"
|
||||||
placeholder="Reenter your new password"
|
autoComplete="new-password"
|
||||||
autoComplete="new-password"
|
isVisible={showPassword}
|
||||||
visibility={showPassword}
|
setVisibility={setShowPassword}
|
||||||
setVisibility={setShowPassword}
|
value={localData.confirm}
|
||||||
value={localData.confirm}
|
onChange={handleChange}
|
||||||
onChange={handleChange}
|
error={errors[idToName["edit-confirm-password"]]}
|
||||||
error={errors[idToName["edit-confirm-password"]] ? true : false}
|
/>
|
||||||
/>
|
|
||||||
{errors[idToName["edit-confirm-password"]] ? (
|
|
||||||
<Typography component="p" className="input-error">
|
|
||||||
{errors[idToName["edit-confirm-password"]]}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-password-form__wrapper">
|
<div className="edit-password-form__wrapper">
|
||||||
<Stack></Stack>
|
<Stack></Stack>
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import TabPanel from "@mui/lab/TabPanel";
|
|||||||
import { Box, Divider, Modal, Stack, Typography } from "@mui/material";
|
import { Box, Divider, Modal, Stack, Typography } from "@mui/material";
|
||||||
import ButtonSpinner from "../../ButtonSpinner";
|
import ButtonSpinner from "../../ButtonSpinner";
|
||||||
import Button from "../../Button";
|
import Button from "../../Button";
|
||||||
import EmailTextField from "../../TextFields/Email/EmailTextField";
|
|
||||||
import StringTextField from "../../TextFields/Text/TextField";
|
|
||||||
import Avatar from "../../Avatar";
|
import Avatar from "../../Avatar";
|
||||||
|
import Field from "../../TextFields/Field";
|
||||||
import {
|
import {
|
||||||
editProfileValidation,
|
editProfileValidation,
|
||||||
imageValidation,
|
imageValidation,
|
||||||
@@ -219,47 +218,27 @@ const ProfilePanel = () => {
|
|||||||
<Stack>
|
<Stack>
|
||||||
<Typography component="h1">First name</Typography>
|
<Typography component="h1">First name</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Field
|
||||||
<StringTextField
|
id="edit-first-name"
|
||||||
id="edit-first-name"
|
value={localData.firstname}
|
||||||
label={null}
|
placeholder="Enter your first name"
|
||||||
value={localData.firstname}
|
autoComplete="given-name"
|
||||||
placeholder="Enter your first name"
|
onChange={handleChange}
|
||||||
autoComplete="given-name"
|
error={errors[idToName["edit-first-name"]]}
|
||||||
onChange={handleChange}
|
/>
|
||||||
error={errors[idToName["edit-first-name"]] ? true : false}
|
|
||||||
/>
|
|
||||||
{errors[idToName["edit-first-name"]] ? (
|
|
||||||
<Typography component="p" className="input-error">
|
|
||||||
{errors[idToName["edit-first-name"]]}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography component="h1">Last name</Typography>
|
<Typography component="h1">Last name</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Field
|
||||||
<StringTextField
|
id="edit-last-name"
|
||||||
id="edit-last-name"
|
placeholder="Enter your last name"
|
||||||
label={null}
|
autoComplete="family-name"
|
||||||
value={localData.lastname}
|
value={localData.lastname}
|
||||||
placeholder="Enter your last name"
|
onChange={handleChange}
|
||||||
autoComplete="family-name"
|
error={errors[idToName["edit-last-name"]]}
|
||||||
onChange={handleChange}
|
/>
|
||||||
error={errors[idToName["edit-last-name"]] ? true : false}
|
|
||||||
/>
|
|
||||||
{errors[idToName["edit-last-name"]] ? (
|
|
||||||
<Typography component="p" className="input-error">
|
|
||||||
{errors[idToName["edit-last-name"]]}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -268,25 +247,15 @@ const ProfilePanel = () => {
|
|||||||
This is your current email address — it cannot be changed.
|
This is your current email address — it cannot be changed.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Field
|
||||||
<EmailTextField
|
id="edit-email"
|
||||||
id="edit-email"
|
value={user.email}
|
||||||
label={null}
|
placeholder="Enter your email"
|
||||||
value={user.email}
|
autoComplete="email"
|
||||||
placeholder="Enter your email"
|
// onChange={handleChange}
|
||||||
autoComplete="email"
|
// error={errors[idToName["edit-email"]]}
|
||||||
// onChange={handleChange}
|
disabled={true}
|
||||||
// error={errors[idToName["edit-email"]] ? true : false}
|
/>
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
{errors[idToName["edit-email"]] ? (
|
|
||||||
<Typography component="p" className="input-error">
|
|
||||||
{errors[idToName["edit-email"]]}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
.field {
|
.field {
|
||||||
min-width: 250px;
|
min-width: 250px;
|
||||||
}
|
}
|
||||||
.field h1.MuiTypography-root,
|
.field h3.MuiTypography-root,
|
||||||
.field h5.MuiTypography-root,
|
.field h5.MuiTypography-root,
|
||||||
.field input,
|
.field input,
|
||||||
.field .input-error {
|
.field .input-error {
|
||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
}
|
}
|
||||||
.field h1.MuiTypography-root,
|
.field h3.MuiTypography-root,
|
||||||
.field h5.MuiTypography-root,
|
.field h5.MuiTypography-root,
|
||||||
.field input {
|
.field input {
|
||||||
color: var(--env-var-color-5);
|
color: var(--env-var-color-5);
|
||||||
}
|
}
|
||||||
.field h1.MuiTypography-root {
|
.field h3.MuiTypography-root {
|
||||||
font-weight: 600;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.field h1.MuiTypography-root span {
|
.field h3.MuiTypography-root span {
|
||||||
color: var(--env-var-color-19);
|
color: var(--env-var-color-19);
|
||||||
margin-left: 1px;
|
margin-left: 1px;
|
||||||
}
|
}
|
||||||
@@ -27,19 +27,19 @@
|
|||||||
border-right: solid 1px var(--env-var-color-29);
|
border-right: solid 1px var(--env-var-color-29);
|
||||||
}
|
}
|
||||||
.field .MuiInputBase-root {
|
.field .MuiInputBase-root {
|
||||||
height: 39px;
|
height: 35px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.field .MuiInputBase-root:has(.MuiInputAdornment-root) {
|
||||||
padding-right: var(--env-var-spacing-1-minus);
|
padding-right: var(--env-var-spacing-1-minus);
|
||||||
}
|
}
|
||||||
.field input {
|
.field input {
|
||||||
padding: var(--env-var-spacing-1-minus);
|
padding: 0 var(--env-var-spacing-1-minus);
|
||||||
}
|
}
|
||||||
.field .MuiOutlinedInput-root fieldset {
|
.field .MuiOutlinedInput-root fieldset {
|
||||||
border-color: var(--env-var-color-29);
|
border-color: var(--env-var-color-29);
|
||||||
border-radius: var(--env-var-radius-1);
|
border-radius: var(--env-var-radius-1);
|
||||||
}
|
}
|
||||||
.field .MuiOutlinedInput-root:hover fieldset {
|
|
||||||
border-color: var(--env-var-color-25);
|
|
||||||
}
|
|
||||||
.field .input-error {
|
.field .input-error {
|
||||||
color: var(--env-var-color-24);
|
color: var(--env-var-color-24);
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Visibility from "@mui/icons-material/Visibility";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const Field = ({
|
const Field = ({
|
||||||
type,
|
type = "text",
|
||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
isRequired,
|
isRequired,
|
||||||
@@ -29,60 +29,49 @@ const Field = ({
|
|||||||
return (
|
return (
|
||||||
<Stack gap={theme.gap.xs} className={`field field-${type}`}>
|
<Stack gap={theme.gap.xs} className={`field field-${type}`}>
|
||||||
{label && (
|
{label && (
|
||||||
<Typography component="h1">
|
<Typography component="h3">
|
||||||
{label}
|
{label}
|
||||||
{isRequired ? <span>*</span> : ""}
|
{isRequired ? <span>*</span> : ""}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
<TextField
|
<TextField
|
||||||
type={
|
type={type === "password" ? (isVisible ? "text" : type) : type}
|
||||||
type === "password"
|
|
||||||
? isVisible
|
|
||||||
? "text"
|
|
||||||
: type
|
|
||||||
: type === "website"
|
|
||||||
? "text"
|
|
||||||
: type
|
|
||||||
}
|
|
||||||
id={id}
|
id={id}
|
||||||
autoComplete={autoComplete}
|
autoComplete={autoComplete}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
InputProps={
|
InputProps={{
|
||||||
type === "website"
|
startAdornment: type === "url" && (
|
||||||
? {
|
<Typography component="h5">https://</Typography>
|
||||||
startAdornment: <Typography component="h5">http://</Typography>,
|
),
|
||||||
}
|
endAdornment: type === "password" && (
|
||||||
: type === "password" && {
|
<InputAdornment position="end">
|
||||||
endAdornment: (
|
<IconButton
|
||||||
<InputAdornment position="end">
|
aria-label="toggle password visibility"
|
||||||
<IconButton
|
onClick={() => setVisibility((show) => !show)}
|
||||||
aria-label="toggle password visibility"
|
tabIndex={-1}
|
||||||
onClick={() => setVisibility((show) => !show)}
|
sx={{
|
||||||
tabIndex={-1}
|
color: theme.palette.section.borderColor,
|
||||||
sx={{
|
padding: theme.gap.xs,
|
||||||
color: theme.palette.section.borderColor,
|
"&:focus": {
|
||||||
padding: theme.gap.xs,
|
outline: "none",
|
||||||
"&:focus": {
|
},
|
||||||
outline: "none",
|
"& .MuiTouchRipple-root": {
|
||||||
},
|
pointerEvents: "none",
|
||||||
"& .MuiTouchRipple-root": {
|
display: "none",
|
||||||
pointerEvents: "none",
|
},
|
||||||
display: "none",
|
}}
|
||||||
},
|
>
|
||||||
}}
|
{!isVisible ? <VisibilityOff /> : <Visibility />}
|
||||||
>
|
</IconButton>
|
||||||
{!isVisible ? <VisibilityOff /> : <Visibility />}
|
</InputAdornment>
|
||||||
</IconButton>
|
),
|
||||||
</InputAdornment>
|
}}
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
{error && (
|
{error && (
|
||||||
<Typography component="p" className="input-error" mt={theme.gap.xs}>
|
<Typography component="span" className="input-error" mt={theme.gap.xs}>
|
||||||
{error}
|
{error}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.account .MuiStack-root:has(p.MuiTypography-root.input-error) {
|
.account .MuiStack-root:has(span.MuiTypography-root.input-error) {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.account .text-field-icon {
|
.account .text-field-icon {
|
||||||
@@ -150,11 +150,9 @@
|
|||||||
height: 18px !important;
|
height: 18px !important;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
.account p.MuiTypography-root.input-error {
|
.account span.MuiTypography-root.input-error {
|
||||||
color: var(--env-var-color-24);
|
|
||||||
opacity: 0.8;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + 5px);
|
top: 100%;
|
||||||
}
|
}
|
||||||
.account .email-text-field,
|
.account .email-text-field,
|
||||||
.account .password-text-field {
|
.account .password-text-field {
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ const Demo = () => {
|
|||||||
placeholder="Create a password"
|
placeholder="Create a password"
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="website"
|
type="url"
|
||||||
label="Website"
|
label="Website"
|
||||||
placeholder="google.com"
|
placeholder="google.com"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user