Refactored password visibility state and added small css fix

This commit is contained in:
Daniel Cojocea committed 2024-07-13 15:02:26 -04:00
1 parent 1e9bb5501e
commit 99b1130e29
7 files changed
+7 -31

No files matched your search

+3 -3
View File
@@ -36,16 +36,16 @@
.field .MuiInputBase-root:has(.MuiInputAdornment-root) {
padding-right: var(--env-var-spacing-1-minus);
}
.field .MuiInputBase-root:has(.MuiInputAdornment-root > .MuiButtonBase-root) {
.field .MuiInputBase-root:has(.copy.MuiInputAdornment-root > .MuiButtonBase-root) {
padding-right: 0;
}
.field .MuiInputBase-root .MuiInputAdornment-root .MuiButtonBase-root {
.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 .MuiInputAdornment-root .MuiButtonBase-root svg {
.field .MuiInputBase-root .copy.MuiInputAdornment-root .MuiButtonBase-root svg {
width: 20px;
height: 20px;
margin-right: 5px;
+4 -4
View File
@@ -19,8 +19,6 @@ const Field = ({
label,
isRequired,
isOptional,
isVisible,
setVisibility,
hasCopy,
autoComplete,
placeholder,
@@ -38,6 +36,8 @@ const Field = ({
setTimeout(() => setCopy(false), 1000);
};
const [isVisible, setVisible] = useState(false);
return (
<Stack gap={theme.gap.xs} className={`field field-${type}`}>
{label && (
@@ -75,7 +75,7 @@ const Field = ({
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={() => setVisibility((show) => !show)}
onClick={() => setVisible((show) => !show)}
tabIndex={-1}
sx={{
color: theme.palette.section.borderColor,
@@ -94,7 +94,7 @@ const Field = ({
</InputAdornment>
) : (
hasCopy && (
<InputAdornment position="end">
<InputAdornment className="copy" position="end">
<Button
level="tertiary"
label={copy ? "Copied" : "Copy"}