diff --git a/src/components/example/DialogExample.tsx b/src/components/example/DialogExample.tsx new file mode 100644 index 0000000..678ab3b --- /dev/null +++ b/src/components/example/DialogExample.tsx @@ -0,0 +1,36 @@ +'use client' +import { useState } from "react"; + +import Dialog from "@/components/neobruu/Dialog"; +import Button from "@/components/neobruu/Button"; + +export default function DialogExample() { + const [showDialog, setShowDialog] = useState(false); + + const handleShowDialog = () => { + setShowDialog(true); + }; + + return ( +
+ + {showDialog && ( + + +
+
+

Dialog

+

Lorem ipsum, dolor sit amet consectetur adipisicing elit. Repellendus hic inventore obcaecati fuga qui id corrupti perferendis, totam aliquam incidunt? Voluptas omnis pariatur inventore tenetur rerum aperiam? Excepturi, dolor quo!

+
+
+
+ +
+ +
+
+
+ )} +
+ ); +} \ No newline at end of file diff --git a/src/components/neobruu/Dialog.tsx b/src/components/neobruu/Dialog.tsx new file mode 100644 index 0000000..84b8d14 --- /dev/null +++ b/src/components/neobruu/Dialog.tsx @@ -0,0 +1,107 @@ +'use client' +import React, { useEffect, useState } from 'react'; +import { IoClose } from 'react-icons/io5'; + +type DialogProps = { + active: boolean; + setActive: React.Dispatch>; + children: React.ReactNode; + title: string; + variant?: 'primary' | 'secondary' | 'light' | 'dark' | 'blue' | 'yellow' | 'green' | 'red' | 'pink'; +}; + +type DialogContentProps = { + children: React.ReactNode; +} + +type DialogFooterProps = { + children: React.ReactNode; +} + +export default function Dialog({ active, setActive, children, title, variant = 'primary' }: DialogProps) { + const [isVisible, setIsVisible] = useState(false); + + useEffect(() => { + if (active) { + setIsVisible(true); + } + }, [active, setActive]); + + const getColors = () => { + switch (variant) { + case 'primary': + return 'border-black bg-orange-400'; + case 'secondary': + return 'border-black bg-pink-500'; + case 'light': + return 'border-black bg-slate-50'; + case 'dark': + return 'border-white/10 bg-zinc-900 text-white'; + case 'blue': + return 'border-black bg-blue-500'; + case 'yellow': + return 'border-black bg-[#f7cb46]'; + case 'green': + return 'border-black bg-green-500'; + case 'red': + return 'border-black bg-red-500'; + case 'pink': + return 'border-black bg-[#ff7d7d]'; + default: + return 'border-black bg-orange-500'; + } + }; + + const closeDialog = () => { + setIsVisible(false); + setTimeout(() => { + setActive(false); + }, 300); + }; + + return ( +
+
+
e.stopPropagation()} + style={{ + opacity: isVisible ? '1' : '0', + visibility: isVisible ? 'visible' : 'hidden', + transition: 'opacity 0.3s ease, visibility 0.3s ease', + }} + className={`z-10 w-[425px] md:w-[500px] overflow-y-auto border-2 border-black ${getColors()} p-2 shadow-[4px_4px_0px_0px_rgba(0,0,0,1)]`} + > +
+

{title}

+ +
+ {children} +
+
+
+ ); +}; + +Dialog.Content = function DialogContent({ children }: DialogContentProps) { + return ( +
{children}
+ ); +} + +Dialog.Footer = function DialogFooter({ children }: DialogFooterProps) { + return ( +
{children}
+ ); +} \ No newline at end of file diff --git a/src/data/components.ts b/src/data/components.ts index 4273a20..7763fbc 100644 --- a/src/data/components.ts +++ b/src/data/components.ts @@ -6,6 +6,8 @@ import Badge from '@/components/neobruu/Badge' import Card from '@/components/neobruu/Card' import Checkbox from '@/components/neobruu/Checkbox' import Dropdown from '@/components/neobruu/Dropdown' +import Drawer from '@/components/neobruu/Drawer' +import Dialog from '@/components/neobruu/Dialog' import Input from '@/components/neobruu/Input' import Toast from '@/components/neobruu/Toast' import Tooltip from '@/components/neobruu/Tooltip' @@ -25,8 +27,8 @@ import InputExample from '@/components/example/InputExample' import TextareaExample from '@/components/example/TextareaExample' import CardExample from '@/components/example/CardExample' import AccordionExample from '@/components/example/AccordionExample' -import Drawer from '@/components/neobruu/Drawer' import DrawerExample from '@/components/example/DrawerExample' +import DialogExample from '@/components/example/DialogExample' type ComponentObj = { name: string @@ -112,7 +114,6 @@ const components: ComponentObj[] = [ { name: 'Textarea', sub: 'Lorem ipsum dolor sit amet, consectetur', - isNew: true, component: Textarea, exampleComponent: TextareaExample, }, @@ -120,7 +121,6 @@ const components: ComponentObj[] = [ { name: 'Card', sub: 'Lorem ipsum dolor sit amet, consectetur', - isNew: true, component: Card, exampleComponent: CardExample, }, @@ -128,7 +128,6 @@ const components: ComponentObj[] = [ { name: 'Accordion', sub: 'Lorem ipsum dolor sit amet, consectetur', - isNew: true, component: Accordion, exampleComponent: AccordionExample, }, @@ -140,6 +139,14 @@ const components: ComponentObj[] = [ component: Drawer, exampleComponent: DrawerExample, }, + + { + name: 'Dialog', + sub: 'Lorem ipsum dolor sit amet, consectetur', + isNew: true, + component: Dialog, + exampleComponent: DialogExample, + }, ]; components.sort((a, b) => a.name.localeCompare(b.name));