Open
Description
The existing <Popper />
component doesn't feel right, it does absolutely nothing, if not allow the consumers to pass props down and retrieve the result.
The README example could be written as follows and everything would still work:
<Popper
reference={referenceElement}
popper={popperElement}
options={popperOptions}
bind:styles
bind:attributes
/>
<button bind:this={referenceElement}>Reference Element</button>
<div
bind:this={popperElement}
class="tooltip"
style={css(styles.popper)}
{...attributes.popper}>
Popper Element
<div bind:this={arrowElement} class="arrow" style={css(styles.arrow)} />
</div>
A cleaner approach could be the use:action
API.
<script>
let styles = {};
let attributes = {};
</script>
<button
use:popper={{ popperElement, options }}
on:popperUpdate={evt => {
styles = evt.detail.styles;
attributes = evt.detail.attributes;
}}
>
Reference Element
</button>
Here's a basic example:
https://codesandbox.io/s/trusting-butterfly-704gd?file=/popperAction.js
Thoughts?