-
Notifications
You must be signed in to change notification settings - Fork 298
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
[Wallets] Responsive view for success and password modal #10871
Changes from 4 commits
35e63b2
e46ce21
13e6e2b
fa3dd75
2fc4b8e
2b2f389
28fd534
7b1de58
5dff4eb
2cd8c69
54766b3
0a051d8
3c4f211
14e5e29
af88a0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.wallets-button-group { | ||
display: flex; | ||
width: 100%; | ||
gap: 1.2rem; | ||
|
||
&--vertical { | ||
flex-direction: column; | ||
} | ||
|
||
&__item { | ||
width: 100%; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { type WalletButton } from '../WalletButton'; | ||
import './WalletButtonGroup.scss'; | ||
import classNames from 'classnames'; | ||
|
||
type TWalletButtonGroupProps = { | ||
isVertical?: boolean; | ||
}; | ||
|
||
const WalletButtonGroup: React.FC<React.PropsWithChildren<TWalletButtonGroupProps>> = ({ children, isVertical }) => { | ||
return ( | ||
<div | ||
className={classNames('wallets-button-group', { | ||
'wallets-button-group--vertical': isVertical, | ||
})} | ||
> | ||
{Children.map(children, child => ( | ||
Check failure on line 17 in packages/wallets/src/components/Base/WalletButtonGroup/WalletButtonGroup.tsx GitHub Actions / Build And Test
|
||
<div className='wallets-button-group__item'>{child}</div> | ||
yashim-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default WalletButtonGroup; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as WalletButtonGroup } from './WalletButtonGroup'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.wallets-mt5-password-modal { | ||
&__footer { | ||
width: 100%; | ||
|
||
&--pair { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
grid-gap: 10px; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,13 @@ import { | |
useSettings, | ||
useTradingPlatformPasswordChange, | ||
} from '@deriv/api'; | ||
import { ModalWrapper, WalletButton } from '../../../../components/Base'; | ||
import { ModalStepWrapper, ModalWrapper, WalletButton, WalletButtonGroup } from '../../../../components/Base'; | ||
import { useModal } from '../../../../components/ModalProvider'; | ||
import MT5PasswordIcon from '../../../../public/images/ic-mt5-password.svg'; | ||
import { CreatePassword, EnterPassword, Success } from '../../screens'; | ||
import { TMarketTypes, TPlatforms } from '../../types'; | ||
import useDevice from '../../../../hooks/useDevice'; | ||
import './MT5PasswordModal.scss'; | ||
import { MarketTypeToTitleMapper, PlatformToTitleMapper } from '../../constants'; | ||
|
||
type TProps = { | ||
|
@@ -28,6 +30,7 @@ const MT5PasswordModal: React.FC<TProps> = ({ marketType, platform }) => { | |
const { data: availableMT5Accounts } = useAvailableMT5Accounts(); | ||
const { data: settings } = useSettings(); | ||
const { hide } = useModal(); | ||
const { isMobile } = useDevice(); | ||
|
||
const hasMT5Account = mt5Accounts?.find(account => account.login); | ||
const isDemo = activeWallet?.is_virtual; | ||
|
@@ -68,6 +71,70 @@ const MT5PasswordModal: React.FC<TProps> = ({ marketType, platform }) => { | |
}); | ||
}; | ||
|
||
const renderTitle = () => { | ||
if (!isSuccess && hasMT5Account) return `Enter your ${PlatformToTitleMapper.mt5} password`; | ||
return ''; | ||
}; | ||
|
||
const renderFooter = () => { | ||
if (isSuccess) return <WalletButton isFullWidth onClick={hide} size='lg' text='Continue' />; | ||
if (hasMT5Account) | ||
return ( | ||
<WalletButtonGroup> | ||
<WalletButton isFullWidth size='lg' text='Forgot password?' variant='outlined' /> | ||
<WalletButton disabled={!password} isFullWidth onClick={onSubmit} size='lg' text='Add account' /> | ||
</WalletButtonGroup> | ||
); | ||
return ( | ||
<WalletButton | ||
disabled={!password} | ||
isFullWidth | ||
onClick={onSubmit} | ||
size='lg' | ||
text='Create Deriv MT5 Password' | ||
/> | ||
); | ||
}; | ||
|
||
if (isMobile) { | ||
return ( | ||
<ModalStepWrapper renderFooter={renderFooter} title={renderTitle()}> | ||
{isSuccess && ( | ||
<Success | ||
description={`You can now start practicing trading with your ${marketTypeTitle} ${ | ||
isDemo ? ' demo' : 'real' | ||
} account.`} | ||
displayBalance={ | ||
mt5Accounts?.find(account => account.market_type === marketType)?.display_balance || '' | ||
} | ||
marketType={marketType} | ||
platform={platform} | ||
renderButton={() => <WalletButton isFullWidth onClick={hide} size='lg' text='Continue' />} | ||
title={`Your ${marketTypeTitle} ${isDemo ? ' demo' : 'real'} account is ready`} | ||
/> | ||
)} | ||
{!isSuccess && | ||
(hasMT5Account ? ( | ||
<EnterPassword | ||
marketType={marketType} | ||
onPasswordChange={e => setPassword(e.target.value)} | ||
onPrimaryClick={onSubmit} | ||
password={password} | ||
platform='mt5' | ||
/> | ||
) : ( | ||
<CreatePassword | ||
icon={<MT5PasswordIcon />} | ||
onPasswordChange={e => setPassword(e.target.value)} | ||
onPrimaryClick={onSubmit} | ||
password={password} | ||
platform='mt5' | ||
/> | ||
))} | ||
</ModalStepWrapper> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
); | ||
} | ||
|
||
return ( | ||
<ModalWrapper hideCloseButton={isSuccess}> | ||
{isSuccess && ( | ||
|
@@ -90,13 +157,15 @@ const MT5PasswordModal: React.FC<TProps> = ({ marketType, platform }) => { | |
marketType={marketType} | ||
onPasswordChange={e => setPassword(e.target.value)} | ||
onPrimaryClick={onSubmit} | ||
password={password} | ||
platform='mt5' | ||
/> | ||
) : ( | ||
<CreatePassword | ||
icon={<MT5PasswordIcon />} | ||
onPasswordChange={e => setPassword(e.target.value)} | ||
onPrimaryClick={onSubmit} | ||
password={password} | ||
platform='mt5' | ||
/> | ||
))} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,20 @@ import PasswordShowIcon from '../../../../public/images/ic-password-show.svg'; | |
import './CreatePassword.scss'; | ||
import { TPlatforms } from '../../types'; | ||
import { PlatformToTitleMapper } from '../../constants'; | ||
import { WalletButton } from '../../../../components/Base'; | ||
import useDevice from '../../../../hooks/useDevice'; | ||
|
||
type TProps = { | ||
icon: React.ReactNode; | ||
onPasswordChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
onPrimaryClick: () => void; | ||
password: string; | ||
platform: TPlatforms.All; | ||
}; | ||
|
||
const CreatePassword: React.FC<TProps> = ({ icon, onPasswordChange, onPrimaryClick, platform }) => { | ||
const CreatePassword: React.FC<TProps> = ({ icon, onPasswordChange, onPrimaryClick, password, platform }) => { | ||
const { isMobile } = useDevice(); | ||
|
||
const title = PlatformToTitleMapper[platform]; | ||
return ( | ||
<div className='wallets-create-password'> | ||
|
@@ -24,9 +29,14 @@ const CreatePassword: React.FC<TProps> = ({ icon, onPasswordChange, onPrimaryCli | |
<input onChange={onPasswordChange} placeholder={`${title} password`} type='password' /> | ||
<PasswordShowIcon className='wallets-create-password-input-trailing-icon' /> | ||
</div> | ||
<button className='wallets-create-password-button' onClick={onPrimaryClick}> | ||
Create {title} password | ||
</button> | ||
{!isMobile && ( | ||
<WalletButton | ||
disabled={!password} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed an issue where the button is not disabled when user has not entered any password. In design the button was disabled when input was empty Screen.Recording.2023-10-23.at.1.15.49.PM.mov |
||
onClick={onPrimaryClick} | ||
size='lg' | ||
text={`Create ${title} password`} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the components we already created from the base for this file 😃 👍🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduced the header height