Skip to content

Commit 96f8bb6

Browse files
committed
chore: add tooltips for take profit & stop loss
1 parent 2a6447d commit 96f8bb6

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

packages/components/src/components/contract-card/contract-card-items/contract-update-form.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import classNames from 'classnames';
22
import React from 'react';
3+
import { Localize } from '@deriv/translations';
34
import {
45
getCancellationPrice,
56
getContractUpdateConfig,
@@ -17,6 +18,7 @@ import InputWithCheckbox from '../../input-wth-checkbox';
1718
import { TContractInfo, TContractStore } from '@deriv/shared/src/utils/contract/contract-types';
1819
import { TGetCardLables, TToastConfig } from '../../types';
1920
import ArrowIndicator from '../../arrow-indicator';
21+
import Text from '../../text';
2022

2123
export type TGeneralContractCardBodyProps = {
2224
addToast: (toast_config: TToastConfig) => void;
@@ -58,6 +60,7 @@ export type TContractUpdateFormProps = Pick<
5860
toggleDialog: (e: React.MouseEvent<HTMLButtonElement>) => void;
5961
getContractById: (contract_id: number) => TContractStore;
6062
is_accumulator?: boolean;
63+
is_mobile?: boolean;
6164
is_turbos?: boolean;
6265
};
6366

@@ -68,6 +71,7 @@ const ContractUpdateForm = (props: TContractUpdateFormProps) => {
6871
current_focus,
6972
error_message_alignment,
7073
getCardLabels,
74+
is_mobile,
7175
is_turbos,
7276
is_accumulator,
7377
onMouseLeave,
@@ -173,6 +177,10 @@ const ContractUpdateForm = (props: TContractUpdateFormProps) => {
173177
value={contract_profit_or_loss.contract_update_take_profit}
174178
is_disabled={is_multiplier && !!is_valid_to_cancel}
175179
setCurrentFocus={setCurrentFocus}
180+
tooltip_alignment={is_mobile ? 'left' : 'right'}
181+
tooltip_label={
182+
<Localize i18n_default_text='When your profit reaches or exceeds this amount, your trade will be closed automatically.' />
183+
}
176184
/>
177185
);
178186

@@ -196,6 +204,10 @@ const ContractUpdateForm = (props: TContractUpdateFormProps) => {
196204
value={contract_profit_or_loss.contract_update_stop_loss}
197205
is_disabled={!!is_valid_to_cancel}
198206
setCurrentFocus={setCurrentFocus}
207+
tooltip_alignment={is_mobile ? 'left' : 'right'}
208+
tooltip_label={
209+
<Localize i18n_default_text='When your loss reaches or exceeds this amount, your trade will be closed automatically.' />
210+
}
199211
/>
200212
);
201213

@@ -205,7 +217,9 @@ const ContractUpdateForm = (props: TContractUpdateFormProps) => {
205217
<React.Fragment>
206218
<MobileWrapper>
207219
<div className='dc-contract-card-dialog__total-profit'>
208-
<span>{getCardLabels().TOTAL_PROFIT_LOSS}</span>
220+
<Text color='less-prominent' size='xs' weight='bold'>
221+
{getCardLabels().TOTAL_PROFIT_LOSS}
222+
</Text>
209223
<div
210224
className={classNames(
211225
'dc-contract-card__profit-loss dc-contract-card-item__total-profit-loss-value',
@@ -216,7 +230,7 @@ const ContractUpdateForm = (props: TContractUpdateFormProps) => {
216230
}
217231
)}
218232
>
219-
<Money amount={total_profit} currency={currency} />
233+
<Money amount={total_profit} currency={currency} show_currency />
220234
{!is_sold && (
221235
<ArrowIndicator className='dc-contract-card__indicative--movement' value={total_profit} />
222236
)}

packages/components/src/components/contract-card/contract-card-items/sass/contract-card-dialog.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
border-radius: $BORDER_RADIUS;
77
box-shadow: 0 4px 8px 2px var(--shadow-menu);
88
transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.25s linear;
9-
padding: 0.8rem;
9+
padding: 0.8rem 1.6rem 1.6rem;
1010
width: 240px;
1111
z-index: 99;
1212

packages/components/src/components/contract-card/contract-card-items/toggle-card-dialog.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ const ToggleCardDialog = ({
173173
getCardLabels={getCardLabels}
174174
getContractById={getContractById}
175175
is_accumulator={is_accumulator}
176+
is_mobile
176177
is_turbos={is_turbos}
177178
onMouseLeave={onMouseLeave}
178179
removeToast={removeToast}

packages/components/src/components/input-wth-checkbox/input-with-checkbox.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ const InputWithCheckbox = ({
189189
id={`dc_${name}-checkbox__tooltip`}
190190
is_bubble_hover_enabled
191191
message={tooltip_label}
192-
margin={isMobile() ? 0 : 216}
192+
margin={isMobile() || tooltip_alignment === 'right' ? 0 : 216}
193193
zIndex='9999'
194-
{...(isDesktop() ? { relative_render: true } : {})}
194+
{...(isDesktop() ? { relative_render: tooltip_alignment === 'left' } : {})}
195195
/>
196196
)}
197197
</div>

0 commit comments

Comments
 (0)