Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DTRA] Maryia/DTRA-1685/feat: design updates for DTrader V2 pages #16607

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
be31e89
feat: update buttons in filter action sheet + show remaining time for…
maryia-deriv Aug 26, 2024
f288c81
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Aug 26, 2024
402cbf9
feat: update contract card timer and profit styles + update empty pag…
maryia-deriv Aug 26, 2024
c6b8ac9
Merge branch master of github.com:binary-com/deriv-app into maryia/DT…
maryia-deriv Aug 26, 2024
a8729b6
feat: add dc remaining time + update stake input using quill-ui lates…
maryia-deriv Aug 26, 2024
75eda3d
feat: c.details header and close buttons updates
maryia-deriv Aug 26, 2024
a97942f
Merge branch master of github.com:binary-com/deriv-app into maryia/DT…
maryia-deriv Aug 27, 2024
8616b94
revert: new header related css removal
maryia-deriv Aug 27, 2024
a752f83
feat: utilize isOpaque property for floating Buttons
maryia-deriv Aug 27, 2024
c53440c
fix: purchase button & stake for 1 of 2 contracts error
maryia-deriv Aug 27, 2024
10f9d97
fix: buttons & inputs updates
maryia-deriv Aug 27, 2024
c371874
fix: c.details cards styles + cancellation styles + MULT close button
maryia-deriv Aug 27, 2024
d49a434
Merge branch master of github.com:binary-com/deriv-app into maryia/DT…
maryia-deriv Aug 28, 2024
ad2b57a
feat: add invalid stake text to any purchase buttons + update chip fo…
maryia-deriv Aug 28, 2024
ab64b7c
feat: add potential payout to all old trade types
maryia-deriv Aug 28, 2024
0f3a95d
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Aug 28, 2024
69561d4
revert: extra file from master
maryia-deriv Aug 28, 2024
c04a0b1
chore: update Chart height
maryia-deriv Aug 28, 2024
0888736
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Aug 28, 2024
2b58c0a
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Aug 29, 2024
3a2ce19
feat: add section message to DC + update text copy
maryia-deriv Aug 29, 2024
7dae18a
feat: add total PnL to risk management action sheet + update sheet he…
maryia-deriv Aug 29, 2024
d090b8c
feat: update chart scroll behavior to allow page scroll on it in cont…
maryia-deriv Aug 29, 2024
4b4f39e
fix: tests
maryia-deriv Aug 29, 2024
f84f883
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Aug 29, 2024
df94e30
revert: unnecessary changes & files from master
maryia-deriv Aug 29, 2024
d4978d7
revert: unnecessary change
maryia-deriv Aug 29, 2024
8dc5c2d
fix: key issue from Chip in quill-ui on test links
maryia-deriv Aug 30, 2024
c2f4064
feat: remove trade types filter from positions-closed
maryia-deriv Aug 30, 2024
8192764
feat: update skeleton for positions-closed
maryia-deriv Aug 30, 2024
72405bf
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Aug 30, 2024
0044c25
fix: data-testid naming
maryia-deriv Aug 30, 2024
be3e755
fix: add localize to contract-type-filter label
maryia-deriv Aug 30, 2024
a71be8a
refactor: skeleton loader for positions-closed
maryia-deriv Aug 30, 2024
9e397f3
Merge branch 'master' of github.com:binary-com/deriv-app into redesig…
balakrishna-deriv Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const PositionsLoader = ({ initial_app_loading, is_closed_tab }: TPositionsLoade
</div>
)}
<div className='skeleton-box__filters'>
{[...new Array(is_closed_tab ? 2 : 1)].map((_, idx) => {
return <Skeleton key={idx} width={144} height={32} />;
})}
<Skeleton width={144} height={32} />
</div>
<div className='skeleton-box__total-pnl-or-date'>
{[...new Array(is_closed_tab ? 1 : 2)].map((_, idx) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
padding: var(--semantic-spacing-general-md);
border-radius: var(--core-borderRadius-500);
gap: var(--semantic-spacing-gap-lg);
box-shadow: var(--core-elevation-shadow-130);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all cards in C.Details should have box shadow.

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
.timer {
background-color: var(--core-color-opacity-black-75);

&,
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it's intended since I want the style to apply to both .timer and .dc-remaining-time :)

Copy link
Contributor

Choose a reason for hiding this comment

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

can we be more explicit for readability

Copy link
Contributor Author

@maryia-deriv maryia-deriv Aug 30, 2024

Choose a reason for hiding this comment

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

& stands for .timer but at the same time it doesn't nest it. it's the only way to not write the style twice for .timer and .dc-remaining-time :) Although, I'm open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

what i mean is i dont mind writing the same style twice for the sake of readability

Copy link
Contributor

Choose a reason for hiding this comment

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

I think using the parent selector(&) is fine here. We've already used in multiple places and it's not hard to understand it, IMO.

.dc-remaining-time {
font-size: unset;
font-size: var(--core-fontSize-50);
}
}
.status-and-profit {
Expand Down Expand Up @@ -86,14 +87,17 @@
button {
all: unset;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: var(--core-size-3600);
height: 100%;
cursor: pointer;

.label {
.label,
.dc-remaining-time {
color: var(--core-color-solid-slate-50);
font-size: var(--core-fontSize-50);
}
&:disabled:not(.loading) {
background-color: var(--core-color-opacity-black-200);
Expand Down Expand Up @@ -137,7 +141,7 @@
}
&.lost {
.profit {
color: var(--core-color-solid-red-600);
color: var(--core-color-solid-red-700);
}
button:not(:disabled),
button.loading {
Expand All @@ -150,7 +154,7 @@
}
&.won {
.profit {
color: var(--core-color-solid-green-600);
color: var(--core-color-solid-green-700);
}
button:not(:disabled),
button.loading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from 'react';
import clsx from 'clsx';
import { CaptionText, Text } from '@deriv-com/quill-ui';
import { useSwipeable } from 'react-swipeable';
import { IconTradeTypes, Money } from '@deriv/components';
import { IconTradeTypes, Money, RemainingTime } from '@deriv/components';
import {
TContractInfo,
getCardLabels,
getCurrentTick,
getMarketName,
getTradeTypeName,
isCryptoContract,
isEnded,
isHighLow,
isMultiplierContract,
Expand Down Expand Up @@ -66,12 +67,14 @@ const ContractCard = ({
isHighLow: is_high_low,
showMainTitle: true,
});
const cancellation_date_expiry = 'cancellation' in contractInfo ? contractInfo.cancellation?.date_expiry : null;
const currentTick = 'tick_count' in contractInfo && contractInfo.tick_count ? getCurrentTick(contractInfo) : null;
const tradeTypeName = `${contract_main_title} ${getTradeTypeName(contract_type ?? '', {
isHighLow: is_high_low,
})}`.trim();
const symbolName =
'underlying_symbol' in contractInfo ? getMarketName(contractInfo.underlying_symbol ?? '') : display_name;
const is_crypto = isCryptoContract((contractInfo as TContractInfo).underlying);
const isMultiplier = isMultiplierContract(contract_type);
const isSold = !!sell_time || isEnded(contractInfo as TContractInfo);
const totalProfit = getProfit(contractInfo);
Expand Down Expand Up @@ -147,7 +150,7 @@ const ContractCard = ({
<div className='status-and-profit'>
<ContractCardStatusTimer
currentTick={currentTick}
hasNoAutoExpiry={isMultiplier}
hasNoAutoExpiry={isMultiplier && !is_crypto}
isSold={isSold}
serverTime={serverTime}
{...contractInfo}
Expand All @@ -168,9 +171,21 @@ const ContractCard = ({
{isCancelButtonPressed ? (
<div className='circle-loader' data-testid='dt_button_loader' />
) : (
<CaptionText bold as='div' className='label'>
{getCardLabels().CANCEL}
</CaptionText>
<>
<CaptionText bold as='div' className='label'>
{getCardLabels().CANCEL}
</CaptionText>
{cancellation_date_expiry && (
<CaptionText bold as='div' className='label'>
<RemainingTime
end_time={cancellation_date_expiry}
format='mm:ss'
getCardLabels={getCardLabels}
start_time={serverTime as moment.Moment}
/>
</CaptionText>
)}
</>
)}
</button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('ContractDetailsFooter', () => {
(isMultiplierContract as jest.Mock).mockImplementation(() => false);
(isValidToSell as jest.Mock).mockImplementation(() => true);
renderFooter();
const closeButton = screen.getByRole('button', { name: /close @ 100.00 usd/i });
const closeButton = screen.getByRole('button', { name: /close 100.00 usd/i });
expect(closeButton).toBeInTheDocument();
expect(closeButton).toBeEnabled();
});
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('ContractDetailsFooter', () => {
(isValidToSell as jest.Mock).mockImplementation(() => true);

renderFooter();
const closeButton = screen.getByRole('button', { name: /close @ 100.00 usd/i });
const closeButton = screen.getByRole('button', { name: /close 100.00 usd/i });

userEvent.click(closeButton);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
.contract-details-footer {
&--container {
padding: var(--semantic-spacing-general-md);
background-color: var(--core-color-solid-slate-50);
padding: 0 var(--semantic-spacing-general-sm) var(--semantic-spacing-general-sm);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: var(--semantic-spacing-gap-md);
width: 100%;
box-shadow: var(--core-elevation-shadow-210);
position: fixed;
bottom: 0;
z-index: 2; // chart has z-index: 1, it should not overlap buttons if screen height is small
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, TButtonColor, TButtonVariant } from '@deriv-com/quill-ui';
import React from 'react';
import { Button, TButtonColor } from '@deriv-com/quill-ui';
import { RemainingTime } from '@deriv/components';
import { TContractInfo, getCardLabelsV2, isMultiplierContract, isValidToCancel, isValidToSell } from '@deriv/shared';
import { useStore } from '@deriv/stores';
import React from 'react';
import { observer } from 'mobx-react';
import { TRegularSizesWithExtraLarge } from '@deriv-com/quill-ui/dist/types';
import { FormatUtils } from '@deriv-com/utils';
Expand All @@ -12,7 +12,6 @@ type ContractInfoProps = {
};

type ButtonProps = {
variant: TButtonVariant;
color: TButtonColor;
size: TRegularSizesWithExtraLarge;
fullWidth: boolean;
Expand All @@ -36,11 +35,13 @@ const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) =>
const is_multiplier = isMultiplierContract(contract_type);

const cardLabels = getCardLabelsV2();
const bidDetails = !is_valid_to_cancel ? `@${bid_price} ${currency}` : '';
const formatted_bid_price = FormatUtils.formatMoney(bid_price || 0, {
currency: currency as 'USD', // currency types mismatched between utils and shared
});
Copy link
Contributor

Choose a reason for hiding this comment

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

we have currencies other than USD though ?

Copy link
Contributor Author

@maryia-deriv maryia-deriv Aug 30, 2024

Choose a reason for hiding this comment

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

sure, it's just a type here in order to not use any, which was used for it before :)

const bidDetails = !is_valid_to_cancel ? `${formatted_bid_price} ${currency}` : '';
const label = `${cardLabels.CLOSE} ${bidDetails}`;

const buttonProps: ButtonProps = {
variant: 'secondary',
color: 'black',
size: 'lg',
fullWidth: true,
Expand All @@ -53,6 +54,7 @@ const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) =>
<Button
label={label}
isLoading={is_sell_requested}
isOpaque
disabled={Number(profit) < 0 && is_valid_to_cancel}
onClick={() => onClickSell(contract_id)}
{...buttonProps}
Expand All @@ -74,6 +76,8 @@ const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) =>
</>
}
disabled={Number(profit) >= 0}
isOpaque
variant='secondary'
{...buttonProps}
/>
)}
Expand All @@ -82,12 +86,11 @@ const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) =>
<Button
label={
is_valid_to_sell
? `${cardLabels.CLOSE} @ ${FormatUtils.formatMoney(bid_price || 0, {
currency: currency as any, // currency types mismatched between utils and shared
})} ${currency}`
? `${cardLabels.CLOSE} ${formatted_bid_price} ${currency}`
: cardLabels.RESALE_NOT_OFFERED
}
isLoading={is_sell_requested && is_valid_to_sell}
isOpaque
onClick={is_valid_to_sell ? () => onClickSell(contract_id) : undefined}
disabled={!is_valid_to_sell}
{...buttonProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jest.mock('@deriv/stores', () => ({
jest.mock('AppV2/Hooks/useContractDetails', () => jest.fn());

describe('DealCancellationRemainingTime component', () => {
const cancellation_badge_testid = 'dt_deal_cancellation_badge';
const mockCommon = {
server_time: {
unix: () => 1623441000,
Expand All @@ -44,7 +45,7 @@ describe('DealCancellationRemainingTime component', () => {
render(<DealCancellationRemainingTime />);

expect(screen.getByText('05:00')).toBeInTheDocument();
expect(screen.getByTestId('deal-cancellation-badge')).toBeInTheDocument();
expect(screen.getByTestId(cancellation_badge_testid)).toBeInTheDocument();
});

it('does not render the remaining time tag when end time is before start time', () => {
Expand All @@ -59,7 +60,7 @@ describe('DealCancellationRemainingTime component', () => {
render(<DealCancellationRemainingTime />);

expect(screen.queryByText('05:00')).not.toBeInTheDocument();
expect(screen.queryByTestId('deal-cancellation-badge')).not.toBeInTheDocument();
expect(screen.queryByTestId(cancellation_badge_testid)).not.toBeInTheDocument();
});

it('does not render the remaining time tag when there is no cancellation date', () => {
Expand All @@ -72,6 +73,6 @@ describe('DealCancellationRemainingTime component', () => {
render(<DealCancellationRemainingTime />);

expect(screen.queryByText('05:00')).not.toBeInTheDocument();
expect(screen.queryByTestId('deal-cancellation-badge')).not.toBeInTheDocument();
expect(screen.queryByTestId(cancellation_badge_testid)).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { Tag } from '@deriv-com/quill-ui';
import { RemainingTime } from '@deriv/components';
import { LabelPairedStopwatchCaptionRegularIcon } from '@deriv/quill-icons';
import { getCardLabelsV2 } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import useContractDetails from 'AppV2/Hooks/useContractDetails';
import React from 'react';

type DealCancellationRemainingTimeProps = {
format?: string;
Expand All @@ -22,12 +23,12 @@ const DealCancellationRemainingTime = observer(({ format = 'mm:ss' }: DealCancel
return (
<Tag
className='deal-cancellation-badge'
color='custom'
data-testid='deal-cancellation-badge'
data-testid='dt_deal_cancellation_badge'
icon={<LabelPairedStopwatchCaptionRegularIcon key='open-contract-card' />}
label={
<RemainingTime
end_time={end_time}
format='mm:ss'
format={format}
getCardLabels={getCardLabelsV2}
start_time={start_time}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ describe('EmptyPositions', () => {

it('should render "No open trades" content when isClosedTab prop is false', () => {
render(<EmptyPositions />);
expect(screen.getByText('No open trades')).toBeInTheDocument();
expect(screen.getByText('Your open trades will appear here.')).toBeInTheDocument();
expect(screen.getByText('No open positions')).toBeInTheDocument();
expect(screen.getByText('Your open positions will appear here.')).toBeInTheDocument();
});

it('should render "No closed trades" content when isClosedTab prop is true', () => {
render(<EmptyPositions isClosedTab />);
expect(screen.getByText('No closed trades')).toBeInTheDocument();
expect(screen.getByText('Your closed trades will be shown here.')).toBeInTheDocument();
expect(screen.getByText('No closed positions')).toBeInTheDocument();
expect(screen.getByText('Your closed positions will be shown here.')).toBeInTheDocument();
});

it('should render "No matches found" content when noMatchesFound prop is true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const EmptyPositions = ({ isClosedTab, noMatchesFound }: TEmptyPositionsProps) =
{noMatchesFound && <Localize i18n_default_text='No matches found' />}
{!noMatchesFound &&
(isClosedTab ? (
<Localize i18n_default_text='No closed trades' />
<Localize i18n_default_text='No closed positions' />
) : (
<Localize i18n_default_text='No open trades' />
<Localize i18n_default_text='No open positions' />
))}
</Text>
<Text size='sm' centered color='quill-typography__color--subtle'>
Expand All @@ -35,9 +35,9 @@ const EmptyPositions = ({ isClosedTab, noMatchesFound }: TEmptyPositionsProps) =
)}
{!noMatchesFound &&
(isClosedTab ? (
<Localize i18n_default_text='Your closed trades will be shown here.' />
<Localize i18n_default_text='Your closed positions will be shown here.' />
) : (
<Localize i18n_default_text='Your open trades will appear here.' />
<Localize i18n_default_text='Your open positions will appear here.' />
))}
</Text>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
display: flex;
justify-content: space-between;
width: 100%;
border-bottom: var(--core-color-solid-slate-75);
margin: var(--core-spacing-400) 0;
border-bottom: var(--core-borderWidth-75) solid var(--core-color-opacity-black-100);
padding: var(--core-spacing-400) 0;

&:first-child {
padding-top: 0;
}
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
}

&-cell {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import ContractTypeFilter from '../contract-type-filter';

const defaultFilterName = 'All trade types';
const defaultFilterName = 'Trade types';
const mockProps = {
onApplyContractTypeFilter: jest.fn(),
contractTypeFilter: [],
Expand All @@ -25,16 +25,16 @@ describe('ContractTypeFilter', () => {

render(<ContractTypeFilter {...mockProps} contractTypeFilter={mockContractTypeFilter} />);

expect(screen.queryByText(defaultFilterName)).not.toBeInTheDocument();
expect(screen.getByText(mockContractTypeFilter[0])).toBeInTheDocument();
expect(screen.queryByText(defaultFilterName)).toBeInTheDocument();
expect(screen.getByText('(1)')).toBeInTheDocument();
});

it('should render correct chip name is contractTypeFilter is with multiple items', () => {
const mockContractTypeFilter = ['Vanillas', 'Turbos'];
render(<ContractTypeFilter {...mockProps} contractTypeFilter={mockContractTypeFilter} />);

expect(screen.queryByText(defaultFilterName)).not.toBeInTheDocument();
expect(screen.getByText(`${mockContractTypeFilter.length} trade types`)).toBeInTheDocument();
expect(screen.queryByText(defaultFilterName)).toBeInTheDocument();
expect(screen.getByText('(2)')).toBeInTheDocument();
});

it('should call onApplyContractTypeFilter and setter (spied on) with array with chosen option after user clicks on contract type and clicks on "Apply" button', () => {
Expand Down
Loading
Loading