MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / FlyoutMenu

Function FlyoutMenu

components/flyoutMenu.tsx:19–98  ·  view source on GitHub ↗
(props: {
  items: Item[];
  getClassName?: (open: boolean) => string;
  buttonClassName?: string;
  Icon?: React.ReactNode;
  popoverClassName?: string;
  title?: string;
})

Source from the content-addressed store, hash-verified

17};
18
19export default function FlyoutMenu(props: {
20 items: Item[];
21 getClassName?: (open: boolean) => string;
22 buttonClassName?: string;
23 Icon?: React.ReactNode;
24 popoverClassName?: string;
25 title?: string;
26}) {
27 return (
28 <Popover className={classNames("relative")}>
29 {({ open }) => (
30 <div className={props.getClassName ? props.getClassName(open) : ""}>
31 <Popover.Button className={props.buttonClassName ?? ""}>
32 {props.Icon ?? (
33 <EllipsisHorizontalIcon
34 className="h-9 w-9 p-1"
35 aria-hidden="true"
36 />
37 )}
38 </Popover.Button>
39
40 <Transition
41 as={Fragment}
42 enter="transition ease-out duration-100"
43 enterFrom="opacity-0 translate-y-1"
44 enterTo="opacity-100 translate-y-0"
45 leave="transition ease-in duration-200"
46 leaveFrom="opacity-100 translate-y-0"
47 leaveTo="opacity-0 translate-y-1"
48 >
49 <Popover.Panel
50 onClick={(e) => {
51 e.preventDefault();
52 e.stopPropagation();
53 }}
54 className="absolute left-1/2 z-10 flex w-screen max-w-min -translate-x-1/2 px-4"
55 >
56 <div
57 className={classNames(
58 "shrink rounded-xl bg-white py-3 px-1 text-sm font-semibold leading-6 text-gray-900 shadow-lg ring-1 ring-gray-900/5",
59 props.popoverClassName ?? "",
60 )}
61 >
62 {props.title && (
63 <h1 className="text-lg w-full text-center pb-1.5 pt-1 border-b font-base border-gray-300">
64 {props.title}
65 </h1>
66 )}
67 {props.items.map((item) => {
68 if ("onClick" in item)
69 return (
70 <button
71 key={item.name}
72 onClick={item.onClick}
73 className="p-2 hover:bg-gray-200 w-full text-left px-3 rounded flex flex-row place-items-center gap-x-2 font-normal"
74 >
75 {item.Icon ?? ""}
76 {item.name}

Callers

nothing calls this directly

Calls 1

classNamesFunction · 0.85

Tested by

no test coverage detected