Skip to content

Commit

Permalink
fix: size of input
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Nov 28, 2023
1 parent 96077cc commit 39729fb
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion apps/common/components/TokenDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function Dropdown(props: TDropdownProps): ReactElement {
onClick={(): void => set_isOpen((o: boolean): boolean => !o)}
className={cl(
props.className,
'flex h-10 w-full items-center justify-between bg-neutral-0 p-2 text-base text-neutral-900 md:w-56 md:px-3'
'flex h-10 w-full items-center justify-between bg-neutral-0 p-2 text-base text-neutral-900 md:px-3'
)}>
<div className={'relative w-full'}>
<div className={'flex w-full items-center'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export function VaultDetailsQuickActionsFrom(): ReactElement {
function renderMultipleOptionsFallback(): ReactElement {
return (
<Dropdown
className={'!w-auto rounded-lg bg-neutral-300'}
comboboxOptionsClassName={'bg-neutral-300 rounded-lg'}
className={'!w-fit rounded-lg bg-neutral-300'}
comboboxOptionsClassName={'bg-neutral-300 rounded-lg w-full'}
defaultOption={possibleOptionsFrom[0]}
options={possibleOptionsFrom}
selected={actionParams?.selectedOptionFrom}
Expand All @@ -64,7 +64,7 @@ export function VaultDetailsQuickActionsFrom(): ReactElement {
return (
<section
id={isActive ? 'active' : 'not-active'}
className={'flex w-full flex-col space-x-0 md:flex-row md:space-x-4'}>
className={'grid w-full grid-cols-2 flex-col space-x-0 md:flex-row md:space-x-4'}>
<div className={'relative z-10 w-full'}>
<div className={'flex flex-col items-baseline justify-between pb-2 pl-1 md:flex-row'}>
<p className={'text-base text-neutral-600'}>{isDepositing ? 'From wallet' : 'From vault'}</p>
Expand All @@ -82,7 +82,7 @@ export function VaultDetailsQuickActionsFrom(): ReactElement {
fallback={renderMultipleOptionsFallback()}>
<div
className={
'flex h-10 w-full items-center justify-between rounded-lg bg-neutral-300 px-2 text-base text-neutral-900 md:w-56 md:px-3'
'flex h-10 w-full items-center justify-between rounded-lg bg-neutral-300 px-2 text-base text-neutral-900 md:px-3'
}>
<div className={'relative flex flex-row items-center truncate'}>
<div className={'h-6 w-6 flex-none rounded-full'}>{selectedFromIcon}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function VaultDetailsQuickActionsTo(): ReactElement {
fallback={renderMultipleOptionsFallback()}>
<div
className={
'flex h-10 w-full items-center justify-between rounded-lg bg-neutral-300 px-2 text-base text-neutral-900 md:w-56 md:px-3'
'flex h-10 w-full items-center justify-between rounded-lg bg-neutral-300 px-2 text-base text-neutral-900 md:px-3'
}>
<div className={'relative flex flex-row items-center truncate'}>
<div className={'h-6 w-6 flex-none rounded-full'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export function VaultsListInternalMigrationRow({currentVault}: {currentVault: TY
{'To keep earning yield on your assets, migrate to the current vault.'}
</div>

<div className={'mt-6 flex w-full items-center md:ml-auto md:mt-0 md:w-56 md:justify-end'}>
<div className={'mt-6 flex w-full items-center md:ml-auto md:mt-0 md:justify-end'}>
<Link
className={'w-full'}
href={`/vaults/${currentVault.chainID}/${toAddress(currentVault.address)}`}>
<button
className={cl(
'rounded-lg overflow-hidden flex',
'px-4 py-2 w-full md:w-56',
'px-4 py-2 w-full',
'relative group',
'border-none'
)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function VaultDetailsQuickActionsFrom(): ReactElement {
fallback={renderMultipleOptionsFallback()}>
<div
className={
'flex h-10 w-full items-center justify-between bg-neutral-300 px-2 text-base text-neutral-900 md:w-56 md:px-3'
'flex h-10 w-full items-center justify-between bg-neutral-300 px-2 text-base text-neutral-900 md:px-3'
}>
<div className={'relative flex flex-row items-center truncate'}>
<div className={'h-6 w-6 flex-none rounded-full'}>{selectedFromIcon}</div>
Expand Down
41 changes: 19 additions & 22 deletions apps/vaults/contexts/useActionFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {decodeAsBigInt} from '@yearn-finance/web-lib/utils/decoder';
import {toBigInt, toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber';
import {isEth} from '@yearn-finance/web-lib/utils/isEth';
import {isZero} from '@yearn-finance/web-lib/utils/isZero';
import {performBatchedUpdates} from '@yearn-finance/web-lib/utils/performBatchedUpdates';
import {getNetwork} from '@yearn-finance/web-lib/utils/wagmi/utils';
import {useWallet} from '@common/contexts/useWallet';
import {useYearn} from '@common/contexts/useYearn';
Expand Down Expand Up @@ -306,29 +305,27 @@ export function ActionFlowContextApp({
}

if (nextFlow === Flow.Switch) {
performBatchedUpdates((): void => {
const _selectedOptionTo = actionParams?.selectedOptionTo;
const _possibleOptionsTo = possibleOptionsTo;
let _selectedOptionFrom = actionParams?.selectedOptionFrom;
if (isDepositing && (actionParams?.selectedOptionFrom?.solveVia || []).length > 0) {
// We don't want to be able to withdraw to exotic tokens. If the current from is one of them, take another one.
_selectedOptionFrom = possibleOptionsFrom.find(
(option: TDropdownOption): boolean =>
option.value !== actionParams?.selectedOptionFrom?.value &&
isZero((option.solveVia || []).length)
);
const _selectedOptionTo = actionParams?.selectedOptionTo;
const _possibleOptionsTo = possibleOptionsTo;
let _selectedOptionFrom = actionParams?.selectedOptionFrom;
if (isDepositing && (actionParams?.selectedOptionFrom?.solveVia || []).length > 0) {
// We don't want to be able to withdraw to exotic tokens. If the current from is one of them, take another one.
_selectedOptionFrom = possibleOptionsFrom.find(
(option: TDropdownOption): boolean =>
option.value !== actionParams?.selectedOptionFrom?.value &&
isZero((option.solveVia || []).length)
);
}
actionParamsDispatcher({
type: 'all',
payload: {
selectedOptionFrom: _selectedOptionTo,
selectedOptionTo: _selectedOptionFrom,
amount: isDepositing ? toNormalizedBN(0) : maxDepositPossible
}
actionParamsDispatcher({
type: 'all',
payload: {
selectedOptionFrom: _selectedOptionTo,
selectedOptionTo: _selectedOptionFrom,
amount: isDepositing ? toNormalizedBN(0) : maxDepositPossible
}
});
set_possibleOptionsTo(possibleOptionsFrom);
set_possibleOptionsFrom(_possibleOptionsTo);
});
set_possibleOptionsTo(possibleOptionsFrom);
set_possibleOptionsFrom(_possibleOptionsTo);
}

const vaultUnderlying = setZapOption({
Expand Down
21 changes: 12 additions & 9 deletions apps/vaults/contexts/useSolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {serialize} from '@wagmi/core';
import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3';
import {toAddress} from '@yearn-finance/web-lib/utils/address';
import {toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber';
import {performBatchedUpdates} from '@yearn-finance/web-lib/utils/performBatchedUpdates';
import {Solver} from '@common/schemas/yDaemonTokenListBalances';
import {hash} from '@common/utils';

Expand Down Expand Up @@ -80,14 +79,12 @@ export function WithSolverContextApp({children}: {children: React.ReactElement})
return;
}
const requestHash = await hash(serialize({...request, solver, expectedOut: quote.value.raw}));
performBatchedUpdates((): void => {
set_currentSolverState({
...ctx,
quote: quote.value,
hash: requestHash
});
set_isLoading(false);
set_currentSolverState({
...ctx,
quote: quote.value,
hash: requestHash
});
set_isLoading(false);
},
[executionNonce]
);
Expand All @@ -104,6 +101,10 @@ export function WithSolverContextApp({children}: {children: React.ReactElement})
) {
return;
}
if (actionParams.amount.raw === 0n) {
return set_currentSolverState({...vanilla, quote: toNormalizedBN(0)});
}

set_isLoading(true);

const request: TInitSolverArgs = {
Expand Down Expand Up @@ -263,6 +264,9 @@ export function WithSolverContextApp({children}: {children: React.ReactElement})
actionParams.selectedOptionFrom,
actionParams.selectedOptionTo,
actionParams.amount.raw,
currentVault.chainID,
currentVault.version,
currentVault.migration.contract,
address,
isDepositing,
currentSolver,
Expand All @@ -274,7 +278,6 @@ export function WithSolverContextApp({children}: {children: React.ReactElement})
optimismBooster,
chainCoin,
partnerContract,
currentVault.migration.contract,
internalMigration
]
);
Expand Down

0 comments on commit 39729fb

Please sign in to comment.