Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+63
@@ -0,0 +1,63 @@
|
||||
import { Fragment, MouseEventHandler, ReactNode } from "react";
|
||||
import { Menu, Transition } from "@headlessui/react";
|
||||
import clsx from "clsx";
|
||||
import { ChevronDownIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
interface Props {
|
||||
right?: boolean;
|
||||
button?: ReactNode;
|
||||
options?: ReactNode;
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
btnClassName?: string;
|
||||
onClick?: MouseEventHandler<HTMLButtonElement>;
|
||||
disabled?: boolean;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export default function Dropdown({ button, options, right, onClick, className, btnClassName, disabled, isLoading }: Props) {
|
||||
return (
|
||||
<Menu as="div" className={clsx(className, "relative inline-block text-left")}>
|
||||
<div>
|
||||
<Menu.Button
|
||||
disabled={disabled || isLoading}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (onClick) {
|
||||
onClick(e);
|
||||
}
|
||||
}}
|
||||
className={clsx(
|
||||
isLoading && "base-spinner cursor-not-allowed",
|
||||
btnClassName ?? "inline-flex w-full items-center justify-center rounded-md px-3 py-2 text-sm font-medium shadow-2xs",
|
||||
disabled || isLoading
|
||||
? "bg-surface-neutral-secondary/90 cursor-not-allowed"
|
||||
: clsx("bg-surface-neutral-primary", "shadow-focus focus:outline-hidden focus:ring-offset-2")
|
||||
)}
|
||||
>
|
||||
{button}
|
||||
{!btnClassName && <ChevronDownIcon className="text-text-neutral-tertiary -mr-1 ml-2 h-4 w-4" />}
|
||||
</Menu.Button>
|
||||
</div>
|
||||
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<Menu.Items
|
||||
className={clsx(
|
||||
"bg-surface-neutral-modal border-border-default absolute z-40 mt-2 w-48 overflow-hidden rounded-md border shadow-lg ring-1 ring-border-default focus:outline-hidden",
|
||||
right ? "left-0 origin-top-left" : "right-0 origin-top-right"
|
||||
)}
|
||||
>
|
||||
<div className="py-1">{options}</div>
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user