📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Add eye icon for password input fields
Blue Mouse8682384b8287
diff --git a/web/app/ui/Input.tsx b/web/app/ui/Input.tsxindex c7407322e..0a7834fad 100644--- a/web/app/ui/Input.tsx+++ b/web/app/ui/Input.tsx@@ -1,7 +1,8 @@import { Description, Field, Input as HeadlessInput, Label } from '@headlessui/react'import cx from 'clsx'import _isEmpty from 'lodash/isEmpty'-import React, { memo } from 'react'+import { Eye, EyeOff } from 'lucide-react'+import React, { memo, useState } from 'react'interface InputProps {label?: React.ReactNode@@ -29,6 +30,29 @@ const Input = ({}: InputProps & React.InputHTMLAttributes<HTMLInputElement>) => {const isError = !_isEmpty(error)const type = rest.type || 'text'+ const isPassword = type === 'password'+ const [showPassword, setShowPassword] = useState(false)++ const { type: _type, ...restWithoutType } = rest++ const inputElement = (+ <HeadlessInput+ className={cx(+ 'w-full rounded-md border-0 ring-1 focus:ring-indigo-500 sm:text-sm dark:bg-slate-800 dark:text-gray-50 dark:placeholder-gray-400',+ {+ 'text-red-900 placeholder-red-300 ring-red-600': isError,+ 'ring-gray-300 dark:ring-slate-800/50': !isError,+ 'cursor-text': disabled,+ 'pr-10': isPassword,+ },+ classes?.input,+ )}+ disabled={disabled}+ invalid={isError}+ {...restWithoutType}+ type={isPassword && showPassword ? 'text' : type}+ />+ )return (<Field as='div' className={className}>@@ -36,21 +60,20 @@ const Input = ({{hint && hintPosition === 'top' ? (<Description className='mt-1 text-sm whitespace-pre-line text-gray-500 dark:text-gray-300'>{hint}</Description>) : null}- <HeadlessInput- type={type}- className={cx(- 'w-full rounded-md border-0 ring-1 focus:ring-indigo-500 sm:text-sm dark:bg-slate-800 dark:text-gray-50 dark:placeholder-gray-400',- {- 'text-red-900 placeholder-red-300 ring-red-600': isError,- 'ring-gray-300 dark:ring-slate-800/50': !isError,- 'cursor-text': disabled,- },- classes?.input,- )}- disabled={disabled}- invalid={isError}- {...rest}- />+ {isPassword ? (+ <div className='relative'>+ {inputElement}+ <button+ type='button'+ onClick={() => setShowPassword(!showPassword)}+ className='absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'+ >+ {showPassword ? <EyeOff className='size-5' /> : <Eye className='size-5' />}+ </button>+ </div>+ ) : (+ inputElement+ )}{isError ? <p className='mt-2 text-sm text-red-600 dark:text-red-500'>{error}</p> : null}{hint && hintPosition === 'bottom' ? (<Description className='mt-2 text-sm whitespace-pre-line text-gray-500 dark:text-gray-300'>{hint}</Description>