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 { .input {
all: unset; all: unset;
padding: 0 0.75rem; padding: 0 0.5rem;
text-align: center; text-align: center;
border-right: 1px solid rgba(var(--foreground-rgb), 0.15); border-right: 1px solid rgba(var(--foreground-rgb), 0.15);
} }

View File

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

View File

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

View File

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