forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[42069] adrienne / account ready modal for wallets (deriv-com#10271)
* chore: backup before merge * feat: added wallet account ready content * chore: removed unsaved changes * chore: removed unsaved changes * chore: fixed circleci build test * chore: incorporated code reviews * chore: updated prop types for account ready * chore: refactoerd code based on master changes * Update icons.js * chore: resolve eslint issues camel case
- Loading branch information
1 parent
4263a92
commit c443ed7
Showing
12 changed files
with
283 additions
and
33 deletions.
There are no files selected for viewing
4 changes: 1 addition & 3 deletions
4
packages/wallets/src/components/Base/ModalWrapper/ModalWrapper.scss
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
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
46 changes: 46 additions & 0 deletions
46
packages/wallets/src/components/WalletMarketCurrencyIcon/WalletMarketCurrencyIcon.scss
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,46 @@ | ||
.wallets-market-currency-icon { | ||
$scaling: 65%; | ||
|
||
width: 95px; | ||
height: 70px; | ||
position: relative; | ||
z-index: 0; | ||
transform-origin: top left; | ||
transform: scale($scaling); | ||
|
||
&__before { | ||
&-demo { | ||
$scaling-before: $scaling + 10%; | ||
width: $scaling + 25%; | ||
|
||
& .wallets-gradient svg { | ||
transform: scale($scaling-before + 10%); | ||
} | ||
transform: scale($scaling-before); | ||
transform-origin: bottom right; | ||
} | ||
|
||
&-real { | ||
$scaling-before: $scaling + 25%; | ||
width: $scaling + 15%; | ||
|
||
& .wallets-gradient svg { | ||
transform: scale($scaling-before - 20%); | ||
} | ||
transform: scale($scaling-before); | ||
transform-origin: bottom right; | ||
} | ||
|
||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
z-index: 1; | ||
} | ||
|
||
&__after { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
z-index: 2; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/wallets/src/components/WalletMarketCurrencyIcon/WalletMarketCurrencyIcon.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, { ComponentType, SVGAttributes } from 'react'; | ||
import DerivedMT5Icon from '../../public/images/mt5-derived.svg'; | ||
import FinancialMT5Icon from '../../public/images/mt5-financial.svg'; | ||
import SwapFreeMT5Icon from '../../public/images/mt5-swap-free.svg'; | ||
import { WalletCardIcon } from '../WalletCardIcon'; | ||
import { WalletGradientBackground } from '../WalletGradientBackground'; | ||
import './WalletMarketCurrencyIcon.scss'; | ||
|
||
const marketTypeToIconMapper: Record<string, ComponentType<SVGAttributes<SVGElement>>> = { | ||
all: SwapFreeMT5Icon, | ||
financial: FinancialMT5Icon, | ||
synthetic: DerivedMT5Icon, | ||
}; | ||
|
||
type TWalletMarketCurrencyIconProps = { | ||
currency: string; | ||
isDemo: boolean; | ||
marketType: string; | ||
}; | ||
|
||
const WalletMarketCurrencyIcon = ({ currency, isDemo, marketType }: TWalletMarketCurrencyIconProps) => { | ||
const MarketTypeIcon = marketTypeToIconMapper[marketType]; | ||
|
||
return ( | ||
<div className='wallets-market-currency-icon'> | ||
<MarketTypeIcon className='wallets-market-currency-icon__after' /> | ||
<div | ||
className={`wallets-market-currency-icon__before wallets-market-currency-icon__before-${ | ||
isDemo ? 'demo' : 'real' | ||
}`} | ||
> | ||
<WalletGradientBackground currency={currency} hasShine isDemo={isDemo} type='card'> | ||
<WalletCardIcon type={isDemo ? 'Demo' : currency} /> | ||
</WalletGradientBackground> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WalletMarketCurrencyIcon; |
1 change: 1 addition & 0 deletions
1
packages/wallets/src/components/WalletMarketCurrencyIcon/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 WalletMarketCurrencyIcon } from './WalletMarketCurrencyIcon'; |
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
87 changes: 87 additions & 0 deletions
87
packages/wallets/src/features/cfd/screens/AccountReady/AccountReady.scss
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,87 @@ | ||
.wallets-account-ready { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 16px; | ||
gap: 24px; | ||
width: 392px; | ||
border-radius: 10px; | ||
text-align: center; | ||
background: var(--system-light-8-primary-background, #fff); | ||
|
||
&__info { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
width: 240px; | ||
height: 128px; | ||
padding: 10px; | ||
position: relative; | ||
border-radius: 10px; | ||
|
||
&__text { | ||
&--type { | ||
font-weight: 400; | ||
line-height: 14px; | ||
font-size: 10px; | ||
} | ||
|
||
&--wallet { | ||
font-size: 10px; | ||
font-weight: 400; | ||
line-height: 14px; | ||
color: #999999; | ||
} | ||
|
||
&--amount { | ||
font-size: 14px; | ||
font-weight: 700; | ||
line-height: 20px; | ||
} | ||
} | ||
|
||
&-badge { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
font-weight: 700; | ||
border-radius: 0 10px 0px; | ||
display: grid; | ||
place-items: center; | ||
color: #ffffff; | ||
height: 25px; | ||
width: 50px; | ||
|
||
&--demo { | ||
background-color: #377cfc; | ||
} | ||
|
||
&--real { | ||
background-color: #ff444f; | ||
} | ||
} | ||
} | ||
|
||
&__title { | ||
font-weight: 700; | ||
font-size: 16px; | ||
line-height: 24px; | ||
} | ||
|
||
&__subtitle { | ||
font-size: 14px; | ||
line-height: 20px; | ||
} | ||
|
||
&__button { | ||
background-color: #ff444f; | ||
color: #ffffff; | ||
cursor: pointer; | ||
font-weight: 700; | ||
width: 100%; | ||
padding: 10px; | ||
border: none; | ||
border-radius: 5px; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
packages/wallets/src/features/cfd/screens/AccountReady/AccountReady.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,65 @@ | ||
import React from 'react'; | ||
import { useActiveWalletAccount, useSortedMT5Accounts } from '@deriv/api'; | ||
import { useModal } from '../../../../components/ModalProvider'; | ||
import { WalletGradientBackground } from '../../../../components/WalletGradientBackground'; | ||
import { WalletMarketCurrencyIcon } from '../../../../components/WalletMarketCurrencyIcon'; | ||
import './AccountReady.scss'; | ||
|
||
type TAccountReadyProps = { | ||
marketType: Exclude<NonNullable<ReturnType<typeof useSortedMT5Accounts>['data']>[number]['market_type'], undefined>; | ||
}; | ||
|
||
const marketTypeToTitleMapper: Record<TAccountReadyProps['marketType'], string> = { | ||
financial: 'MT5 Financial', | ||
all: 'Swap-Free', | ||
synthetic: 'MT5 Derived', | ||
}; | ||
|
||
const AccountReady: React.FC<TAccountReadyProps> = ({ marketType }) => { | ||
const { data } = useActiveWalletAccount(); | ||
const { hide } = useModal(); | ||
const isDemo = data?.is_virtual; | ||
const landingCompanyName = data?.landing_company_name?.toUpperCase(); | ||
|
||
return ( | ||
<div className='wallets-account-ready'> | ||
<WalletGradientBackground | ||
bodyClassName='wallets-account-ready__info' | ||
currency={data?.currency || 'USD'} | ||
hasShine | ||
theme='grey' | ||
> | ||
<div | ||
className={`wallets-account-ready__info-badge wallets-account-ready__info-badge--${ | ||
isDemo ? 'demo' : 'real' | ||
}`} | ||
> | ||
{isDemo ? 'Demo' : 'Real'} | ||
</div> | ||
<WalletMarketCurrencyIcon | ||
currency={data?.currency || 'USD'} | ||
isDemo={isDemo || false} | ||
marketType={marketType} | ||
/> | ||
<div className='wallets-account-ready__info__text--type'> | ||
{marketTypeToTitleMapper[marketType]} ({landingCompanyName}) | ||
</div> | ||
<div className='wallets-account-ready__info__text--wallet'>{data?.currency} Wallet</div> | ||
<div className='wallets-account-ready__info__text--amount'>{data?.display_balance} USD</div> | ||
</WalletGradientBackground> | ||
<div className='wallets-account-ready__title'> | ||
Your {marketTypeToTitleMapper[marketType]} | ||
{isDemo && ' demo'} account is ready | ||
</div> | ||
<div className='wallets-account-ready__subtitle'> | ||
You can now start practicing trading with your {marketTypeToTitleMapper[marketType]} | ||
{isDemo && ' demo'} account. | ||
</div> | ||
<button className='wallets-account-ready__button' onClick={hide}> | ||
Continue | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AccountReady; |
1 change: 1 addition & 0 deletions
1
packages/wallets/src/features/cfd/screens/AccountReady/index.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 @@ | ||
export { default as AccountReady } from './AccountReady'; |
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