Skip to content

Commit

Permalink
Change receiver input to textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Oct 22, 2024
1 parent 4bf06d9 commit c74c43d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,9 @@
justify-content: space-between;
margin-top: rem(12px);
}

textarea {
resize: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ const InputClear = forwardRef<HTMLInputElement, AmountInputProps>(

const FormInputClear = makeUncontrolled(InputClear);

type ReceiverInputProps = Pick<
InputHTMLAttributes<HTMLTextAreaElement>,
'className' | 'value' | 'onChange' | 'onBlur' | 'autoFocus'
> &
RequiredUncontrolledFieldProps<HTMLInputElement>;

/**
* @description
* Use as a normal \<textarea /\>.
*/
const ReceiverInput = forwardRef<HTMLTextAreaElement, ReceiverInputProps>(({ error, className, ...props }, ref) => {
return (
<textarea
className={clsx('token-amount_field', error !== undefined && 'token-amount_field--invalid', className)}
ref={ref}
autoComplete="off"
spellCheck="false"
{...props}
/>
);
});

const FormReceiverInput = makeUncontrolled(ReceiverInput);

const parseTokenSelectorId = (value: string): null | CIS2.TokenAddress => {
if (value.startsWith('ccd')) {
return null;
Expand Down Expand Up @@ -335,7 +359,7 @@ export default function TokenAmountView(props: TokenAmountViewProps) {
selectedToken={selectedToken}
onSelect={handleTokenSelect}
tokens={tokens}
selectedTokenBalance={availableAmount}
selectedTokenBalance={balance}
formatAmount={formatAmount}
/>
) : (
Expand All @@ -344,7 +368,7 @@ export default function TokenAmountView(props: TokenAmountViewProps) {
onSelect={handleTokenSelect}
tokens={tokens}
canSelect
selectedTokenBalance={availableAmount}
selectedTokenBalance={balance}
formatAmount={formatAmount}
/>
)}
Expand Down Expand Up @@ -377,10 +401,7 @@ export default function TokenAmountView(props: TokenAmountViewProps) {
{props.receiver === true && (
<div className="token-amount_receiver">
<span className="text__main_medium">{t('form.tokenAmount.address.label')}</span>
{/* TODO: Figure out what to do with overflowing text?
1. multiline <input type="text">
2. show abbreviated version on blur */}
<FormInputClear
<FormReceiverInput
className="text__main"
register={(props.form as UseFormReturn<AmountReceiveForm>).register}
name="receiver"
Expand Down

0 comments on commit c74c43d

Please sign in to comment.