|
1 | 1 | import React, { useState } from 'react' |
2 | 2 | import { Controller, useFormContext } from 'react-hook-form' |
3 | | -import { TextField } from '@mui/material' |
| 3 | +import { Button, TextField } from '@mui/material' |
4 | 4 |
|
5 | 5 | import { BridgeInputProps } from './bridge-input.types' |
6 | 6 | import { useBridgeInfo } from '@/hooks/use-bridge-info' |
@@ -105,54 +105,76 @@ export const BridgeInput = ({ fromNetwork, availableBalance, remainingDailyLimit |
105 | 105 | }, |
106 | 106 | }} |
107 | 107 | render={({ field }) => ( |
108 | | - <TextField |
109 | | - {...field} |
110 | | - type="number" |
111 | | - variant="standard" |
112 | | - placeholder="0" |
113 | | - error={Boolean(errors.amount)} |
114 | | - helperText={helperText as React.ReactNode} |
115 | | - onKeyDown={handleKeyDown} |
116 | | - onChange={handleChange(field.onChange)} |
117 | | - slotProps={{ |
118 | | - input: { |
119 | | - disableUnderline: true, |
120 | | - inputMode: 'decimal', |
121 | | - inputProps: { |
| 108 | + <div style={{ position: 'relative', width: '100%' }}> |
| 109 | + <TextField |
| 110 | + {...field} |
| 111 | + type="number" |
| 112 | + variant="standard" |
| 113 | + placeholder="0" |
| 114 | + error={Boolean(errors.amount)} |
| 115 | + helperText={helperText as React.ReactNode} |
| 116 | + onKeyDown={handleKeyDown} |
| 117 | + onChange={handleChange(field.onChange)} |
| 118 | + slotProps={{ |
| 119 | + input: { |
| 120 | + disableUnderline: true, |
| 121 | + inputMode: 'decimal', |
| 122 | + inputProps: { |
| 123 | + style: { |
| 124 | + fontSize: getFontSize(valueLength), |
| 125 | + fontWeight: 500, |
| 126 | + minWidth: '180px', |
| 127 | + width: '100%', |
| 128 | + paddingRight: '50px', // Make space for the MAX button |
| 129 | + padding: 0, |
| 130 | + appearance: 'textfield', |
| 131 | + }, |
| 132 | + }, |
122 | 133 | style: { |
123 | | - fontSize: getFontSize(valueLength), |
124 | | - fontWeight: 500, |
125 | | - minWidth: '180px', |
126 | | - width: '100%', |
127 | | - padding: 0, |
128 | | - appearance: 'textfield', |
| 134 | + display: 'flex', |
| 135 | + alignItems: 'center', |
| 136 | + height: '35px', |
| 137 | + paddingTop: '10px', |
129 | 138 | }, |
130 | 139 | }, |
131 | | - style: { |
132 | | - display: 'flex', |
133 | | - alignItems: 'center', |
134 | | - height: '35px', |
135 | | - paddingTop: '10px', |
136 | | - }, |
137 | | - }, |
138 | | - }} |
139 | | - sx={{ |
140 | | - '& .MuiInputBase-input': { |
141 | | - appearance: 'textfield', |
142 | | - '&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': { |
143 | | - appearance: 'none', |
144 | | - margin: 0, |
| 140 | + }} |
| 141 | + sx={{ |
| 142 | + '& .MuiInputBase-input': { |
| 143 | + appearance: 'textfield', |
| 144 | + '&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': { |
| 145 | + appearance: 'none', |
| 146 | + margin: 0, |
| 147 | + }, |
145 | 148 | }, |
146 | | - }, |
147 | | - '& .Mui-error': { |
148 | | - fontSize: '11px', |
149 | | - marginTop: '2px', |
150 | | - '@media (max-width:1280px)': { |
151 | | - fontSize: '9px', |
| 149 | + '& .Mui-error': { |
| 150 | + fontSize: '11px', |
| 151 | + marginTop: '2px', |
| 152 | + '@media (max-width:1280px)': { |
| 153 | + fontSize: '9px', |
| 154 | + }, |
152 | 155 | }, |
153 | | - }, |
154 | | - }} |
155 | | - /> |
| 156 | + }} |
| 157 | + /> |
| 158 | + <Button |
| 159 | + variant="text" |
| 160 | + size="small" |
| 161 | + onClick={() => field.onChange(String(availableBalance))} |
| 162 | + sx={{ |
| 163 | + position: 'absolute', |
| 164 | + right: 0, |
| 165 | + top: '50%', |
| 166 | + transform: 'translateY(-50%)', |
| 167 | + minWidth: 'unset', |
| 168 | + padding: '2px 5px', |
| 169 | + lineHeight: 1, |
| 170 | + fontSize: '12px', |
| 171 | + fontWeight: 600, |
| 172 | + color: 'primary.main', |
| 173 | + }} |
| 174 | + > |
| 175 | + MAX |
| 176 | + </Button> |
| 177 | + </div> |
156 | 178 | )} |
157 | 179 | /> |
158 | 180 | ) |
|
0 commit comments