Skip to content

Commit b96cdee

Browse files
authored
Merge pull request #1045 from vr-varad/fix/maximize_help_modal
Feat: FullScreen Mode in Modal
2 parents 6ecae96 + 53ffae6 commit b96cdee

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

src/custom/Modal/index.tsx

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import React, { useRef, useState } from 'react';
33
import { Box, Dialog, IconButton, Paper, Typography } from '../../base';
44
import { ContainedButton, OutlinedButton, TextButton } from '../../base/Button/Button';
55
import { iconLarge, iconMedium } from '../../constants/iconsSizes';
6-
import { CloseIcon, InfoCircleIcon } from '../../icons';
6+
import { CloseIcon, FullScreenIcon, InfoCircleIcon } from '../../icons';
7+
import FullScreenExitIcon from '../../icons/Fullscreen/FullScreenExitIcon';
78
import { darkModalGradient, lightModalGradient } from '../../theme/colors/colors';
89
import { CustomTooltip } from '../CustomTooltip';
910

@@ -12,6 +13,7 @@ interface ModalProps extends DialogProps {
1213
title: string;
1314
headerIcon?: React.ReactNode;
1415
reactNode?: React.ReactNode;
16+
isFullScreenModeAllowed?: boolean;
1517
}
1618

1719
interface ModalFooterProps {
@@ -56,6 +58,20 @@ const StyledDialog = styled(Dialog)`
5658
}
5759
`;
5860

61+
const FullscreenButton = styled(FullScreenIcon)(({ theme }) => ({
62+
height: '2.25rem',
63+
width: '2.25rem',
64+
fill: theme.palette.common.white,
65+
cursor: 'pointer'
66+
}));
67+
68+
const FullscreenExitButton = styled(FullScreenExitIcon)(({ theme }) => ({
69+
height: '2.25rem',
70+
width: '2.25rem',
71+
fill: theme.palette.common.white,
72+
cursor: 'pointer'
73+
}));
74+
5975
export const ModalStyledHeader = styled('div')(({ theme }) => ({
6076
background: theme.palette.mode === 'light' ? lightModalGradient.header : darkModalGradient.header,
6177
color: '#eee',
@@ -103,7 +119,8 @@ export const useModal = ({ headerIcon }: { headerIcon: React.ReactNode }): UseMo
103119
export const ModalBody = styled(Paper)(({ theme }) => ({
104120
padding: '1rem',
105121
backgroundColor: theme.palette.background.surfaces,
106-
overflowY: 'auto'
122+
overflowY: 'auto',
123+
height: '100%'
107124
}));
108125

109126
const StyledFooter = styled('div', {
@@ -135,16 +152,22 @@ export const Modal: React.FC<ModalProps> = ({
135152
reactNode,
136153
children,
137154
maxWidth = 'xs',
155+
isFullScreenModeAllowed,
138156
...props
139157
}) => {
158+
const [fullScreen, setFullScreen] = useState(false);
159+
const toggleFullScreen = () => {
160+
setFullScreen((prev) => !prev);
161+
};
140162
return (
141163
<StyledDialog
142-
fullWidth={true}
143164
maxWidth={maxWidth}
144165
open={open}
145166
onClose={closeModal}
146167
aria-labelledby="alert-dialog-slide-title"
147168
aria-describedby="alert-dialog-slide-description"
169+
fullScreen={fullScreen}
170+
fullWidth={!fullScreen}
148171
{...props}
149172
>
150173
{title && (
@@ -153,9 +176,20 @@ export const Modal: React.FC<ModalProps> = ({
153176
<Typography component={'div'} variant="h6">
154177
{title}
155178
</Typography>
156-
<CloseBtn onClick={closeModal}>
157-
<CloseIcon {...iconLarge} fill="#fff"></CloseIcon>
158-
</CloseBtn>
179+
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
180+
{isFullScreenModeAllowed && (
181+
<CustomTooltip title={fullScreen ? 'Exit Fullscreen' : 'Enter Fullscreen'}>
182+
{fullScreen ? (
183+
<FullscreenExitButton onClick={toggleFullScreen} />
184+
) : (
185+
<FullscreenButton onClick={toggleFullScreen} />
186+
)}
187+
</CustomTooltip>
188+
)}
189+
<CloseBtn onClick={closeModal}>
190+
<CloseIcon {...iconLarge} fill="#fff"></CloseIcon>
191+
</CloseBtn>
192+
</div>
159193
</ModalStyledHeader>
160194
)}
161195

0 commit comments

Comments
 (0)