Skip to content

Commit fe63685

Browse files
authored
feat: migrate wrappers (#3556)
1 parent a91bbc4 commit fe63685

File tree

2 files changed

+70
-71
lines changed

2 files changed

+70
-71
lines changed
Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { Dialog, DialogType, Spinner } from '@fluentui/react';
1+
import {
2+
Dialog,
3+
DialogActions,
4+
DialogBody,
5+
DialogContent,
6+
DialogSurface,
7+
DialogTitle,
8+
Spinner
9+
} from '@fluentui/react-components';
210
import { Suspense } from 'react';
311

412
import { WrapperProps } from './popups.types';
@@ -7,43 +15,25 @@ export function DialogWrapper(props: WrapperProps) {
715
const { isOpen, dismissPopup, Component, popupsProps, closePopup } = props;
816
const { settings: { title, subtitle } } = popupsProps;
917

10-
const getDialogType = () => {
11-
switch (popupsProps.settings.width) {
12-
case 'md':
13-
return DialogType.normal;
14-
case 'lg':
15-
return DialogType.largeHeader;
16-
}
17-
return DialogType.normal;
18-
}
19-
20-
const type = getDialogType();
21-
2218
return (
23-
<Dialog
24-
hidden={!isOpen}
25-
onDismiss={() => dismissPopup()}
26-
dialogContentProps={{
27-
type,
28-
title: title?.toString(),
29-
isMultiline: false,
30-
subText: subtitle?.toString()
31-
}}
32-
>
33-
{
34-
<Suspense fallback={<Spinner />}>
35-
36-
<Component
37-
{...popupsProps}
38-
data={popupsProps.data || {}}
39-
dismissPopup={() => dismissPopup()}
40-
closePopup={(e: any) => closePopup(e)}
41-
/>
42-
{
43-
popupsProps.settings.renderFooter && popupsProps.settings.renderFooter()
44-
}
45-
</Suspense>
46-
}
19+
<Dialog open={isOpen} onOpenChange={(_, data) => !data.open && dismissPopup()}>
20+
<DialogSurface>
21+
<DialogBody>
22+
<DialogTitle>{title?.toString()}</DialogTitle>
23+
<DialogContent>{subtitle?.toString()}</DialogContent>
24+
<Suspense fallback={<Spinner />}>
25+
<Component
26+
{...popupsProps}
27+
data={popupsProps.data || {}}
28+
dismissPopup={() => dismissPopup()}
29+
closePopup={(e: any) => closePopup(e)}
30+
/>
31+
{popupsProps.settings.renderFooter && (
32+
<DialogActions>{popupsProps.settings.renderFooter()}</DialogActions>
33+
)}
34+
</Suspense>
35+
</DialogBody>
36+
</DialogSurface>
4737
</Dialog>
4838
);
4939
}
Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
import { IconButton, Modal, Spinner } from '@fluentui/react';
1+
import {
2+
Dialog,
3+
DialogActions,
4+
DialogBody,
5+
DialogContent,
6+
DialogSurface,
7+
DialogTitle,
8+
DialogTrigger,
9+
Spinner
10+
} from '@fluentui/react-components';
11+
import { Dismiss20Regular } from '@fluentui/react-icons';
212
import { Suspense } from 'react';
313

414
import { translateMessage } from '../../../utils/translate-messages';
@@ -8,37 +18,36 @@ export function ModalWrapper(props: WrapperProps) {
818
const { isOpen, dismissPopup, Component, popupsProps, closePopup } = props;
919

1020
return (
11-
<Modal
12-
isOpen={isOpen}
13-
onDismiss={() => dismissPopup()}
14-
layerProps={{ eventBubblingEnabled: true }}
15-
>
16-
<IconButton
17-
styles={{
18-
root: {
19-
float: 'right',
20-
zIndex: 1
21-
}
22-
}}
23-
iconProps={{ iconName: 'Cancel' }}
24-
ariaLabel={translateMessage('Close expanded response area')}
25-
onClick={() => closePopup()}
26-
/>
27-
{
28-
<Suspense fallback={<Spinner />}>
29-
<Component
30-
{...popupsProps}
31-
data={popupsProps.data || {}}
32-
dismissPopup={() => dismissPopup()}
33-
closePopup={(e: any) => closePopup(e)}
34-
/>
35-
{
36-
popupsProps.settings.renderFooter && popupsProps.settings.renderFooter()
37-
}
38-
</Suspense>
39-
}
40-
</Modal>
21+
<Dialog open={isOpen} onOpenChange={(_, data) => !data.open && dismissPopup()}>
22+
<DialogSurface>
23+
<DialogBody>
24+
<DialogTitle
25+
action={
26+
<DialogTrigger>
27+
<Dismiss20Regular
28+
aria-label={translateMessage('Close expanded response area')}
29+
onClick={() => closePopup()}
30+
/>
31+
</DialogTrigger>
32+
}
33+
>
34+
{popupsProps.settings.title?.toString()}
35+
</DialogTitle>
36+
<DialogContent>
37+
<Suspense fallback={<Spinner />}>
38+
<Component
39+
{...popupsProps}
40+
data={popupsProps.data || {}}
41+
dismissPopup={() => dismissPopup()}
42+
closePopup={(e: any) => closePopup(e)}
43+
/>
44+
{popupsProps.settings.renderFooter && (
45+
<DialogActions>{popupsProps.settings.renderFooter()}</DialogActions>
46+
)}
47+
</Suspense>
48+
</DialogContent>
49+
</DialogBody>
50+
</DialogSurface>
51+
</Dialog>
4152
);
42-
}
43-
44-
53+
}

0 commit comments

Comments
 (0)