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.
[DTRA] / Kate / DTRA-680 / Add popup for "Turbos" launch (deriv-com#1…
…2761) * refactor: launch modal for turbos * refactor: remove unused images * feat: add functionality for opening description * refactor: test cases * chore: remove unused icon * fix: add check for popup * fix: add one more setter
- Loading branch information
1 parent
8872a9b
commit c7eb068
Showing
20 changed files
with
262 additions
and
134 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
...ges/trader/src/App/Components/Elements/LaunchModal/__tests__/launch-modal-button.spec.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,37 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import LaunchModalButton from '../launch-modal-button'; | ||
|
||
const default_props = { | ||
handleOpen: jest.fn(), | ||
setShowDescription: jest.fn(), | ||
}; | ||
|
||
const confirm_button = 'Ok'; | ||
const learn_more_button = 'Learn more'; | ||
|
||
describe('<LaunchModalButton />', () => { | ||
it('should render LaunchModalButton', () => { | ||
render(<LaunchModalButton {...default_props} />); | ||
|
||
expect(screen.getByText(confirm_button)).toBeInTheDocument(); | ||
expect(screen.getByText(learn_more_button)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call only handleOpen function if user click on OK button', () => { | ||
render(<LaunchModalButton {...default_props} />); | ||
|
||
userEvent.click(screen.getByText(confirm_button)); | ||
expect(default_props.handleOpen).toBeCalled(); | ||
expect(default_props.setShowDescription).not.toBeCalled(); | ||
}); | ||
|
||
it('should call both handleOpen and setShowDescription function if user click on Learn more button', () => { | ||
render(<LaunchModalButton {...default_props} />); | ||
|
||
userEvent.click(screen.getByText(learn_more_button)); | ||
expect(default_props.handleOpen).toBeCalled(); | ||
expect(default_props.setShowDescription).toBeCalled(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/trader/src/App/Components/Elements/LaunchModal/__tests__/launch-modal-info.spec.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,14 @@ | ||
import React from 'react'; | ||
import LaunchModalInfo from '../launch-modal-info'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
jest.mock('Assets/SvgComponents/trade_explanations/img-turbos.svg', () => jest.fn(() => <div>Turbos Image</div>)); | ||
|
||
describe('<LaunchModalInfo />', () => { | ||
it('should render component', () => { | ||
render(<LaunchModalInfo is_mobile />); | ||
|
||
expect(screen.getByText('Turbos Image')).toBeInTheDocument(); | ||
expect(screen.getByText('Turbos — a new trade type for you!')).toBeInTheDocument(); | ||
}); | ||
}); |
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
3 changes: 3 additions & 0 deletions
3
packages/trader/src/App/Components/Elements/LaunchModal/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,3 @@ | ||
import LaunchModal from './launch-modal'; | ||
|
||
export default LaunchModal; |
31 changes: 31 additions & 0 deletions
31
packages/trader/src/App/Components/Elements/LaunchModal/launch-modal-button.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,31 @@ | ||
import React from 'react'; | ||
import { Button, Modal } from '@deriv/components'; | ||
import { Localize } from '@deriv/translations'; | ||
|
||
const LaunchModalButton = ({ | ||
handleOpen, | ||
setShowDescription, | ||
}: { | ||
handleOpen: () => void; | ||
setShowDescription: (status: boolean) => void; | ||
}) => ( | ||
<Modal.Footer has_separator> | ||
<Button | ||
className='launch-button' | ||
has_effect | ||
onClick={() => { | ||
handleOpen(); | ||
setShowDescription(true); | ||
}} | ||
secondary | ||
large | ||
> | ||
<Localize i18n_default_text='Learn more' /> | ||
</Button> | ||
<Button className='launch-button' has_effect onClick={handleOpen} primary large> | ||
<Localize i18n_default_text='Ok' /> | ||
</Button> | ||
</Modal.Footer> | ||
); | ||
|
||
export default LaunchModalButton; |
26 changes: 26 additions & 0 deletions
26
packages/trader/src/App/Components/Elements/LaunchModal/launch-modal-info.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,26 @@ | ||
import React from 'react'; | ||
import ImageTurbos from 'Assets/SvgComponents/trade_explanations/img-turbos.svg'; | ||
import { Text } from '@deriv/components'; | ||
import { Localize } from '@deriv/translations'; | ||
|
||
const LaunchModalInfo = ({ is_mobile }: { is_mobile?: boolean }) => { | ||
return ( | ||
<div className='modal_content' data-testid='launch-modal'> | ||
<ImageTurbos className='modal_image' viewBox={is_mobile ? '0 0 328 164' : '56 18 216 128'} /> | ||
<Text as='h1' weight='bold' align='center' size={is_mobile ? 'xsm' : 'sm'}> | ||
<Localize i18n_default_text='Turbos — a new trade type for you!' /> | ||
</Text> | ||
<Text as='p' align='center'> | ||
<Localize i18n_default_text='Power up your market view.' /> | ||
</Text> | ||
<Text as='p' align='center'> | ||
<Localize i18n_default_text='High potential payout. Limited risk.' /> | ||
</Text> | ||
<Text as='p' align='center'> | ||
<Localize i18n_default_text='Available on both demo and real accounts.' /> | ||
</Text> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LaunchModalInfo; |
59 changes: 59 additions & 0 deletions
59
packages/trader/src/App/Components/Elements/LaunchModal/launch-modal.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,59 @@ | ||
// For Web Modal | ||
.dc-modal__container_launch-modal-root { | ||
text-align: center; | ||
|
||
.dc-modal-body { | ||
justify-content: center; | ||
display: flex; | ||
height: 100%; | ||
|
||
.modal { | ||
&_image { | ||
margin: 2.4rem 0rem; | ||
width: 21.6rem; | ||
height: 12.8rem; | ||
border-radius: 0.6rem; | ||
} | ||
} | ||
} | ||
|
||
.dc-modal-footer { | ||
.launch-button { | ||
min-width: 5.1rem; | ||
} | ||
} | ||
} | ||
|
||
// For Mobile | ||
.launch-page-mobile { | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
|
||
.modal { | ||
&_content { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 1rem; | ||
} | ||
|
||
&_image { | ||
margin-bottom: 2.4rem; | ||
border-radius: 0.6rem; | ||
} | ||
} | ||
|
||
.dc-modal-footer { | ||
border-top: 0.2rem solid var(--general-section-5); | ||
padding: 1.6rem; | ||
|
||
.launch-button { | ||
height: 4rem; | ||
width: 100%; | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/trader/src/App/Components/Elements/LaunchModal/launch-modal.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 { DesktopWrapper, MobileWrapper, Modal, UILoader } from '@deriv/components'; | ||
import LaunchModalInfo from './launch-modal-info'; | ||
import LaunchModalButton from './launch-modal-button'; | ||
import './launch-modal.scss'; | ||
|
||
type LaunchModalProps = { | ||
handleChange: () => void; | ||
open: boolean; | ||
setShowDescription: (status: boolean) => void; | ||
}; | ||
|
||
const LaunchModal = ({ handleChange, open, setShowDescription }: LaunchModalProps) => ( | ||
<React.Suspense fallback={<UILoader />}> | ||
<DesktopWrapper> | ||
<Modal | ||
is_open={open} | ||
className='launch-modal-root' | ||
height='440px' | ||
width='440px' | ||
toggleModal={handleChange} | ||
should_close_on_click_outside | ||
portalId='launch_modal_root' | ||
> | ||
<Modal.Body> | ||
<LaunchModalInfo /> | ||
</Modal.Body> | ||
<LaunchModalButton handleOpen={handleChange} setShowDescription={setShowDescription} /> | ||
</Modal> | ||
</DesktopWrapper> | ||
<MobileWrapper> | ||
<div className='launch-page-mobile'> | ||
<LaunchModalInfo is_mobile /> | ||
<LaunchModalButton handleOpen={handleChange} setShowDescription={setShowDescription} /> | ||
</div> | ||
</MobileWrapper> | ||
</React.Suspense> | ||
); | ||
|
||
export default LaunchModal; |
1 change: 1 addition & 0 deletions
1
packages/trader/src/Assets/SvgComponents/trade_explanations/img-turbos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions
10
...les/SmartChartBeta/Components/LaunchModal/__tests__/launch-modal-continue-button.spec.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...er/src/Modules/SmartChartBeta/Components/LaunchModal/__tests__/launch-modal-info.spec.tsx
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...trader/src/Modules/SmartChartBeta/Components/LaunchModal/launch-modal-continue-button.tsx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
packages/trader/src/Modules/SmartChartBeta/Components/LaunchModal/launch-modal-info.tsx
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
packages/trader/src/Modules/SmartChartBeta/Components/LaunchModal/launch-modal.scss
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.