Skip to content

Commit

Permalink
fix: width of price impact speedbump (#557)
Browse files Browse the repository at this point in the history
* fix: width of price impact speedbump

* fix: rename const
  • Loading branch information
just-toby authored Mar 16, 2023
1 parent 7bae76a commit 14b32b4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export enum DialogAnimationType {
NONE = 'none',
}

export const MIN_PAGE_CENTERED_DIALOG_WIDTH = 400

const Context = createContext({
element: null as HTMLElement | null,
options: {} as DialogOptions | undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Swap/Speedbump/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const SpeedBumpWrapper = styled(Column)`
display: flex;
height: 100%;
justify-content: space-between;
max-width: 420px;
padding: 1rem;
text-align: center;
`
Expand All @@ -28,7 +29,6 @@ const SpeedbumpButtonStyle = css`
padding: 1rem;
`
const HeaderRow = styled(Row)`
align-items: flex-start;
width: 100%;
`

Expand Down Expand Up @@ -56,7 +56,7 @@ export default function SpeedBumpDialog({ onAcknowledge, children }: PropsWithCh
return (
<SpeedBumpWrapper>
<Column flex gap={0.75}>
<HeaderRow>
<HeaderRow flex align="center" justify="flex-end">
<StyledXButton onClick={onClose} />
</HeaderRow>
<IconWrapper>
Expand Down
25 changes: 13 additions & 12 deletions src/components/Swap/Summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { formatPriceImpact } from '@uniswap/conedison/format'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import ActionButton, { Action, ActionButtonColor } from 'components/ActionButton'
import Column from 'components/Column'
import { Header, useCloseDialog, useIsDialogPageCentered } from 'components/Dialog'
import { Header, MIN_PAGE_CENTERED_DIALOG_WIDTH, useCloseDialog, useIsDialogPageCentered } from 'components/Dialog'
import { PopoverBoundaryProvider } from 'components/Popover'
import { SmallToolTipBody, TooltipText } from 'components/Tooltip'
import { UserRejectedRequestError } from 'errors'
Expand Down Expand Up @@ -287,24 +287,25 @@ export function SummaryDialog(props: SummaryDialogProps) {
}, [ackPriceImpact, props.impact, showSpeedbump])

return (
<>
<Column
style={{ minWidth: isPageCentered ? Math.min(MIN_PAGE_CENTERED_DIALOG_WIDTH, width) : 'auto', height: '100%' }}
ref={setBoundary}
>
{showSpeedbump && props.impact ? (
<SpeedBumpDialog onAcknowledge={onAcknowledgeSpeedbump}>
{t`This transaction will result in a`}{' '}
<PriceImpactText>{formatPriceImpact(props.impact?.percent)} </PriceImpactText>
{t`price impact on the market price of this pool. Do you wish to continue? `}
</SpeedBumpDialog>
) : (
<Column style={{ minWidth: isPageCentered ? Math.min(400, width) : 'auto', height: '100%' }} ref={setBoundary}>
<PopoverBoundaryProvider value={boundary}>
<Header title={<Trans>Review swap</Trans>} />
<Body flex align="stretch">
<Details {...props} />
</Body>
<ConfirmButton {...props} triggerImpactSpeedbump={triggerImpactSpeedbump} />
</PopoverBoundaryProvider>
</Column>
<PopoverBoundaryProvider value={boundary}>
<Header title={<Trans>Review swap</Trans>} />
<Body flex align="stretch">
<Details {...props} />
</Body>
<ConfirmButton {...props} triggerImpactSpeedbump={triggerImpactSpeedbump} />
</PopoverBoundaryProvider>
)}
</>
</Column>
)
}
2 changes: 1 addition & 1 deletion src/components/Swap/Toolbar/ToolbarContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export function Provider({ children }: PropsWithChildren) {
[Field.INPUT]: { currency: inputCurrency },
[Field.OUTPUT]: { currency: outputCurrency },
} = useSwapInfo()

const isWrap = useIsWrap()

useEffect(() => {
if (isWrap) {
collapse()
Expand Down

1 comment on commit 14b32b4

@vercel
Copy link

@vercel vercel bot commented on 14b32b4 Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

widgets – ./

widgets-git-main-uniswap.vercel.app
widgets-seven-tau.vercel.app
widgets-uniswap.vercel.app

Please sign in to comment.