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

Akmal / feat: add longcode collapsed view #8997

Merged
merged 8 commits into from
Jun 30, 2023
29 changes: 25 additions & 4 deletions packages/reports/src/sass/app/modules/contract.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,35 @@ $CONTRACT_INFO_BOX_PADDING: 1.6em;
margin-right: 0.8rem;
}
}
&-wrapper {
max-width: 35rem;

@include mobile {
max-width: 23.3rem;

a {
font-size: 1rem;
}
}

a {
color: var(--brand-red-coral);
}
}
&-text {
max-width: 360px;
&--collapsed {
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
display: -webkit-box;
line-clamp: 3;
akmal-deriv marked this conversation as resolved.
Show resolved Hide resolved
overflow: hidden;
}

@include mobile {
max-width: 175px;
line-height: 1.4;
letter-spacing: normal;
font-size: 1rem;
letter-spacing: normal;
line-height: 1.4;
max-width: 23.3rem;
/* iPhone SE screen height fixes due to UI space restrictions */
@media only screen and (max-height: 480px) {
font-size: 0.8rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { observer } from 'mobx-react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import React from 'react';
import { Icon, Text } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { isVanillaContract } from '@deriv/shared';

const generateMessageForVanillaTrade = contract_info => (
<Localize
i18n_default_text='<0>For {{contract_type}}:</0> Get a payout if {{index_name}} is {{strike_status}} than the strike price at the expiry time. Your payout is zero if the market is {{market_status}} or equal to the strike price at the expiry time. You will start making a profit when the payout is higher than your stake.'
components={[<strong key={0} />]}
values={{
contract_type: contract_info.contract_type === 'VANILLALONGCALL' ? localize('Call') : localize('Put'),
index_name: contract_info.display_name,
strike_status: contract_info.contract_type === 'VANILLALONGCALL' ? localize('higher') : localize('lower'),
market_status: contract_info.contract_type === 'VANILLALONGCALL' ? localize('lower') : localize('higher'),
}}
/>
);
import { localize } from '@deriv/translations';

const InfoBoxLongcode = ({ contract_info }) => {
const is_vanilla = isVanillaContract(contract_info.contract_type);
const max_longcode_length = 150;
const [is_collapsed, setIsCollapsed] = React.useState(true);

const handleToggle = () => {
setIsCollapsed(!is_collapsed);
};

return (
<div className='info-box-longcode'>
<Icon icon='IcContractFlag' className='info-box-longcode-icon' size={24} />
<Text size='xs' className='info-box-longcode-text'>
{is_vanilla ? generateMessageForVanillaTrade(contract_info) : contract_info.longcode}
</Text>
<div className='info-box-longcode-wrapper'>
<Text size='xs' className={classNames('info-box-longcode-text', {'info-box-longcode-text--collapsed' : is_collapsed})}>
{contract_info.longcode}
</Text>
{` `}
akmal-deriv marked this conversation as resolved.
Show resolved Hide resolved
{contract_info.longcode.length > max_longcode_length &&
<Text as='a' href='#' size='xs' onClick={handleToggle} c>
{is_collapsed ? localize('View more') : localize('View less')}
</Text>}
</div>
</div>
);
};
Expand Down
29 changes: 25 additions & 4 deletions packages/trader/src/sass/app/modules/contract.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,35 @@ $CONTRACT_INFO_BOX_PADDING: 1.6em;
margin-right: 0.8rem;
}
}
&-wrapper {
max-width: 35rem;

@include mobile {
max-width: 23.3rem;

a {
font-size: 1rem;
}
}

a {
color: var(--brand-red-coral);
}
}
&-text {
max-width: 360px;
&--collapsed {
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
display: -webkit-box;
line-clamp: 3;
overflow: hidden;
}

@include mobile {
max-width: 175px;
line-height: 1.4;
letter-spacing: normal;
font-size: 1rem;
letter-spacing: normal;
line-height: 1.4;
max-width: 23.3rem;
/* iPhone SE screen height fixes due to UI space restrictions */
@media only screen and (max-height: 480px) {
font-size: 0.8rem;
Expand Down