Skip to content

Commit dd297bd

Browse files
author
roshni73
committed
Add Close Button for infopopup component
1 parent 4ecd8cd commit dd297bd

File tree

8 files changed

+51
-8
lines changed

8 files changed

+51
-8
lines changed

packages/go-ui-storybook/src/stories/InfoPopup.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import type {
66

77
import InfoPopup from './InfoPopup';
88

9-
type Story = StoryObj<InfoPopupProps>;
9+
type InfoPoppupSpecificProps = InfoPopupProps<string>;
10+
type Story = StoryObj<InfoPoppupSpecificProps>;
1011

1112
const meta: Meta<typeof InfoPopup> = {
1213
title: 'Components/InfoPopup',

packages/go-ui-storybook/src/stories/InfoPopup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
InfoPopupProps,
44
} from '@ifrc-go/ui';
55

6-
function InfoPopup(props: InfoPopupProps) {
6+
function InfoPopup <N extends string>(props: InfoPopupProps<N>) {
77
return (
88
<PureInfoPopup {...props} />// eslint-disable-line react/jsx-props-no-spreading
99
);

packages/ui/src/components/Button/styles.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
display: inline-flex;
1212
position: relative;
1313
align-items: center;
14+
text-align: center;
1415
border: var(--go-ui-width-separator-sm) solid var(--color-border);
1516
border-radius: var(--border-radius);
1617
background-color: var(--color-background);
@@ -21,7 +22,7 @@
2122
max-width: 100%;
2223
overflow: hidden;
2324
text-transform: var(--text-transform);
24-
line-height: var(--go-ui-line-height-xs);
25+
line-height: 21px;
2526
color: var(--color-text);
2627
font-family: inherit;
2728
font-size: var(--font-size);

packages/ui/src/components/DropdownMenu/styles.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@
1717
display: flex;
1818
flex-direction: column;
1919
padding: var(--go-ui-spacing-sm) 0;
20+
21+
:hover {
22+
background-color:var(--go-ui-color-gray)
23+
}
2024
}

packages/ui/src/components/Heading/styles.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
margin: 0;
55
line-height: var(--line-height);
66
font-size: var(--font-size);
7-
font-weight: var(--go-ui-font-weight-semibold);
7+
font-weight: 500;
88

99
&.modal-font-weight {
1010
font-weight: var(--go-ui-font-weight-medium);

packages/ui/src/components/InfoPopup/index.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { InformationLineIcon } from '@ifrc-go/icons';
1+
import { useCallback } from 'react';
2+
import {
3+
CloseLineIcon,
4+
InformationLineIcon,
5+
} from '@ifrc-go/icons';
26
import { _cs } from '@togglecorp/fujs';
37

8+
import Button from '#components/Button';
49
import Container from '#components/Container';
510
import DropdownMenu from '#components/DropdownMenu';
611

712
import 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>

packages/ui/src/components/InfoPopup/styles.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,13 @@
2323
white-space: pre-wrap;
2424
gap: var(--go-ui-spacing-xs);
2525
font-size: var(--go-ui-font-size-sm);
26+
27+
.heading {
28+
font-weight: 500;
29+
}
30+
}
31+
.close-icon {
32+
font-size: var(--go-ui-font-size-2xl);
2633
}
34+
2735
}

packages/ui/src/components/InputContainer/styles.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
padding: 0 var(--go-ui-spacing-sm);
1111

1212
.input {
13-
padding: var(--go-ui-spacing-xs) 0;
13+
padding-left:12px;
1414
height: 32px;
1515
}
1616
}

0 commit comments

Comments
 (0)