From 1d9f4553ebd8e2e30f54948e4242b391faae121f Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sat, 30 Mar 2024 18:42:49 -0400 Subject: [PATCH] feat: support children in confirmation modal --- app/components/Modal.tsx | 11 +++- app/routes/_data.dns._index/rename.tsx | 72 ++++++++++---------------- 2 files changed, 35 insertions(+), 48 deletions(-) diff --git a/app/components/Modal.tsx b/app/components/Modal.tsx index d17e5f0..17b8775 100644 --- a/app/components/Modal.tsx +++ b/app/components/Modal.tsx @@ -1,7 +1,7 @@ import { Dialog, Transition } from '@headlessui/react' import { XMarkIcon } from '@heroicons/react/24/outline' import clsx from 'clsx' -import { Fragment, type SetStateAction, useState } from 'react' +import { Fragment, type ReactNode, type SetStateAction, useState } from 'react' import Button from './Button' @@ -10,6 +10,7 @@ type HookParameters = { description?: string; buttonText?: string; variant?: 'danger' | 'confirm'; + children?: ReactNode; // Optional because the button submits onConfirm?: () => void | Promise; @@ -100,11 +101,17 @@ function Modal({ parameters, isOpen, setIsOpen }: Properties) { {parameters.description} ) : undefined} + {parameters.children ? ( +
+ {parameters.children} +
+ ) : undefined} - { - setIsOpen(false) - }} - > - + {Modal} ) }