mirror of
https://github.com/hunvreus/basecoat.git
synced 2026-11-13 21:58:17 +00:00
53 lines
1.1 KiB
Plaintext
53 lines
1.1 KiB
Plaintext
{% macro popover(
|
|
id=None,
|
|
trigger=None,
|
|
main_attrs=None,
|
|
trigger_attrs=None,
|
|
content_attrs=None,
|
|
include_script=false,
|
|
register_on=["alpine:init"]
|
|
) %}
|
|
{% if include_script %}
|
|
{% include "components/popover-script.njk" %}
|
|
{% endif %}
|
|
|
|
<div
|
|
class="popover {{ main_attrs.class }}"
|
|
x-data="popover"
|
|
@click.away="open = false"
|
|
{% if id %}id="{{ id }}"{% endif %}
|
|
{% for key, value in main_attrs %}
|
|
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
{% endfor %}
|
|
>
|
|
{% if trigger %}
|
|
<button
|
|
type="button"
|
|
aria-haspopup="menu"
|
|
aria-expanded="false"
|
|
x-bind="$trigger"
|
|
{% if id %}
|
|
id="{{ id }}-trigger"
|
|
aria-controls="{{ id }}-menu"
|
|
{% endif %}
|
|
{% for key, value in trigger_attrs %}
|
|
{{ key }}="{{ value }}"
|
|
{% endfor %}
|
|
>
|
|
{{ trigger | safe }}
|
|
</button>
|
|
{% endif %}
|
|
<div
|
|
data-popover
|
|
aria-hidden="true"
|
|
x-bind="$content"
|
|
{% if id %}id="{{ id }}-menu"{% endif %}
|
|
{% for key, value in content_attrs %}
|
|
{{ key }}="{{ value }}"
|
|
{% endfor %}
|
|
>
|
|
{% if caller %}{{ caller() }}{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|