From 51ce98f5e91ae2c8afd20d035a63c40f92961fea Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Sat, 13 Jul 2024 14:17:04 -0400 Subject: [PATCH] Added copy button and description input type --- .../src/Components/TextFields/Field/index.css | 28 ++++- .../src/Components/TextFields/Field/index.jsx | 77 ++++++++++---- Client/src/Pages/PlayGround/PlayGround.jsx | 100 +++++++++++------- 3 files changed, 139 insertions(+), 66 deletions(-) diff --git a/Client/src/Components/TextFields/Field/index.css b/Client/src/Components/TextFields/Field/index.css index 08a22a384..802eff6b0 100644 --- a/Client/src/Components/TextFields/Field/index.css +++ b/Client/src/Components/TextFields/Field/index.css @@ -4,12 +4,14 @@ .field h3.MuiTypography-root, .field h5.MuiTypography-root, .field input, +.field textarea, .field .input-error { font-size: var(--env-var-font-size-medium); } .field h3.MuiTypography-root, .field h5.MuiTypography-root, -.field input { +.field input, +.field textarea { color: var(--env-var-color-5); } .field h3.MuiTypography-root { @@ -28,22 +30,42 @@ opacity: 0.8; padding-right: var(--env-var-spacing-1-minus); } -.field .MuiInputBase-root { +.field .MuiInputBase-root:has(input) { height: 34px; } .field .MuiInputBase-root:has(.MuiInputAdornment-root) { padding-right: var(--env-var-spacing-1-minus); } +.field .MuiInputBase-root:has(.MuiInputAdornment-root > .MuiButtonBase-root) { + padding-right: 0; +} +.field .MuiInputBase-root .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 .MuiInputAdornment-root .MuiButtonBase-root svg { + width: 20px; + height: 20px; + margin-right: 5px; +} +.field .MuiInputBase-root .MuiInputAdornment-root .MuiButtonBase-root:hover { + border-color: var(--env-var-color-29); +} .field input { height: 100%; padding: 0 var(--env-var-spacing-1-minus); } +.field .MuiInputBase-root:has(textarea) { + padding: 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:not(:has(.input-error)) - .MuiOutlinedInput-root:hover:not(:has(input:focus)) + .MuiOutlinedInput-root:hover:not(:has(input:focus)):not(:has(textarea:focus)) fieldset { border-color: var(--env-var-color-29); } diff --git a/Client/src/Components/TextFields/Field/index.jsx b/Client/src/Components/TextFields/Field/index.jsx index 7b4ad77af..8f84dbfec 100644 --- a/Client/src/Components/TextFields/Field/index.jsx +++ b/Client/src/Components/TextFields/Field/index.jsx @@ -8,7 +8,10 @@ import { } from "@mui/material"; import VisibilityOff from "@mui/icons-material/VisibilityOff"; import Visibility from "@mui/icons-material/Visibility"; +import ContentCopyIcon from "@mui/icons-material/ContentCopy"; +import Button from "../../Button"; import "./index.css"; +import { useState } from "react"; const Field = ({ type = "text", @@ -18,6 +21,7 @@ const Field = ({ isOptional, isVisible, setVisibility, + hasCopy, autoComplete, placeholder, value, @@ -27,6 +31,13 @@ const Field = ({ }) => { const theme = useTheme(); + // TODO - are we using this feature anywhere ? + const [copy, setCopy] = useState(false); + const handleCopy = () => { + setCopy(true); + setTimeout(() => setCopy(false), 1000); + }; + return ( {label && ( @@ -41,6 +52,8 @@ const Field = ({ id={id} autoComplete={autoComplete} placeholder={placeholder} + multiline={type === "description"} + rows={type === "description" ? 4 : 1} value={value} onChange={onChange} disabled={disabled} @@ -57,28 +70,48 @@ const Field = ({ https:// ), - endAdornment: type === "password" && ( - - setVisibility((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 ? : } - - - ), + endAdornment: + type === "password" ? ( + + setVisibility((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 && ( + +