Skip to content

Commit cfd500c

Browse files
authored
feat(popup): add cross button support to popup (#302)
* feat(popup): add cross button support to popup * Add margin to close button
1 parent 03866ad commit cfd500c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@
126126
"path": "./node_modules/cz-conventional-changelog"
127127
}
128128
}
129-
}
129+
}

src/components/popup/index.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as R from 'ramda';
66
import useKeyUp from '../../utils/useKeyUp';
77
// Styles
88
import getStyles, { backdropStyles } from './popup.styles';
9+
import { IconName } from '../icon';
10+
import IconButton from '../icon-button';
911

1012
export interface PopupProps extends Omit<BoxProps, 'css'> {
1113
children: React.ReactNode;
@@ -22,6 +24,7 @@ export interface PopupProps extends Omit<BoxProps, 'css'> {
2224
disabledMainButton?: boolean;
2325
footer?: React.ReactNode;
2426
disabledSecondaryButton?: boolean;
27+
hasCloseButton?: boolean;
2528
}
2629

2730
const Popup: FC<PopupProps> = ({
@@ -37,6 +40,7 @@ const Popup: FC<PopupProps> = ({
3740
closeOnBackdropClick = true,
3841
footer,
3942
onClose = () => {},
43+
hasCloseButton = false,
4044
sx,
4145
...props
4246
}: PopupProps) => {
@@ -84,6 +88,14 @@ const Popup: FC<PopupProps> = ({
8488
overflowX="visible"
8589
{...props}
8690
>
91+
{hasCloseButton && (
92+
<IconButton
93+
icon={IconName.cross}
94+
sx={{ position: 'absolute', right: 10, top: 10 }}
95+
size="lg"
96+
onClick={onClose}
97+
/>
98+
)}
8799
{children}
88100
{footer && (
89101
<Box width="100%" backgroundColor="grayShade3">

src/components/popup/popup.stories.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ const Template: Story<PopupProps> = (props) => {
4343
return (
4444
<div>
4545
<Button onClick={handleToggle}>Open Drawer</Button>
46-
<Popup isOpen={isOpen} onClose={handleToggle} {...props} />
46+
<Popup isOpen={isOpen} onClose={handleToggle} {...props}>
47+
<div>this is children</div>
48+
</Popup>
4749
</div>
4850
);
4951
};
@@ -299,4 +301,9 @@ Default.argTypes = {
299301
summary: 'Is show backdrop',
300302
},
301303
},
304+
hasCloseButton: {
305+
control: {
306+
type: 'boolean',
307+
},
308+
},
302309
};

0 commit comments

Comments
 (0)