Skip to content

Feat: FullScreen Mode in Modal #1045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions src/custom/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import React, { useRef, useState } from 'react';
import { Box, Dialog, IconButton, Paper, Typography } from '../../base';
import { ContainedButton, OutlinedButton, TextButton } from '../../base/Button/Button';
import { iconLarge, iconMedium } from '../../constants/iconsSizes';
import { CloseIcon, InfoCircleIcon } from '../../icons';
import { CloseIcon, FullScreenIcon, InfoCircleIcon } from '../../icons';
import FullScreenExitIcon from '../../icons/Fullscreen/FullScreenExitIcon';
import { darkModalGradient, lightModalGradient } from '../../theme/colors/colors';
import { CustomTooltip } from '../CustomTooltip';

Expand All @@ -12,6 +13,7 @@ interface ModalProps extends DialogProps {
title: string;
headerIcon?: React.ReactNode;
reactNode?: React.ReactNode;
isFullScreenModeAllowed?: boolean;
}

interface ModalFooterProps {
Expand Down Expand Up @@ -56,6 +58,20 @@ const StyledDialog = styled(Dialog)`
}
`;

const FullscreenButton = styled(FullScreenIcon)(({ theme }) => ({
height: '2.25rem',
width: '2.25rem',
fill: theme.palette.common.white,
cursor: 'pointer'
}));

const FullscreenExitButton = styled(FullScreenExitIcon)(({ theme }) => ({
height: '2.25rem',
width: '2.25rem',
fill: theme.palette.common.white,
cursor: 'pointer'
}));

export const ModalStyledHeader = styled('div')(({ theme }) => ({
background: theme.palette.mode === 'light' ? lightModalGradient.header : darkModalGradient.header,
color: '#eee',
Expand Down Expand Up @@ -103,7 +119,8 @@ export const useModal = ({ headerIcon }: { headerIcon: React.ReactNode }): UseMo
export const ModalBody = styled(Paper)(({ theme }) => ({
padding: '1rem',
backgroundColor: theme.palette.background.surfaces,
overflowY: 'auto'
overflowY: 'auto',
height: '100%'
}));

const StyledFooter = styled('div', {
Expand Down Expand Up @@ -135,16 +152,22 @@ export const Modal: React.FC<ModalProps> = ({
reactNode,
children,
maxWidth = 'xs',
isFullScreenModeAllowed,
...props
}) => {
const [fullScreen, setFullScreen] = useState(false);
const toggleFullScreen = () => {
setFullScreen((prev) => !prev);
};
return (
<StyledDialog
fullWidth={true}
maxWidth={maxWidth}
open={open}
onClose={closeModal}
aria-labelledby="alert-dialog-slide-title"
aria-describedby="alert-dialog-slide-description"
fullScreen={fullScreen}
fullWidth={!fullScreen}
{...props}
>
{title && (
Expand All @@ -153,9 +176,20 @@ export const Modal: React.FC<ModalProps> = ({
<Typography component={'div'} variant="h6">
{title}
</Typography>
<CloseBtn onClick={closeModal}>
<CloseIcon {...iconLarge} fill="#fff"></CloseIcon>
</CloseBtn>
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
{isFullScreenModeAllowed && (
<CustomTooltip title={fullScreen ? 'Exit Fullscreen' : 'Enter Fullscreen'}>
{fullScreen ? (
<FullscreenExitButton onClick={toggleFullScreen} />
) : (
<FullscreenButton onClick={toggleFullScreen} />
)}
</CustomTooltip>
)}
<CloseBtn onClick={closeModal}>
<CloseIcon {...iconLarge} fill="#fff"></CloseIcon>
</CloseBtn>
</div>
</ModalStyledHeader>
)}

Expand Down