1
1
import React , { FC } from 'react' ;
2
- import { Box } from 'rebass' ;
3
- import Action from '../../action.type' ;
2
+ import { Box , Flex } from 'rebass' ;
4
3
import Button from '../../button' ;
5
4
6
5
// Components
7
6
import Popup , { PopupProps } from '../index' ;
8
7
import Subtitle from '../../typography/subtitle' ;
9
8
import Text from '../../typography/text' ;
9
+ import { ButtonProps } from '../../..' ;
10
10
11
- export interface TinyPopupProps extends Omit < PopupProps , 'css' | 'children' > {
11
+ export interface TinyPopupProps
12
+ extends Omit <
13
+ PopupProps ,
14
+ 'css' | 'children' | 'disabledMainButton' | 'disabledSecondaryButton'
15
+ > {
12
16
title : string ;
13
17
secondaryText : string ;
14
- mainButton ?: Action < React . MouseEvent < HTMLButtonElement > > ;
15
- secondaryButton ?: Action < React . MouseEvent < HTMLButtonElement > > ;
16
- tertiaryButton ?: Action < React . MouseEvent < HTMLButtonElement > > ;
17
- disabledTertiaryButton ?: boolean ;
18
+ mainButtonProps ?: ButtonProps ;
19
+ secondaryButtonProps ?: ButtonProps ;
20
+ tertiaryButtonProps ?: ButtonProps ;
18
21
onClose ?: ( ) => void ;
19
22
children ?: React . ReactNode ;
20
23
contentHeight ?: string ;
@@ -23,35 +26,27 @@ export interface TinyPopupProps extends Omit<PopupProps, 'css' | 'children'> {
23
26
const TinyPopup : FC < TinyPopupProps > = ( {
24
27
title,
25
28
secondaryText,
26
- mainButton,
27
- secondaryButton,
28
- tertiaryButton,
29
29
onClose = ( ) => { } ,
30
- disabledMainButton = false ,
31
- disabledSecondaryButton = false ,
32
- disabledTertiaryButton = false ,
30
+ mainButtonProps ,
31
+ secondaryButtonProps ,
32
+ tertiaryButtonProps ,
33
33
children,
34
34
contentHeight,
35
+ sx,
35
36
...props
36
37
} : TinyPopupProps ) => {
37
- const [ mainActionTitle , mainActionCallback ] = mainButton || [ ] ;
38
- const [ secondaryActionTitle , secondaryActionCallback ] = secondaryButton || [ ] ;
39
- const [ tertiaryActionTitle , tertiaryActionCallback ] = tertiaryButton || [ ] ;
40
-
41
38
return (
42
39
< Popup
43
- pt = "20px"
44
- pl = "20px"
45
- pr = "20px"
46
- pb = "20px"
40
+ p = "20px"
47
41
width = "fit-content"
48
42
sx = { {
49
43
left : '50%' ,
50
44
top : '50%' ,
51
45
transform : 'translate(-50%, -50%)' ,
46
+ ...sx ,
52
47
} }
53
- { ...props }
54
48
onClose = { onClose }
49
+ { ...props }
55
50
>
56
51
< Subtitle pb = "20px" lineHeight = "22px" >
57
52
{ title }
@@ -62,35 +57,17 @@ const TinyPopup: FC<TinyPopupProps> = ({
62
57
</ Text >
63
58
) }
64
59
< Box sx = { contentHeight ? { height : contentHeight } : { } } > { children } </ Box >
65
- < Box display = "flex" mt = "auto" >
66
- < Box display = "flex" ml = "auto" >
67
- { tertiaryButton && (
68
- < Button
69
- disabled = { disabledTertiaryButton }
70
- intent = "secondary"
71
- onClick = { tertiaryActionCallback }
72
- mr = "20px"
73
- >
74
- { tertiaryActionTitle }
75
- </ Button >
76
- ) }
77
- { secondaryButton && (
78
- < Button
79
- disabled = { disabledSecondaryButton }
80
- intent = "secondary"
81
- onClick = { secondaryActionCallback }
82
- mr = "20px"
83
- >
84
- { secondaryActionTitle }
85
- </ Button >
60
+ < Flex >
61
+ < Flex width = "100%" sx = { { gap : '20px' , justifyContent : 'flex-end' } } >
62
+ { tertiaryButtonProps && (
63
+ < Button intent = "secondary" { ...tertiaryButtonProps } />
86
64
) }
87
- { mainButton && (
88
- < Button disabled = { disabledMainButton } onClick = { mainActionCallback } >
89
- { mainActionTitle }
90
- </ Button >
65
+ { secondaryButtonProps && (
66
+ < Button intent = "secondary" { ...secondaryButtonProps } />
91
67
) }
92
- </ Box >
93
- </ Box >
68
+ { mainButtonProps && < Button { ...mainButtonProps } /> }
69
+ </ Flex >
70
+ </ Flex >
94
71
</ Popup >
95
72
) ;
96
73
} ;
0 commit comments