mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 14:49:43 +02:00
Add visibility toggle of password input. Closes #2
This commit is contained in:
parent
a11f6260c0
commit
00c7f514ae
25 changed files with 111 additions and 92 deletions
22
client/src/lib/custom-ui/components/Input/InputPassword.jsx
Normal file
22
client/src/lib/custom-ui/components/Input/InputPassword.jsx
Normal file
|
@ -0,0 +1,22 @@
|
|||
import React, { useCallback } from 'react';
|
||||
import { Icon, Input } from 'semantic-ui-react';
|
||||
import { useToggle } from '../../../hooks';
|
||||
|
||||
const InputPassword = React.forwardRef((props, ref) => {
|
||||
const [isHidden, toggleHidden] = useToggle(true);
|
||||
|
||||
const handleToggleClick = useCallback(() => {
|
||||
toggleHidden();
|
||||
}, [toggleHidden]);
|
||||
|
||||
return (
|
||||
<Input
|
||||
{...props} // eslint-disable-line react/jsx-props-no-spreading
|
||||
ref={ref}
|
||||
type={isHidden ? 'password' : 'text'}
|
||||
icon={<Icon link name={isHidden ? 'eye slash' : 'eye'} onClick={handleToggleClick} />}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export default React.memo(InputPassword);
|
Loading…
Add table
Add a link
Reference in a new issue