Skip to content

Commit 9d9121f

Browse files
[TRAH] shontzu/TRAH-2644/you-need-a-deriv-account-dialog (deriv-com#12975)
* refactor: add a deriv account dialog * style: small tweak * chore: code review * chore: keyof typeof Headings * chore: better name for Heading variance
1 parent 051fb65 commit 9d9121f

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

packages/tradershub/src/components/Dialog/DialogHeader.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,33 @@ import CloseIcon from '../../public/images/ic-close-dark.svg';
1212
*/
1313
type TDialogHeader = {
1414
className?: string;
15+
heading?: keyof typeof HeadingVariants;
1516
hideCloseButton?: boolean;
1617
title?: string;
1718
};
1819

20+
const HeadingVariants = {
21+
h1: Heading.H1,
22+
h2: Heading.H2,
23+
h3: Heading.H3,
24+
h4: Heading.H4,
25+
h5: Heading.H5,
26+
h6: Heading.H6,
27+
};
28+
1929
/**
2030
* DialogHeader component
2131
* @param {TDialogHeader} props - The properties that define the DialogHeader component.
2232
* @returns {JSX.Element} The DialogHeader component.
2333
*/
24-
const DialogHeader = ({ className, hideCloseButton = false, title }: TDialogHeader) => {
34+
const DialogHeader = ({ className, heading = 'h3', hideCloseButton = false, title }: TDialogHeader) => {
35+
const Heading = HeadingVariants[heading];
36+
2537
const { hide } = Provider.useModal();
2638

2739
return (
2840
<div className={qtMerge('flex items-start', title ? 'justify-between' : 'justify-end', className)}>
29-
{title && <Heading.H3 className='flex-1'>{title}</Heading.H3>}
41+
{title && <Heading className='flex-1'>{title}</Heading>}
3042
{!hideCloseButton && <CloseIcon className='hover:cursor-pointer' onClick={hide} />}
3143
</div>
3244
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import { Button, Text } from '@deriv/quill-design';
3+
import { Dialog } from '../Dialog';
4+
5+
/**
6+
* `GetADerivAccountDialog` is opened when user tried to create a CFD account without a Deriv account
7+
* It includes a button that leads the user to a modal where they can create a Deriv account.
8+
*
9+
* @returns {React.ReactElement} A `<Dialog>` component containing the dialog message and action button.
10+
*/
11+
const GetADerivAccountDialog = () => {
12+
return (
13+
<Dialog className='lg:w-[440px]'>
14+
<Dialog.Header heading='h5' hideCloseButton title="You'll need a Deriv account" />
15+
<Dialog.Content>
16+
<Text size='sm'>A Deriv account will allow you to fund (and withdraw from) your MT5 account(s). </Text>
17+
</Dialog.Content>
18+
<Dialog.Action align='right'>
19+
<Button className='rounded-200 h-2000 px-500' colorStyle='black' size='md' variant='secondary'>
20+
Cancel
21+
</Button>
22+
<Button className='rounded-200 h-2000 px-500' colorStyle='coral' size='md' variant='primary'>
23+
Add a Deriv account
24+
</Button>
25+
</Dialog.Action>
26+
</Dialog>
27+
);
28+
};
29+
30+
export default GetADerivAccountDialog;
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { default as GetADerivAccountBanner } from './GetADerivAccountBanner';
2+
export { default as GetADerivAccountDialog } from './GetADerivAccountDialog';

0 commit comments

Comments
 (0)