Password peek
This commit is contained in:
+19
-2
@@ -7,6 +7,7 @@ import { useRouter } from "next/navigation";
|
|||||||
import { CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { loginUser } from "@/actions/user";
|
import { loginUser } from "@/actions/user";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
||||||
|
|
||||||
type Feedback = { kind: "error" | "info"; message: string };
|
type Feedback = { kind: "error" | "info"; message: string };
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ export default function Login() {
|
|||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [feedback, setFeedback] = useState<Feedback>();
|
const [feedback, setFeedback] = useState<Feedback>();
|
||||||
|
const [passwordVisible, setPasswordVisible] = useState(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -54,14 +56,29 @@ export default function Login() {
|
|||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
Password
|
Password
|
||||||
|
<div className="relative flex">
|
||||||
<Input
|
<Input
|
||||||
|
className="relative"
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === "Enter") login();
|
if (e.key === "Enter") login();
|
||||||
}}
|
}}
|
||||||
type="password"
|
type={passwordVisible ? "text" : "password"}
|
||||||
/>
|
/>
|
||||||
|
<div className="absolute w-full h-full flex items-center justify-end pr-3 pointer-events-none">
|
||||||
|
<div
|
||||||
|
className="pointer-events-auto cursor-pointer hover:text-primary transition-colors duration-500"
|
||||||
|
onClick={() => setPasswordVisible((prev) => !prev)}
|
||||||
|
>
|
||||||
|
{passwordVisible ? (
|
||||||
|
<EyeOffIcon className="w-4.5 left-full" />
|
||||||
|
) : (
|
||||||
|
<EyeIcon className="w-4.5 left-full" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{feedback && (
|
{feedback && (
|
||||||
@@ -76,7 +93,7 @@ export default function Login() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button className="mt-2" onClick={login}>
|
<Button className="mt-2 select-none" onClick={login}>
|
||||||
Login
|
Login
|
||||||
</Button>
|
</Button>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user