Skip to content

Commit ee21059

Browse files
committed
Fix: Themed Modal
Signed-off-by: vr-varad <[email protected]>
1 parent 1baa4b9 commit ee21059

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

src/custom/Modal/index.tsx

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ interface ModalProps extends DialogProps {
1414
headerIcon?: React.ReactNode;
1515
reactNode?: React.ReactNode;
1616
isFullScreenModeAllowed?: boolean;
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18+
headerBg?: any;
1719
}
1820

1921
interface ModalFooterProps {
2022
children: React.ReactNode;
2123
variant?: 'filled' | 'transparent';
2224
helpText?: string;
2325
hasHelpText?: boolean;
26+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27+
footerBg?: any;
2428
}
2529

2630
type openModalCallback = (props: {
@@ -72,8 +76,13 @@ const FullscreenExitButton = styled(FullScreenExitIcon)(({ theme }) => ({
7276
cursor: 'pointer'
7377
}));
7478

75-
export const ModalStyledHeader = styled('div')(({ theme }) => ({
76-
background: theme.palette.mode === 'light' ? lightModalGradient.header : darkModalGradient.header,
79+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
80+
export const ModalStyledHeader = styled('div')<{ headerBg?: any }>(({ theme, headerBg }) => ({
81+
background: headerBg
82+
? `linear-gradient(90deg, ${headerBg?.secondaryBar}, ${headerBg.mainBar})`
83+
: theme.palette.mode === 'light'
84+
? lightModalGradient.header
85+
: darkModalGradient.header,
7786
color: '#eee',
7887
display: 'flex',
7988
justifyContent: 'space-between',
@@ -130,12 +139,14 @@ export const ModalBody = styled(Paper)(({ theme }) => ({
130139

131140
const StyledFooter = styled('div', {
132141
shouldForwardProp: (prop) => prop !== 'variant'
133-
})<ModalFooterProps>(({ theme, variant, hasHelpText }) => ({
142+
})<ModalFooterProps>(({ theme, variant, hasHelpText, footerBg }) => ({
134143
background:
135144
variant === 'filled'
136-
? theme.palette.mode === 'light'
137-
? lightModalGradient.fotter
138-
: darkModalGradient.fotter
145+
? footerBg
146+
? `linear-gradient(90deg, ${footerBg.mainBar}, ${footerBg.secondaryBar})`
147+
: theme.palette.mode === 'light'
148+
? lightModalGradient.fotter
149+
: darkModalGradient.fotter
139150
: 'transparent',
140151
display: 'flex',
141152
alignItems: 'center',
@@ -158,6 +169,7 @@ export const Modal: React.FC<ModalProps> = ({
158169
children,
159170
maxWidth = 'xs',
160171
isFullScreenModeAllowed,
172+
headerBg,
161173
...props
162174
}) => {
163175
const [fullScreen, setFullScreen] = useState(false);
@@ -176,7 +188,7 @@ export const Modal: React.FC<ModalProps> = ({
176188
{...props}
177189
>
178190
{title && (
179-
<ModalStyledHeader className="modal-header">
191+
<ModalStyledHeader className="modal-header" headerBg={headerBg}>
180192
{headerIcon && headerIcon}
181193
<Typography component={'div'} variant="h6">
182194
{title}
@@ -204,9 +216,19 @@ export const Modal: React.FC<ModalProps> = ({
204216
);
205217
};
206218

207-
export const ModalFooter: React.FC<ModalFooterProps> = ({ helpText, children, variant }) => {
219+
export const ModalFooter: React.FC<ModalFooterProps> = ({
220+
helpText,
221+
children,
222+
variant,
223+
footerBg
224+
}) => {
208225
return (
209-
<StyledFooter className="modal-footer" variant={variant} hasHelpText={!!helpText}>
226+
<StyledFooter
227+
className="modal-footer"
228+
footerBg={footerBg}
229+
variant={variant}
230+
hasHelpText={!!helpText}
231+
>
210232
{helpText && (
211233
<CustomTooltip title={helpText} variant="standard" placement="top">
212234
<IconButton>

0 commit comments

Comments
 (0)