1- import { InformationLineIcon } from '@ifrc-go/icons' ;
1+ import { useCallback } from 'react' ;
2+ import {
3+ CloseLineIcon ,
4+ InformationLineIcon ,
5+ } from '@ifrc-go/icons' ;
26import { _cs } from '@togglecorp/fujs' ;
37
8+ import Button from '#components/Button' ;
49import Container from '#components/Container' ;
510import DropdownMenu from '#components/DropdownMenu' ;
611
712import styles from './styles.module.css' ;
813
9- export interface Props {
14+ export interface Props < N > {
15+ name : N ;
1016 icon ?: React . ReactNode ;
1117 withoutIcon ?: boolean ;
1218 infoLabel ?: React . ReactNode ;
@@ -15,20 +21,32 @@ export interface Props {
1521 descriptionClassName ?: string ;
1622 popupClassName ?: string ;
1723 className ?: string ;
24+ onCloseButtonClick ?: ( name : string ) => void ;
1825}
1926
20- function InfoPopup ( props : Props ) {
27+ function InfoPopup < N extends string > ( props : Props < N > ) {
2128 const {
29+ name,
2230 className,
2331 icon = < InformationLineIcon /> ,
2432 infoLabel,
2533 title,
2634 description,
2735 withoutIcon,
36+ onCloseButtonClick,
2837 popupClassName,
2938 descriptionClassName,
3039 } = props ;
3140
41+ const handleCloseButtonClick = useCallback (
42+ ( ) => {
43+ if ( onCloseButtonClick ) {
44+ onCloseButtonClick ( name ) ;
45+ }
46+ } ,
47+ [ onCloseButtonClick , name ] ,
48+ ) ;
49+
3250 return (
3351 < DropdownMenu
3452 label = { (
@@ -50,6 +68,17 @@ function InfoPopup(props: Props) {
5068 heading = { title }
5169 childrenContainerClassName = { _cs ( descriptionClassName , styles . content ) }
5270 withInternalPadding
71+ withHeaderBorder
72+ actions = { (
73+ < Button
74+ name = { undefined }
75+ onClick = { handleCloseButtonClick }
76+ variant = "tertiary"
77+ title = "Close"
78+ >
79+ < CloseLineIcon className = { styles . closeIcon } />
80+ </ Button >
81+ ) }
5382 >
5483 { description }
5584 </ Container >
0 commit comments