From eba1676c1581eff4b3a3a0e9ac19b63feb90cfce Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Mon, 24 Feb 2025 23:29:46 -0500 Subject: [PATCH] Modal initial comit --- src/components/modal/Modal.tsx | 41 +++++++++++++++++++++ src/components/modal/ModalBackground.tsx | 37 +++++++++++++++++++ src/components/modal/ModalBody.tsx | 23 ++++++++++++ src/components/modal/ModalFooter.tsx | 32 +++++++++++++++++ src/components/modal/ModalHeader.tsx | 45 ++++++++++++++++++++++++ src/interface/ModalInterfaces.ts | 34 ++++++++++++++++++ src/pages/public/HomePage.tsx | 44 +++++++++++++++++++++++ 7 files changed, 256 insertions(+) create mode 100644 src/components/modal/Modal.tsx create mode 100644 src/components/modal/ModalBackground.tsx create mode 100644 src/components/modal/ModalBody.tsx create mode 100644 src/components/modal/ModalFooter.tsx create mode 100644 src/components/modal/ModalHeader.tsx create mode 100644 src/interface/ModalInterfaces.ts diff --git a/src/components/modal/Modal.tsx b/src/components/modal/Modal.tsx new file mode 100644 index 0000000..9f3c4a1 --- /dev/null +++ b/src/components/modal/Modal.tsx @@ -0,0 +1,41 @@ +import { ModalProps } from "@/interface/ModalInterfaces"; +import clsx from "clsx"; +import ModalBackground from "./ModalBackground"; + + +export default function Modal(props: ModalProps){ + const { + display, + backgroundType = "blur", + backgroundClassName, + close, + className, + children + } = props; + + + return ( + <> + { + display && + <> + +
+ {children} +
+ + } + + ); +} diff --git a/src/components/modal/ModalBackground.tsx b/src/components/modal/ModalBackground.tsx new file mode 100644 index 0000000..111f442 --- /dev/null +++ b/src/components/modal/ModalBackground.tsx @@ -0,0 +1,37 @@ +import { ModalBackgroundProps } from "@/interface/ModalInterfaces"; +import clsx from "clsx"; + + +export default function ModalBackground(props: ModalBackgroundProps){ + const { + backgroundType = "blur", + close, + className + } = props; + + + if(backgroundType === "none"){ + return (<>); + } + + + return ( +
+ ); +} diff --git a/src/components/modal/ModalBody.tsx b/src/components/modal/ModalBody.tsx new file mode 100644 index 0000000..4206a3b --- /dev/null +++ b/src/components/modal/ModalBody.tsx @@ -0,0 +1,23 @@ +import { ModalBodyProps } from "@/interface/ModalInterfaces"; +import clsx from "clsx"; + + +export default function ModalBody(props: ModalBodyProps){ + const { + className, + children + } = props; + + + return ( +
+ {children} +
+ ); +} diff --git a/src/components/modal/ModalFooter.tsx b/src/components/modal/ModalFooter.tsx new file mode 100644 index 0000000..4a56b68 --- /dev/null +++ b/src/components/modal/ModalFooter.tsx @@ -0,0 +1,32 @@ +import { ModalFooterProps } from "@/interface/ModalInterfaces"; +import clsx from "clsx"; + + +export default function ModalFooter(props: ModalFooterProps){ + const { + backgroundType = "none", + className, + children + } = props; + + + return ( +
+
+ {children} +
+
+ ); +} diff --git a/src/components/modal/ModalHeader.tsx b/src/components/modal/ModalHeader.tsx new file mode 100644 index 0000000..070c045 --- /dev/null +++ b/src/components/modal/ModalHeader.tsx @@ -0,0 +1,45 @@ +import { ModalHeaderProps } from "@/interface/ModalInterfaces"; +import clsx from "clsx"; +import { BsXLg } from "react-icons/bs"; + + +export default function ModalHeader(props: ModalHeaderProps){ + const { + backgroundType = "none", + close, + className, + children + } = props; + + + return ( +
+
+ {children} +
+ { + close && +
+ +
+ } +
+ ); +} diff --git a/src/interface/ModalInterfaces.ts b/src/interface/ModalInterfaces.ts new file mode 100644 index 0000000..f9f1fa6 --- /dev/null +++ b/src/interface/ModalInterfaces.ts @@ -0,0 +1,34 @@ +import { HTMLProps } from "react"; + + +export type ModalBackgroundType = "darken" | "lighten" | "blur" | "darken-blur" | "lighten-blur" | "transparent" | "none"; +export type ModalHeaderFooterBackgroundType = "darken" | "lighten" | "none"; + + +export interface ModalBackgroundProps extends HTMLProps{ + backgroundType?: ModalBackgroundType; + close: () => void; +} + +export interface ModalProps extends HTMLProps{ + display: boolean; + backgroundType?: ModalBackgroundType; + backgroundClassName?: string; + close: () => void; + children: React.ReactNode; +} + +export interface ModalHeaderProps extends HTMLProps{ + backgroundType?: ModalHeaderFooterBackgroundType; + close?: () => void; + children: React.ReactNode; +} + +export interface ModalBodyProps extends HTMLProps{ + children: React.ReactNode; +} + +export interface ModalFooterProps extends HTMLProps{ + backgroundType?: ModalHeaderFooterBackgroundType; + children: React.ReactNode; +} diff --git a/src/pages/public/HomePage.tsx b/src/pages/public/HomePage.tsx index d35a652..2aa79f9 100644 --- a/src/pages/public/HomePage.tsx +++ b/src/pages/public/HomePage.tsx @@ -1,7 +1,51 @@ +import Modal from "@/components/modal/Modal"; +import ModalBody from "@/components/modal/ModalBody"; +import ModalFooter from "@/components/modal/ModalFooter"; +import ModalHeader from "@/components/modal/ModalHeader"; +import { useState } from "react"; + + export default function HomePage(){ + const [ displayModal, setDisplayModal ] = useState(false); + + + const showModal = () => { + setDisplayModal(true); + } + + const hideModal = () => { + setDisplayModal(false); + } + + return (
Home Page + + + + Header + + + Body + + + Footer + +
); }