mirror of
https://github.com/hunvreus/basecoat.git
synced 2026-11-12 21:28:18 +00:00
54 lines
1.2 KiB
Plaintext
54 lines
1.2 KiB
Plaintext
{% macro dropdown_menu(
|
|
id=None,
|
|
trigger=None,
|
|
main_attrs={},
|
|
trigger_attrs={},
|
|
content_attrs={},
|
|
include_script=false,
|
|
register_on=["alpine:init"]
|
|
) %}
|
|
{% if include_script %}
|
|
{% include "components/dropdown-menu-script.njk" %}
|
|
{% endif %}
|
|
|
|
<div
|
|
class="popover {{ main_attrs.class }}"
|
|
x-data="dropdownMenu"
|
|
@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 %}
|
|
>
|
|
<nav role="menu">
|
|
{% if caller %}{{ caller() }}{% endif %}
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
{% endmacro %} |