refactor: create wide modal variant

This commit is contained in:
Carlos Valente
2026-03-26 21:30:49 +01:00
committed by Carlos Valente
parent 97cb41dc5a
commit cb9528d894
2 changed files with 23 additions and 3 deletions
@@ -11,12 +11,22 @@
background-color: $gray-1250; background-color: $gray-1250;
color: $ui-white; color: $ui-white;
border-radius: 3px; border-radius: $component-border-radius-md;
box-shadow: $box-shadow-l1; box-shadow: $box-shadow-l1;
border: 1px solid $gray-1100; border: 1px solid $gray-1100;
outline: none; outline: none;
} }
.wide {
top: 4vh;
min-width: min(1280px, 96vw);
max-width: min(1600px, 96vw);
height: 88vh;
max-height: 88vh;
display: flex;
flex-direction: column;
}
.backdrop { .backdrop {
position: fixed; position: fixed;
inset: 0; inset: 0;
@@ -48,6 +58,13 @@
overflow-y: auto; overflow-y: auto;
} }
.wide .body {
flex: 1;
min-height: 0;
max-height: none;
overflow: hidden;
}
.footer { .footer {
padding-block: 1rem; padding-block: 1rem;
display: flex; display: flex;
@@ -2,6 +2,7 @@ import { Dialog as BaseDialog } from '@base-ui/react/dialog';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { IoClose } from 'react-icons/io5'; import { IoClose } from 'react-icons/io5';
import { cx } from '../../utils/styleUtils';
import IconButton from '../buttons/IconButton'; import IconButton from '../buttons/IconButton';
import style from './Modal.module.scss'; import style from './Modal.module.scss';
@@ -11,6 +12,7 @@ interface ModalProps {
title?: string; title?: string;
showCloseButton?: boolean; showCloseButton?: boolean;
showBackdrop?: boolean; showBackdrop?: boolean;
size?: 'default' | 'wide';
bodyElements: ReactNode; bodyElements: ReactNode;
footerElements?: ReactNode; footerElements?: ReactNode;
onClose: () => void; onClose: () => void;
@@ -21,6 +23,7 @@ export default function Modal({
title, title,
showCloseButton, showCloseButton,
showBackdrop, showBackdrop,
size = 'default',
bodyElements, bodyElements,
footerElements, footerElements,
onClose, onClose,
@@ -35,7 +38,7 @@ export default function Modal({
> >
<BaseDialog.Portal> <BaseDialog.Portal>
{showBackdrop && <BaseDialog.Backdrop className={style.backdrop} />} {showBackdrop && <BaseDialog.Backdrop className={style.backdrop} />}
<BaseDialog.Popup className={style.modal}> <BaseDialog.Popup className={cx([style.modal, size === 'wide' && style.wide])}>
<div className={style.title}> <div className={style.title}>
{title} {title}
{showCloseButton && ( {showCloseButton && (
@@ -45,7 +48,7 @@ export default function Modal({
)} )}
</div> </div>
<div className={style.body}>{bodyElements}</div> <div className={style.body}>{bodyElements}</div>
<div className={style.footer}>{footerElements}</div> {footerElements ? <div className={style.footer}>{footerElements}</div> : null}
</BaseDialog.Popup> </BaseDialog.Popup>
</BaseDialog.Portal> </BaseDialog.Portal>
</BaseDialog.Root> </BaseDialog.Root>