Update modal

This commit is contained in:
2025-02-25 23:19:45 -05:00
parent 29724da42f
commit d1b0a499a8
6 changed files with 24 additions and 9 deletions

View File

@@ -12,6 +12,13 @@ export default function Modal(props: ModalProps){
className, className,
children children
} = props; } = props;
const divProps = {...props};
delete divProps["children"];
delete divProps["display"];
delete divProps["backgroundType"];
delete divProps["backgroundClassName"];
delete divProps["close"];
delete divProps["className"];
return ( return (
@@ -25,7 +32,7 @@ export default function Modal(props: ModalProps){
close={close} close={close}
/> />
<div <div
{...props} {...divProps}
className={clsx( className={clsx(
"fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-50", "fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-50",
"flex flex-col rounded-lg max-h-full shadow-lg shadow-[#00000066]", "flex flex-col rounded-lg max-h-full shadow-lg shadow-[#00000066]",

View File

@@ -8,6 +8,10 @@ export default function ModalBackground(props: ModalBackgroundProps){
close, close,
className className
} = props; } = props;
const divProps = { ...props };
delete divProps["backgroundType"];
delete divProps["close"];
delete divProps["className"];
if(backgroundType === "none"){ if(backgroundType === "none"){
@@ -17,7 +21,7 @@ export default function ModalBackground(props: ModalBackgroundProps){
return ( return (
<div <div
{...props} {...divProps}
className={clsx( className={clsx(
"fixed left-0 top-0 w-full h-full z-40", "fixed left-0 top-0 w-full h-full z-40",
"flex flex-row justify-center items-center", "flex flex-row justify-center items-center",

View File

@@ -9,11 +9,15 @@ export default function ModalHeader(props: ModalHeaderProps){
className, className,
children children
} = props; } = props;
const divProps = {...props};
delete divProps["close"];
delete divProps["className"];
delete divProps["children"];
return ( return (
<div <div
{...props} {...divProps}
className={clsx( className={clsx(
"flex flex-row justify-center w-full rounded-t-lg", "flex flex-row justify-center w-full rounded-t-lg",
className className

View File

@@ -34,7 +34,6 @@ a.active {
} }
body { body {
display: flex;
place-items: center; place-items: center;
min-width: 320px; min-width: 320px;
min-height: 100vh; min-height: 100vh;

View File

@@ -7,14 +7,14 @@ export type ModalHeaderFooterBackgroundType = "darken" | "lighten" | "none";
export interface ModalBackgroundProps extends HTMLProps<HTMLDivElement>{ export interface ModalBackgroundProps extends HTMLProps<HTMLDivElement>{
backgroundType?: ModalBackgroundType; backgroundType?: ModalBackgroundType;
close: () => void; close?: () => void;
} }
export interface ModalProps extends HTMLProps<HTMLDivElement>{ export interface ModalProps extends HTMLProps<HTMLDivElement>{
display: boolean; display?: boolean;
backgroundType?: ModalBackgroundType; backgroundType?: ModalBackgroundType;
backgroundClassName?: string; backgroundClassName?: string;
close: () => void; close?: () => void;
children: React.ReactNode; children: React.ReactNode;
} }

View File

@@ -20,7 +20,7 @@ export default function HomePage(){
return ( return (
<main> <main>
Home Page <div>Home Page</div>
<button <button
onClick={showModal} onClick={showModal}
> >
@@ -29,7 +29,8 @@ export default function HomePage(){
<Modal <Modal
display={displayModal} display={displayModal}
close={hideModal} close={hideModal}
backgroundType="darken-blur" backgroundType="lighten"
className="bg-(--bg-color) text-(--text-color)"
> >
<ModalHeader <ModalHeader
close={hideModal} close={hideModal}