2021-04-12 17:10:55 +02:00
|
|
|
<script>
|
2021-04-21 16:03:12 +02:00
|
|
|
import Popover from '../Popover/Popover.svelte'
|
2021-04-12 17:10:55 +02:00
|
|
|
import Menu from '../Menu/Menu.svelte'
|
|
|
|
let anchor;
|
|
|
|
let dropdown;
|
|
|
|
|
|
|
|
// This is needed because display: contents is considered "invisible".
|
|
|
|
// It should only ever be an action button, so should be fine.
|
|
|
|
function getAnchor(node) {
|
|
|
|
anchor = node.firstChild
|
|
|
|
}
|
|
|
|
|
|
|
|
export const hide = () => { dropdown.hide() }
|
|
|
|
export const show = () => { dropdown.show() }
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="contents" use:getAnchor on:click={dropdown.show}>
|
|
|
|
<slot name="button" />
|
|
|
|
</div>
|
2021-04-21 16:03:12 +02:00
|
|
|
<Popover bind:this={dropdown} {anchor} align="left">
|
2021-04-12 17:10:55 +02:00
|
|
|
<Menu>
|
|
|
|
<slot />
|
|
|
|
</Menu>
|
2021-04-21 16:03:12 +02:00
|
|
|
</Popover>
|
2021-04-12 17:10:55 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
div {
|
|
|
|
display: contents;
|
|
|
|
}
|
|
|
|
</style>
|