-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[trah]thisyahlen/2290/chore: add options and multipliers section for …
…tradershub v2 (#12467) * chore: add options and multipliers section for tradershub v2 * chore: update quill version * chore: add import for FC
- Loading branch information
1 parent
049765e
commit 1c519a7
Showing
10 changed files
with
224 additions
and
35,430 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ges/tradershub/src/components/OptionsAndMultiplersSection/OptionsAndMultiplersSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { Heading, Text, useBreakpoint } from '@deriv/quill-design'; | ||
import { OptionsAndMultipliersContent } from './OptionsAndMultipliersContent'; | ||
|
||
const OptionsAndMultiplersSection = () => { | ||
const { isMobile } = useBreakpoint(); | ||
return ( | ||
<div className='border-solid p-1200 rounded-1200 border-xs border-opacity-black-100 '> | ||
<div className='flex-col w-full gap-1200'> | ||
{!isMobile && <Heading.H4>Options & multipliers</Heading.H4>} | ||
<Text size='sm'> | ||
Earn a range of payouts by correctly predicting market price movements with | ||
<a | ||
className='underline cursor-pointer text-solid-red-700 underline-offset-2 px-200' | ||
href='https://deriv.com/trade-types/options/digital-options/up-and-down/' | ||
key={0} | ||
rel='noopener noreferrer' | ||
target='_blank' | ||
> | ||
options | ||
</a> | ||
, or get the upside of CFDs without risking more than your initial stake with | ||
<a | ||
className='underline cursor-pointer text-solid-red-700 underline-offset-2 px-200' | ||
href='https://deriv.com/trade-types/multiplier/' | ||
key={1} | ||
rel='noopener noreferrer' | ||
target='_blank' | ||
> | ||
multipliers | ||
</a> | ||
. | ||
</Text> | ||
|
||
<OptionsAndMultipliersContent /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default OptionsAndMultiplersSection; |
116 changes: 116 additions & 0 deletions
116
...OptionsAndMultiplersSection/OptionsAndMultipliersContent/OptionsAndMultipliersContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import React, { FC } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { useActiveTradingAccount } from '@deriv/api'; | ||
import { Button, Text, useBreakpoint } from '@deriv/quill-design'; | ||
import { optionsAndMultipliersContent } from '../../../constants/constants'; | ||
import { getStaticUrl, getUrlBinaryBot, getUrlSmartTrader } from '../../../helpers/urls'; | ||
import { TradingAccountCard } from '../../TradingAccountCard'; | ||
|
||
type TShowButtonProps = Pick<typeof optionsAndMultipliersContent[number], 'isExternal' | 'redirect'>; | ||
|
||
type TLinkTitleProps = Pick<typeof optionsAndMultipliersContent[number], 'icon' | 'title'>; | ||
|
||
const LinkTitle: FC<TLinkTitleProps> = ({ icon, title }) => { | ||
const handleClick = ( | ||
event: | ||
| React.KeyboardEvent<HTMLButtonElement> | ||
| React.MouseEvent<HTMLButtonElement, MouseEvent> | ||
| React.MouseEvent<HTMLDivElement, MouseEvent> | ||
) => { | ||
event.persist(); | ||
switch (title) { | ||
case 'Deriv Trader': | ||
window.open(getStaticUrl(`/dtrader`)); | ||
break; | ||
case 'Deriv Bot': | ||
window.open(getStaticUrl(`/dbot`)); | ||
break; | ||
case 'SmartTrader': | ||
window.open(getUrlSmartTrader()); | ||
break; | ||
case 'Binary Bot': | ||
window.open(getUrlBinaryBot()); | ||
break; | ||
case 'Deriv GO': | ||
window.open(getStaticUrl('/deriv-go')); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
return ( | ||
// Had to result to button instead of div because of sonarcloud | ||
<button | ||
className='cursor-pointer' | ||
onClick={event => handleClick(event)} | ||
onKeyDown={event => { | ||
if (event.key === 'Enter') { | ||
handleClick(event); | ||
} | ||
}} | ||
> | ||
{icon} | ||
</button> | ||
); | ||
}; | ||
|
||
const ShowOpenButton = ({ isExternal, redirect }: TShowButtonProps) => { | ||
const history = useHistory(); | ||
|
||
const { data } = useActiveTradingAccount(); | ||
if (data?.loginid) { | ||
return ( | ||
<Button | ||
className='rounded-200' | ||
onClick={() => { | ||
if (isExternal) { | ||
window.open(redirect, '_blank'); | ||
} else { | ||
history.push(redirect); | ||
} | ||
}} | ||
> | ||
Open | ||
</Button> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
const OptionsAndMultipliersContent = () => { | ||
const { isMobile } = useBreakpoint(); | ||
const { data } = useActiveTradingAccount(); | ||
|
||
return ( | ||
<div className='grid w-full grid-cols-1 gap-200 lg:grid-cols-3 lg:gap-x-1200 lg:gap-y-200'> | ||
{optionsAndMultipliersContent.map(account => { | ||
const trailingComponent = () => ( | ||
<ShowOpenButton isExternal={account.isExternal} redirect={account.redirect} /> | ||
); | ||
|
||
const leadingComponent = () => ( | ||
<LinkTitle icon={data?.loginid || !isMobile ? account.icon : account.smallIcon} title={title} /> | ||
); | ||
|
||
const title = account.title; | ||
return ( | ||
<TradingAccountCard | ||
{...account} | ||
key={`trading-account-card-${account.title}`} | ||
leading={leadingComponent} | ||
trailing={trailingComponent} | ||
> | ||
<div className='flex flex-col flex-grow'> | ||
<Text bold size='sm'> | ||
{account.title} | ||
</Text> | ||
<Text size='xs'>{account.description}</Text> | ||
</div> | ||
</TradingAccountCard> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default OptionsAndMultipliersContent; |
1 change: 1 addition & 0 deletions
1
...adershub/src/components/OptionsAndMultiplersSection/OptionsAndMultipliersContent/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as OptionsAndMultipliersContent } from './OptionsAndMultipliersContent'; |
1 change: 1 addition & 0 deletions
1
packages/tradershub/src/components/OptionsAndMultiplersSection/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as OptionsAndMultiplersSection } from './OptionsAndMultiplersSection'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 49 additions & 66 deletions
115
packages/tradershub/src/routes/TradersHubRoute/TradersHubRoute.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,63 @@ | ||
import React, { FC } from 'react'; | ||
import { Button, Heading, Text } from '@deriv/quill-design'; | ||
import { OptionsAndMultiplersSection } from '../../components'; | ||
|
||
const TradersHubRoute: FC = () => ( | ||
<div className='flex flex-col gap-1200'> | ||
{/* Header */} | ||
<div className='flex align-start items-center justify-between gap-100'> | ||
<Heading.H3>Trader's Hub</Heading.H3> | ||
<div className='flex flex-col items-end justify-end'> | ||
<Text size='sm'>Total assets</Text> | ||
<Heading.H3 className='text-status-light-information'>10,000.00 USD</Heading.H3> | ||
</div> | ||
</div> | ||
{/* Deriv Apps */} | ||
<div className='p-1200 rounded-1200 border-xs border-solid border-opacity-black-100'> | ||
<div className='pb-1200 lg:w-4/6'> | ||
<Heading.H4>Options & multipliers</Heading.H4> | ||
<Text size='sm'> | ||
Earn a range of payouts by correctly predicting market price movements with{' '} | ||
<a className='text-solid-coral-700 underline underline-offset-2 cursor-pointer'>options</a> or get | ||
the upside of CFDs without risking more than your initial stake with{' '} | ||
<a className='text-solid-coral-700 underline underline-offset-2 cursor-pointer'>multipliers</a>. | ||
</Text> | ||
</div> | ||
<div className='grid grid-cols-1 gap-4 lg:grid-cols-3 lg:gap-x-1200 lg:gap-y-200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
</div> | ||
</div> | ||
{/* CFD Apps */} | ||
<div className='p-1200 rounded-1200 border-xs border-solid border-opacity-black-100'> | ||
<div className='pb-1200'> | ||
<div className='flex items-center gap-200'> | ||
<Heading.H4>CFDs</Heading.H4> | ||
<Button className='no-underline' colorStyle='coral' size='sm' variant='tertiary'> | ||
Compare Accounts | ||
</Button> | ||
const TradersHubRoute: FC = () => { | ||
return ( | ||
<div className='flex flex-col gap-1200'> | ||
<div className='flex items-center justify-between align-start gap-100'> | ||
<Heading.H3>Trader's Hub</Heading.H3> | ||
<div className='flex flex-col items-end justify-end'> | ||
<Text size='sm'>Total assets</Text> | ||
<Heading.H3 className='text-status-light-information'>10,000.00 USD</Heading.H3> | ||
</div> | ||
<Text size='sm'> | ||
Trade with leverage and tight spreads for better returns on trades.{' '} | ||
<a className='text-solid-coral-700 underline underline-offset-2 cursor-pointer'>Learn more</a> | ||
</Text> | ||
</div> | ||
<div className='flex flex-col gap-y-1200'> | ||
<div> | ||
<Text bold className='pb-800' size='md'> | ||
Deriv MT5 | ||
</Text> | ||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-1200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<OptionsAndMultiplersSection /> | ||
|
||
<div className='border-solid p-1200 rounded-1200 border-xs border-opacity-black-100'> | ||
<div className='pb-1200'> | ||
<div className='flex items-center gap-200'> | ||
<Heading.H4>CFDs</Heading.H4> | ||
<Button className='no-underline' colorStyle='coral' size='sm' variant='tertiary'> | ||
Compare Accounts | ||
</Button> | ||
</div> | ||
</div> | ||
<div> | ||
<Text bold className='pb-800' size='md'> | ||
Deriv cTrader | ||
<Text size='sm'> | ||
Trade with leverage and tight spreads for better returns on trades.{' '} | ||
<a className='underline cursor-pointer text-solid-coral-700 underline-offset-2'>Learn more</a> | ||
</Text> | ||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-1200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
</div> | ||
</div> | ||
<div> | ||
<Text bold className='pb-800' size='md'> | ||
Other CFDs | ||
</Text> | ||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-1200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='flex flex-col gap-y-1200'> | ||
<div> | ||
<Text bold className='pb-800' size='md'> | ||
Deriv MT5 | ||
</Text> | ||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-1200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
</div> | ||
</div> | ||
<div> | ||
<Text bold className='pb-800' size='md'> | ||
Deriv cTrader | ||
</Text> | ||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-1200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
</div> | ||
</div> | ||
<div> | ||
<Text bold className='pb-800' size='md'> | ||
Other CFDs | ||
</Text> | ||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-1200'> | ||
<div className='h-4000 rounded-300 bg-solid-slate-100' /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
export default TradersHubRoute; |