Skip to content

Commit

Permalink
Add Word Number Labels to Mnemonic Inputs in Wallet Restoration Flow (#…
Browse files Browse the repository at this point in the history
…202)

* add word number label

* added space double digit

* add space single digit

* fix lint error

---------

Co-authored-by: Tomek Marciniak <[email protected]>
  • Loading branch information
aliraza556 and mrcnk authored Aug 21, 2024
1 parent 678ec59 commit a674fbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions packages/features/src/components/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type AutocompleteProps = {
autoFocus?: boolean
testId: string
inputProps: UseFormRegisterReturn
wordNumber: number
}

export const Autocomplete = ({
Expand All @@ -31,20 +32,28 @@ export const Autocomplete = ({
testId,
inputProps,
setValue,
wordNumber,
}: AutocompleteProps) => {
const filteredOptions = take(3, matchSorter(options, currentValue))
return (
<div className="dropdown">
<div className="dropdown relative">
<Combobox value={currentValue} onChange={setValue}>
<ComboboxInput
className="input text-sm w-full bg-[#413E5E]"
className={clsx(
"input text-sm w-full bg-[#413E5E] caret-[#eec382]",
wordNumber > 9 ? "pl-8" : "pl-6",
)}
placeholder={placeholder}
autoFocus={autoFocus}
onPaste={onPaste}
autoComplete="off"
data-testid={testId}
{...inputProps}
style={{ position: "relative" }}
/>
<span className="absolute left-2 top-1/2 transform -translate-y-1/2 text-[#afd9e2] pointer-events-none">
{wordNumber}.
</span>
<ComboboxOptions
className={clsx(
"dropdown-content z-10 menu shadow p-2 bg-secondary rounded-box w-28 empty:invisible",
Expand Down
3 changes: 2 additions & 1 deletion packages/features/src/onboarding/views/seed-import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const SeedImportView = ({
<Autocomplete
// biome-ignore lint: hardcoded
key={i}
placeholder={`${wordLabel}.`}
placeholder=""
options={wordlist}
autoFocus={i === 0}
currentValue={form.watch(`mnemonic.${i}`)}
Expand All @@ -70,6 +70,7 @@ export const SeedImportView = ({
form.setValue(`mnemonic.${i}`, newValue)
}
inputProps={form.register(`mnemonic.${i}`, { value: "" })}
wordNumber={wordLabel}
/>
))}
</div>
Expand Down

0 comments on commit a674fbc

Please sign in to comment.