2024-09-02 12:44:49 +02:00
|
|
|
<script>
|
|
|
|
import Button from "../Button/Button.svelte"
|
|
|
|
import Popover from "../Popover/Popover.svelte"
|
|
|
|
import Menu from "../Menu/Menu.svelte"
|
|
|
|
import MenuItem from "../Menu/Item.svelte"
|
|
|
|
|
|
|
|
export let buttons
|
|
|
|
export let text = "Action"
|
|
|
|
export let size = "M"
|
|
|
|
export let align = "left"
|
|
|
|
export let offset
|
2024-09-03 16:05:13 +02:00
|
|
|
export let animate
|
2024-09-06 10:20:00 +02:00
|
|
|
export let quiet = false
|
2024-09-02 12:44:49 +02:00
|
|
|
|
|
|
|
let anchor
|
|
|
|
let popover
|
|
|
|
|
|
|
|
const handleClick = async button => {
|
|
|
|
popover.hide()
|
|
|
|
await button.onClick?.()
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
bind:ref={anchor}
|
|
|
|
{size}
|
|
|
|
icon="ChevronDown"
|
2024-09-06 10:20:00 +02:00
|
|
|
{quiet}
|
|
|
|
primary={quiet}
|
|
|
|
cta={!quiet}
|
|
|
|
newStyles={!quiet}
|
2024-09-02 12:44:49 +02:00
|
|
|
on:click={() => popover?.show()}
|
2024-09-03 16:14:40 +02:00
|
|
|
on:click
|
2024-09-06 10:20:00 +02:00
|
|
|
reverse
|
2024-09-02 12:44:49 +02:00
|
|
|
>
|
|
|
|
{text || "Action"}
|
|
|
|
</Button>
|
2024-09-03 16:05:13 +02:00
|
|
|
<Popover
|
|
|
|
bind:this={popover}
|
|
|
|
{align}
|
|
|
|
{anchor}
|
|
|
|
{offset}
|
|
|
|
{animate}
|
|
|
|
resizable={false}
|
2024-09-03 16:14:40 +02:00
|
|
|
on:close
|
|
|
|
on:open
|
2024-09-04 12:28:49 +02:00
|
|
|
on:mouseenter
|
|
|
|
on:mouseleave
|
2024-09-03 16:05:13 +02:00
|
|
|
>
|
2024-09-02 12:44:49 +02:00
|
|
|
<Menu>
|
|
|
|
{#each buttons as button}
|
|
|
|
<MenuItem on:click={() => handleClick(button)} disabled={button.disabled}>
|
|
|
|
{button.text || "Button"}
|
|
|
|
</MenuItem>
|
|
|
|
{/each}
|
|
|
|
</Menu>
|
|
|
|
</Popover>
|