diff --git a/src/components/loginform/loginForm.jsx b/src/components/loginform/loginForm.jsx index 218201d..cc3a47f 100644 --- a/src/components/loginform/loginForm.jsx +++ b/src/components/loginform/loginForm.jsx @@ -9,7 +9,6 @@ import { AuthContext } from "../../contexts/auth/AuthContext.js"; function LoginForm({ className }) { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); - const [showPassword, setShowPassword] = useState(false); let navigate = useNavigate(); const { login } = useContext(AuthContext); @@ -19,10 +18,6 @@ function LoginForm({ className }) { navigate("/"); } - const toggleShowPassword = () => { - setShowPassword(!showPassword); - }; - return (
@@ -35,32 +30,7 @@ function LoginForm({ className }) { />
-
- setPassword(e.target.value)} - style={{ width: '100%' }} - /> - -
+ setPassword(e.target.value)} value={password} />
diff --git a/src/components/ui/input/input.jsx b/src/components/ui/input/input.jsx index c756a3e..0218b3e 100644 --- a/src/components/ui/input/input.jsx +++ b/src/components/ui/input/input.jsx @@ -1,13 +1,38 @@ import styles from "./input.module.css"; +import { useState } from "react"; -const TextInput = ({ placeholder, onChange, value, borderStyle, ...props }) => { +const TextInput = ({ placeholder, onChange, value, borderStyle, password, className, ...props }) => { + const [showPassword, setShowPassword] = useState(false); let inputBorderStyle = styles.square; if (borderStyle === "square") inputBorderStyle = styles.square; if(borderStyle === "rounded") inputBorderStyle = styles.rounded; - return + const toggleShowPassword = () => { + setShowPassword(!showPassword); + }; + + if(password) return ( +
+ + +
+ ); + + return }; export default TextInput; diff --git a/src/components/ui/input/input.module.css b/src/components/ui/input/input.module.css index eaafa25..e56ef67 100644 --- a/src/components/ui/input/input.module.css +++ b/src/components/ui/input/input.module.css @@ -30,3 +30,23 @@ border-radius: 12px; } +.passwordContainer { + position: relative; + width: 100%; +} + +.passwordInput { + width: 100%; +} + +.passwordBtn { + position: absolute; + width: 30px; + right: 10px; + top: 50%; + transform: translateY(-50%); + background: none; + border: none; + cursor: pointer; + font-size: 16px; +}