-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve UX of token list modal (#330)
- Autofocus text input field - Make appearance more consistent with chain picker - Hide disabled tokens by default
- Loading branch information
Showing
5 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import clsx from 'clsx'; | ||
import { Field, FieldAttributes } from 'formik'; | ||
import { ChangeEvent, InputHTMLAttributes } from 'react'; | ||
import { ChangeEvent, InputHTMLAttributes, Ref, forwardRef } from 'react'; | ||
|
||
export function TextField({ classes, ...props }: FieldAttributes<{ classes: string }>) { | ||
return <Field className={`${defaultInputClasses} ${classes}`} {...props} />; | ||
export function TextField({ className, ...props }: FieldAttributes<unknown>) { | ||
return <Field className={clsx(defaultClassName, className)} {...props} />; | ||
} | ||
|
||
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & { | ||
onChange: (v: string) => void; | ||
classes?: string; | ||
}; | ||
|
||
export function TextInput({ onChange, classes, ...props }: InputProps) { | ||
export const TextInput = forwardRef(function _TextInput( | ||
{ onChange, className, ...props }: InputProps, | ||
ref: Ref<HTMLInputElement>, | ||
) { | ||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
onChange(e?.target?.value || ''); | ||
}; | ||
return ( | ||
<input | ||
ref={ref} | ||
type="text" | ||
autoComplete="off" | ||
onChange={handleChange} | ||
className={`${defaultInputClasses} ${classes}`} | ||
className={clsx(defaultClassName, className)} | ||
{...props} | ||
/> | ||
); | ||
} | ||
}); | ||
|
||
const defaultInputClasses = | ||
const defaultClassName = | ||
'mt-1.5 px-2.5 py-2.5 text-sm rounded-lg border border-primary-300 focus:border-primary-500 disabled:bg-gray-150 outline-none transition-all duration-300'; |
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
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