fix(trading): update price change
This commit is contained in:
parent
4bb50c0dab
commit
87579c0c5f
@ -71,6 +71,7 @@ export const MobileMarketHeader = () => {
|
|||||||
<Last24hPriceChange
|
<Last24hPriceChange
|
||||||
marketId={data.id}
|
marketId={data.id}
|
||||||
decimalPlaces={data.decimalPlaces}
|
decimalPlaces={data.decimalPlaces}
|
||||||
|
hideZero={true}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<MarketMarkPrice
|
<MarketMarkPrice
|
||||||
|
@ -11,7 +11,6 @@ import { useCandles } from '../../hooks/use-candles';
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useT } from '../../use-t';
|
import { useT } from '../../use-t';
|
||||||
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
marketId?: string;
|
marketId?: string;
|
||||||
@ -19,15 +18,17 @@ interface Props {
|
|||||||
initialValue?: string[];
|
initialValue?: string[];
|
||||||
isHeader?: boolean;
|
isHeader?: boolean;
|
||||||
noUpdate?: boolean;
|
noUpdate?: boolean;
|
||||||
|
// to render nothing instead of '-' when there is no price change
|
||||||
|
hideZero?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Last24hPriceChange = ({
|
export const Last24hPriceChange = ({
|
||||||
marketId,
|
marketId,
|
||||||
decimalPlaces,
|
decimalPlaces,
|
||||||
initialValue,
|
initialValue,
|
||||||
|
hideZero,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const { isMobile } = useScreenDimensions();
|
|
||||||
const { oneDayCandles, error, fiveDaysCandles } = useCandles({
|
const { oneDayCandles, error, fiveDaysCandles } = useCandles({
|
||||||
marketId,
|
marketId,
|
||||||
});
|
});
|
||||||
@ -36,8 +37,8 @@ export const Last24hPriceChange = ({
|
|||||||
fiveDaysCandles.length > 0 &&
|
fiveDaysCandles.length > 0 &&
|
||||||
(!oneDayCandles || oneDayCandles?.length === 0)
|
(!oneDayCandles || oneDayCandles?.length === 0)
|
||||||
) {
|
) {
|
||||||
// if there is no change and no percentage, we don't show anything on mobile
|
// render nothing instead of '-' when there is no price change
|
||||||
if (isMobile) {
|
if (hideZero) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@ -67,8 +68,8 @@ export const Last24hPriceChange = ({
|
|||||||
const change = priceChange(candles);
|
const change = priceChange(candles);
|
||||||
const changePercentage = priceChangePercentage(candles);
|
const changePercentage = priceChangePercentage(candles);
|
||||||
|
|
||||||
// if there is no change and no percentage, we don't show anything on mobile
|
// render nothing instead of '-' when there is no price change
|
||||||
if (!change && !changePercentage && isMobile) {
|
if (!change && !changePercentage && hideZero) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user