mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
fix dead code with knip upgrade TS to v6 and fix linting errors auto apply oxfmt rules fix linting errors - unused deps etc ignore file remove all ignored files in knip add knip - dead code analysis tool swap prettier and eslint of oxfmt and oxlint fix: fix map rendering in react strict mode fix: headlessUI float replace fix: disable Matomo if not URL and SITE ID exist upgrade: 1st pass upgrade to Next.js v16 deps: upgrade react to v19
98 lines
2.8 KiB
TypeScript
98 lines
2.8 KiB
TypeScript
import React, { ComponentProps, Fragment } from "react";
|
|
|
|
import { Dialog, Transition } from "@headlessui/react";
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
type ModalProps = ComponentProps<typeof Dialog> & {
|
|
title?: string;
|
|
subTitle?: string;
|
|
|
|
titleClass?: string;
|
|
subTitleClass?: string;
|
|
overlayClass?: string;
|
|
panelClass?: string;
|
|
children?: React.ReactNode;
|
|
};
|
|
|
|
export const Modal = ({
|
|
open,
|
|
onClose,
|
|
|
|
title,
|
|
subTitle,
|
|
|
|
titleClass,
|
|
subTitleClass,
|
|
overlayClass,
|
|
panelClass,
|
|
children,
|
|
|
|
...dialogProps
|
|
}: ModalProps) => (
|
|
<Transition appear show={open} as={Fragment}>
|
|
<Dialog as="div" className="relative z-[2000]" onClose={onClose} {...dialogProps}>
|
|
<Transition.Child
|
|
as={Fragment}
|
|
enter="ease-out duration-300"
|
|
enterFrom="opacity-0"
|
|
enterTo="opacity-100"
|
|
leave="ease-in duration-200"
|
|
leaveFrom="opacity-100"
|
|
leaveTo="opacity-0"
|
|
>
|
|
<div className={twMerge("fixed inset-0 bg-neutral-900/50", overlayClass)} />
|
|
</Transition.Child>
|
|
|
|
<div className="fixed inset-0 overflow-y-auto">
|
|
<div className="flex min-h-full items-center justify-center p-4 text-center">
|
|
<Transition.Child
|
|
as={Fragment}
|
|
enter="ease-out duration-300"
|
|
enterFrom="opacity-0 scale-95"
|
|
enterTo="opacity-100 scale-100"
|
|
leave="ease-in duration-200"
|
|
leaveFrom="opacity-100 scale-100"
|
|
leaveTo="opacity-0 scale-95"
|
|
>
|
|
<Dialog.Panel
|
|
className={twMerge(
|
|
"flex w-full max-w-md transform flex-col space-y-6 overflow-hidden rounded-lg bg-neutral-100 p-4 transition-all dark:bg-neutral-600",
|
|
panelClass,
|
|
)}
|
|
>
|
|
{title && (
|
|
<div>
|
|
<div className="flex items-center justify-between space-x-4">
|
|
<Dialog.Title
|
|
as="h3"
|
|
className={twMerge(
|
|
"text-xl font-normal !leading-8 text-black dark:text-white",
|
|
titleClass,
|
|
)}
|
|
>
|
|
{title}
|
|
</Dialog.Title>
|
|
</div>
|
|
|
|
{subTitle && (
|
|
<Dialog.Description
|
|
className={twMerge(
|
|
"mt-2 text-left text-xs font-normal text-black dark:text-white",
|
|
subTitleClass,
|
|
)}
|
|
>
|
|
{subTitle}
|
|
</Dialog.Description>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
{children}
|
|
</Dialog.Panel>
|
|
</Transition.Child>
|
|
</div>
|
|
</div>
|
|
</Dialog>
|
|
</Transition>
|
|
);
|