Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
chore: live market testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hasan-deriv committed Jan 4, 2024
1 parent 2d688d2 commit 85a5837
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/data/trustpilot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"stars": 4.5,
"trustScore": 4.6,
"numberOfReviews": "38,452"
"numberOfReviews": "38,754"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React, { useEffect, useRef, useState } from 'react'
import { qtMerge, Text } from '@deriv/quill-design'
import {
StandaloneChartTrendDownRegularIcon,
Expand All @@ -7,8 +6,8 @@ import {
// eslint-disable-next-line import/no-unresolved
} from '@deriv/quill-icons/Standalone'
import clsx from 'clsx'
import { MarketStatus } from '@deriv-com/components'
import { LiveMarketContent } from '../types'
import React, { useEffect, useRef } from 'react'
import { LiveMarketContent, MarketStatus } from '../types'
import LivePrice from './live-price'
import { BuySellButtons } from './buy-sell.buttons'

Expand Down Expand Up @@ -36,32 +35,24 @@ export const LiveMarketCard: React.FC<LiveMarketCardProps> = ({
instrumentIcon,
instrument,
changePercentage,
status,
mid,
bidPrice,
askPrice,
spread,
mid,
onClickBuyButton,
onClickSellButton,
}) => {
const prevMid = useRef<HTMLDivElement>(null)
const prevState = prevMid.current?.dataset['state'] as MarketStatus
let chnageCount = prevMid.current?.dataset['count'] || '0'
let state: MarketStatus
if (mid > +prevMid?.current?.textContent) state = 'up'
if (mid < +prevMid?.current?.textContent) state = 'down'
if (mid === +prevMid?.current?.textContent) {
state = prevState || 'up'
chnageCount = `${+chnageCount + 1}`
} else {
chnageCount = '0'
const prevStatus = prevMid.current?.dataset['status'] as MarketStatus
let status: MarketStatus = 'up'
if (prevMid?.current?.textContent) {
if (mid > +prevMid.current.textContent) status = 'up'
if (mid < +prevMid.current.textContent) status = 'down'
if (mid === +prevMid.current.textContent) status = prevStatus
}
state = +chnageCount >= 300 ? 'closed' : state

console.log('==>', state)

const textClassName =
state === 'closed' ? 'text-typography-disabled' : 'text-typography-default'
status === 'closed' ? 'text-typography-disabled' : 'text-typography-default'

return (
<div
Expand All @@ -75,8 +66,8 @@ export const LiveMarketCard: React.FC<LiveMarketCardProps> = ({
className,
)}
>
<div className="flex h-[52px] shrink-0 grow flex-row gap-gap-sm">
<div className="flex flex-1 flex-row gap-gap-md">
<div className="flex h-[52px] shrink-0 grow flex-row justify-between gap-gap-sm">
<div className="flex max-w-[141px] flex-1 flex-row gap-gap-md">
<div className={clsx(status === 'closed' && 'opacity-600')}>
{instrumentIcon}
</div>
Expand All @@ -90,19 +81,19 @@ export const LiveMarketCard: React.FC<LiveMarketCardProps> = ({
{instrument}
</Text>
</div>
<div className="flex flex-row gap-gap-md pt-[2px]">
{status !== 'closed' && ChartIcons[state]}
<Text size="md" className={colorVariant[state]}>
<div className="flex max-w-[90px] flex-row gap-gap-md pt-[2px]">
{status !== 'closed' && ChartIcons[status]}
<Text size="md" className={colorVariant[status]}>
{changePercentage}
</Text>
</div>
</div>
<div ref={prevMid} data-state={state} className="sr-only">
<div ref={prevMid} data-status={status} className="sr-only">
{mid}
</div>

<LivePrice
status={state}
status={status}
bidPrice={bidPrice}
askPrice={askPrice}
textClass={textClassName}
Expand Down

0 comments on commit 85a5837

Please sign in to comment.