use alpine in PopoverMenu
This commit is contained in:
@@ -1,27 +1,26 @@
|
|||||||
import { MenuAlt4Icon } from "@heroicons/react/outline/esm"
|
import { MenuAlt4Icon } from "@heroicons/react/outline/esm"
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { useAssetBuilder } from "../asset-builder/asset-builder-context.js"
|
|
||||||
import { linkClass } from "./components"
|
import { linkClass } from "./components"
|
||||||
|
|
||||||
export function PopoverMenu({ children }: { children: React.ReactNode }) {
|
export function PopoverMenu({ children }: { children: React.ReactNode }) {
|
||||||
const assets = useAssetBuilder()
|
|
||||||
return (
|
return (
|
||||||
<div data-popover className="relative">
|
<div className="relative" x-data="{ open: false }">
|
||||||
<button data-popover-button title="Menu" className={linkClass}>
|
<button title="Menu" className={linkClass} x-on:click="open = !open">
|
||||||
<MenuAlt4Icon className="w-6" />
|
<MenuAlt4Icon className="w-6" />
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
data-popover-panel
|
className={`
|
||||||
hidden
|
w-48 max-h-[calc(100vh-4rem)]
|
||||||
className="absolute w-48 bg-slate-800 rounded-lg shadow overflow-hidden max-h-[calc(100vh-4rem)] overflow-y-auto right-0 top-[calc(100%+8px)]"
|
absolute right-0 top-[calc(100%+8px)]
|
||||||
|
bg-slate-800 shadow rounded-lg
|
||||||
|
overflow-hidden overflow-y-auto
|
||||||
|
transition-all
|
||||||
|
`}
|
||||||
|
x-bind:class="open ? 'visible opacity-100' : 'invisible opacity-0 translate-y-3'"
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
<script
|
|
||||||
type="module"
|
|
||||||
src={assets.file(new URL("popover-menu.client.tsx", import.meta.url))}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user