auto-growing token select

* closes #6
This commit is contained in:
Matthias Kretschmann 2024-04-06 13:55:43 +01:00
parent 0c3eecd681
commit 7fb3c95822
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 18 additions and 11 deletions

View File

@ -1,6 +1,6 @@
.input {
all: unset;
padding: 0 0.75rem;
padding: 0 0.5rem;
text-align: center;
border-right: 1px solid rgba(var(--foreground-rgb), 0.15);
}

View File

@ -5,7 +5,7 @@
.select {
display: inline-block;
all: unset;
padding: 0 0.75rem;
padding: 0 0.5rem;
}
.select:hover:not(.select[disabled]) {

View File

@ -46,9 +46,7 @@ export function FormAmount({
pattern="[0-9]*"
value={amount}
onChange={handleAmountChange}
style={{
width: Math.min(Math.max(amount.toString().length, 2), 50) + 'ch'
}}
style={{ width: amount.toString().length + 'ch' }}
/>
<Select
@ -56,7 +54,15 @@ export function FormAmount({
value={token}
onChange={handleTokenChange}
disabled={!setToken}
style={setToken ? { paddingRight: '1.25rem' } : {}}
style={
setToken
? {
paddingRight: '1.2rem',
width: `calc(${token.length + 'em'} - 1.75rem)`,
minWidth: '1.85rem'
}
: undefined
}
/>
</FormInline>
)

View File

@ -2,6 +2,11 @@ import { Dispatch, SetStateAction } from 'react'
import { Select, FormInline } from '@/components'
import { type Market } from '@/features/strategies'
const options = [
{ value: 'market', label: 'All Markets' },
{ value: 'uniswap-v3', label: 'Uniswap v3' }
]
export function FormMarket({
market,
setMarket
@ -9,17 +14,13 @@ export function FormMarket({
market: Market
setMarket: Dispatch<SetStateAction<Market>>
}) {
const options = [
{ value: 'market', label: 'All Markets' },
{ value: 'uniswap-v3', label: 'Uniswap v3' }
]
return (
<FormInline>
<Select
options={options}
value={market}
onChange={(e) => setMarket(e.target.value as Market)}
style={{ paddingRight: '1.25rem' }}
style={{ paddingRight: '1.2rem' }}
/>
</FormInline>
)