add show-password-button for login form
This commit is contained in:
@@ -98,7 +98,7 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
right: 7px;
|
right: 6px;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import styles from '@/app/styles/login.module.scss'
|
import styles from '@/app/styles/login.module.scss'
|
||||||
import { useActionState } from 'react';
|
import { useActionState, useState } from 'react';
|
||||||
import { authorization } from '@/app/actions/auth';
|
import { authorization } from '@/app/actions/auth';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { IconEye } from '@/app/ui/icons/icons';
|
||||||
|
|
||||||
export default function LoginForm() {
|
export default function LoginForm() {
|
||||||
const [state, formAction, isPending] = useActionState(
|
const [state, formAction, isPending] = useActionState(
|
||||||
@@ -12,6 +13,20 @@ export default function LoginForm() {
|
|||||||
);
|
);
|
||||||
const t = useTranslations('Login-register-form');
|
const t = useTranslations('Login-register-form');
|
||||||
|
|
||||||
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
|
||||||
|
function handleMouseDown() {
|
||||||
|
setShowPassword(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseUp() {
|
||||||
|
setShowPassword(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseOut() {
|
||||||
|
setShowPassword(false);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form action={formAction}>
|
<form action={formAction}>
|
||||||
<div className={`${styles['form-group']}`}>
|
<div className={`${styles['form-group']}`}>
|
||||||
@@ -36,13 +51,24 @@ export default function LoginForm() {
|
|||||||
<label className={`${styles['form-label']}`}>
|
<label className={`${styles['form-label']}`}>
|
||||||
{t('password')}
|
{t('password')}
|
||||||
</label>
|
</label>
|
||||||
|
<div className={`${styles['password-wrapper']}`}>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type={showPassword ? "text" : "password"}
|
||||||
id="password"
|
id="password"
|
||||||
name="password"
|
name="password"
|
||||||
className={`${styles['form-input']}`}
|
className={`${styles['form-input']}`}
|
||||||
placeholder={t('enter-password')}
|
placeholder={t('enter-password')}
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
onMouseDown={handleMouseDown}
|
||||||
|
onMouseUp={handleMouseUp}
|
||||||
|
onMouseOut={handleMouseOut}
|
||||||
|
type="button"
|
||||||
|
className={`show-password-button ${showPassword ? 'show' : ''}`}
|
||||||
|
>
|
||||||
|
<IconEye />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{state?.error?.password && (
|
{state?.error?.password && (
|
||||||
<p className={`${styles['form-error']}`}>
|
<p className={`${styles['form-error']}`}>
|
||||||
{t(state?.error?.password)}
|
{t(state?.error?.password)}
|
||||||
|
|||||||
Reference in New Issue
Block a user