Skip to content

Commit

Permalink
Unlock by pressing enter (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolgahan-arikan authored Nov 11, 2024
1 parent 7475e0f commit 620136d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/PasswordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextInput } from '@0xsequence/design-system'
import { ChangeEvent, useState } from 'react'
import { ChangeEvent, KeyboardEvent, useState } from 'react'

import passwordEyeOff from '../assets/images/password-eye-off.svg'
import passwordEye from '../assets/images/password-eye.svg'
Expand All @@ -8,13 +8,15 @@ interface TextInputWrapperProps {
label: string
labelLocation?: 'top' | 'left' | 'right' | 'bottom' // Optional prop for label location
value: string
onKeyPress: (ev: KeyboardEvent<HTMLInputElement>) => void
onChange: (ev: ChangeEvent<HTMLInputElement>) => void
}

export const PasswordInput: React.FC<TextInputWrapperProps> = ({
label,
labelLocation = 'top',
value,
onKeyPress,
onChange
}) => {
const [showPassword, setShowPassword] = useState(false)
Expand All @@ -31,6 +33,7 @@ export const PasswordInput: React.FC<TextInputWrapperProps> = ({
label={label}
labelLocation={labelLocation}
value={value}
onKeyPress={onKeyPress}
onChange={onChange}
/>
<button
Expand Down
5 changes: 5 additions & 0 deletions src/routes/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ function Landing() {
<PasswordInput
label="Password"
value={password}
onKeyPress={ev => {
if (ev.key === 'Enter') {
handleUnlock()
}
}}
onChange={(ev: ChangeEvent<HTMLInputElement>) => {
setPassword(ev.target.value)
setWrongPassword(false)
Expand Down

0 comments on commit 620136d

Please sign in to comment.