diff --git a/src/components/Inputs/DepositAmountInput/DepositAmountInput.tsx b/src/components/Inputs/DepositAmountInput/DepositAmountInput.tsx index ef2f218e5..137167178 100644 --- a/src/components/Inputs/DepositAmountInput/DepositAmountInput.tsx +++ b/src/components/Inputs/DepositAmountInput/DepositAmountInput.tsx @@ -21,6 +21,7 @@ interface IProps { balanceValue?: string disabled?: boolean priceLoading?: boolean + isBalanceLoading: boolean } export const DepositAmountInput: React.FC = ({ @@ -38,7 +39,8 @@ export const DepositAmountInput: React.FC = ({ tokenPrice, balanceValue, disabled = false, - priceLoading = false + priceLoading = false, + isBalanceLoading }) => { const classes = useStyles() @@ -145,6 +147,13 @@ export const DepositAmountInput: React.FC = ({ const usdBalance = tokenPrice && balanceValue ? tokenPrice * +balanceValue : 0 + const formattedBalance = currency + ? `${ + balanceValue + ? formatNumbers(thresholds)(balanceValue) + showPrefix(Number(balanceValue)) + : '0' + } ${currency}` + : '- -' return (
@@ -199,14 +208,11 @@ export const DepositAmountInput: React.FC = ({ <> Balance:{' '} - {currency - ? `${ - balanceValue - ? formatNumbers(thresholds)(balanceValue) + - showPrefix(Number(balanceValue)) - : '0' - } ${currency}` - : '- -'} + {isBalanceLoading ? ( + + ) : ( + <>{' '.concat(formattedBalance)} + )} + + {address !== '' ? ( = ({ concentrationIndex={concentrationIndex} minimumSliderIndex={minimumSliderIndex} positionOpeningMethod={positionOpeningMethod} + setShouldResetPlot={setShouldResetPlot} + isBalanceLoading={isBalanceLoading} /> {isCurrentPoolExisting || @@ -653,6 +685,8 @@ export const NewPosition: React.FC = ({ concentrationIndex={concentrationIndex} minimumSliderIndex={minimumSliderIndex} getTicksInsideRange={getTicksInsideRange} + shouldResetPlot={shouldResetPlot} + setShouldResetPlot={setShouldResetPlot} /> ) : ( void } export const RangeSelector: React.FC = ({ @@ -79,6 +81,8 @@ export const RangeSelector: React.FC = ({ hasTicksError, reloadHandler, volumeRange, + shouldResetPlot, + setShouldResetPlot, concentrationArray, minimumSliderIndex, concentrationIndex, @@ -245,10 +249,11 @@ export const RangeSelector: React.FC = ({ }, [currentPairReversed]) useEffect(() => { - if (ticksLoading && isMountedRef.current) { + if (ticksLoading && shouldResetPlot && midPrice.index !== 0 && isMountedRef.current) { resetPlot() + setShouldResetPlot(false) } - }, [ticksLoading, midPrice]) + }, [ticksLoading, midPrice, poolIndex]) const autoZoomHandler = (left: number, right: number, canZoomCloser: boolean = false) => { const leftX = calcPrice(left, isXtoY, xDecimal, yDecimal) diff --git a/src/components/NewPosition/style.ts b/src/components/NewPosition/style.ts index 23895a1dd..44181fba7 100644 --- a/src/components/NewPosition/style.ts +++ b/src/components/NewPosition/style.ts @@ -28,7 +28,6 @@ const useStyles = makeStyles((theme: Theme) => ({ title: { color: colors.white.main, ...typography.heading4, - marginBottom: 18, [theme.breakpoints.down('xs')]: { fontSize: 18 @@ -85,11 +84,56 @@ const useStyles = makeStyles((theme: Theme) => ({ }, options: { width: 'fit-content', - marginBottom: 18, + marginBottom: 16, height: 28 }, switch: { transition: 'opacity 500ms' + }, + jupiterIcon: { + cursor: 'pointer', + transition: 'filter 100ms', + '&:hover': { + filter: 'brightness(1.5)' + } + }, + refreshIconBtn: { + padding: 0, + margin: 0, + minWidth: 'auto', + background: 'none', + marginRight: 7, + '&:hover': { + background: 'none' + }, + '&:disabled': { + opacity: 0.5 + } + }, + refreshIcon: { + width: 26, + height: 21, + cursor: 'pointer', + transition: 'filter 100ms', + '&:hover': { + filter: 'brightness(1.5)' + } + }, + subHeader: { + alignItems: 'center', + + [theme.breakpoints.down('sm')]: { + justifyContent: 'flex-start' + } + }, + leftSideSubHeader: { + marginBottom: 16, + width: 'calc(50% - 12px)', + + [theme.breakpoints.down('sm')]: { + flex: 'initial', + width: 'auto' + } } })) diff --git a/src/components/PositionDetails/PositionDetails.tsx b/src/components/PositionDetails/PositionDetails.tsx index 96ce0a25c..e455c9be6 100644 --- a/src/components/PositionDetails/PositionDetails.tsx +++ b/src/components/PositionDetails/PositionDetails.tsx @@ -13,6 +13,7 @@ import { Link, useHistory } from 'react-router-dom' import { ILiquidityToken } from './SinglePositionInfo/consts' import SinglePositionPlot from './SinglePositionPlot/SinglePositionPlot' import useStyles from './style' +import refreshIcon from '@static/svg/refresh.svg' import MarketIdLabel from '@components/NewPosition/MarketIdLabel/MarketIdLabel' import { Color } from '@material-ui/lab' @@ -41,6 +42,7 @@ interface IProps { initialIsDiscreteValue: boolean onDiscreteChange: (val: boolean) => void showFeesLoader?: boolean + showLiquidityLoader?: boolean hasTicksError?: boolean reloadHandler: () => void plotVolumeRange?: { @@ -51,6 +53,7 @@ interface IProps { globalPrice?: number setXToY: (val: boolean) => void xToY: boolean + handleRefresh: () => void } const PositionDetails: React.FC = ({ @@ -77,13 +80,15 @@ const PositionDetails: React.FC = ({ initialIsDiscreteValue, onDiscreteChange, showFeesLoader = false, + showLiquidityLoader = false, hasTicksError, reloadHandler, plotVolumeRange, userHasStakes = false, globalPrice, setXToY, - xToY + xToY, + handleRefresh }) => { const classes = useStyles() @@ -109,6 +114,7 @@ const PositionDetails: React.FC = ({ xToY={xToY} swapHandler={() => setXToY(!xToY)} showFeesLoader={showFeesLoader} + showLiquidityLoader={showLiquidityLoader} userHasStakes={userHasStakes} /> @@ -117,17 +123,16 @@ const PositionDetails: React.FC = ({ container item direction='column' - alignItems='flex-end' + alignItems='center' className={classes.right} wrap='nowrap'> + diff --git a/src/components/PositionDetails/SinglePositionInfo/SinglePositionInfo.tsx b/src/components/PositionDetails/SinglePositionInfo/SinglePositionInfo.tsx index 309d0142c..9d0372146 100644 --- a/src/components/PositionDetails/SinglePositionInfo/SinglePositionInfo.tsx +++ b/src/components/PositionDetails/SinglePositionInfo/SinglePositionInfo.tsx @@ -21,6 +21,7 @@ interface IProp { xToY: boolean swapHandler: () => void showFeesLoader?: boolean + showLiquidityLoader?: boolean userHasStakes?: boolean } @@ -35,6 +36,7 @@ const SinglePositionInfo: React.FC = ({ xToY, swapHandler, showFeesLoader = false, + showLiquidityLoader = false, userHasStakes = false }) => { const history = useHistory() @@ -101,7 +103,6 @@ const SinglePositionInfo: React.FC = ({ Close position - {' '}