forked from NangoHQ/nango
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hide secrets by default (NangoHQ#553)
- Loading branch information
1 parent
45bee9a
commit 8d55bf8
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { forwardRef, useCallback, useState } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
const SecretInput = forwardRef<HTMLInputElement, JSX.IntrinsicElements['input']>(function PasswordField({ className, ...props }, ref) { | ||
const [isSecretVisible, setIsSecretVisible] = useState(false); | ||
|
||
const toggleSecretVisibility = useCallback(() => setIsSecretVisible(!isSecretVisible), [isSecretVisible, setIsSecretVisible]); | ||
|
||
return ( | ||
<div className="relative"> | ||
<input | ||
type={isSecretVisible ? 'text' : 'password'} | ||
ref={ref} | ||
className={classNames( | ||
'border-border-gray bg-bg-black text-text-light-gray focus:border-white focus:ring-white block h-11 w-full appearance-none rounded-md border px-3 py-2 text-base placeholder-gray-400 shadow-sm focus:outline-none', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
<label | ||
className="absolute right-4 top-2 bg-gray-300 hover:bg-gray-400 rounded px-2 py-1 text-sm text-gray-600 cursor-pointer" | ||
onClick={toggleSecretVisibility} | ||
> | ||
{isSecretVisible ? 'hide' : 'show'} | ||
</label> | ||
</div> | ||
); | ||
}); | ||
|
||
export default SecretInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters