budibase/packages/bbui/src/ActionMenu/ActionMenu.svelte

30 lines
728 B
Svelte
Raw Normal View History

2021-04-12 17:10:55 +02:00
<script>
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>
<Popover bind:this={dropdown} {anchor} align="left">
2021-04-12 17:10:55 +02:00
<Menu>
<slot />
</Menu>
</Popover>
2021-04-12 17:10:55 +02:00
<style>
div {
display: contents;
}
</style>