32 lines
1.4 KiB
Twig
32 lines
1.4 KiB
Twig
{#-
|
|
One line of a dashboard:widget. Its text is `parts` (shown with dots between them) or the content
|
|
block; `icon` in front. With `url` the line is a link, without one but with hx-* attributes a
|
|
button (opening a modal, say), otherwise plain text.
|
|
-#}
|
|
{% set url = url ?? null %}
|
|
{% set icon = icon ?? null %}
|
|
{% set parts = parts ?? null %}
|
|
{% set is_button = not url and attributes.all|keys|filter(k => k starts with 'hx-')|length > 0 %}
|
|
{% set body %}
|
|
{% if icon %}{{ include('_partials/_icon.html.twig', {icon: icon, class: 'size-4 text-muted'}) }}{% endif %}
|
|
<span class="entry-text">
|
|
{%- if parts is not null -%}
|
|
{%- for part in parts|filter(p => p is not empty) -%}
|
|
{% if not loop.first %} <span class="entry-dot" aria-hidden="true">·</span> {% endif %}<span>{{ part }}</span>
|
|
{%- endfor -%}
|
|
{%- else -%}
|
|
{{ block('content') }}
|
|
{%- endif -%}
|
|
</span>
|
|
{% endset %}
|
|
{% set attrs = attributes.defaults({class: 'entry-link'}).without('url', 'icon', 'parts') %}
|
|
<li>
|
|
{% if url %}
|
|
<a href="{{ url }}" {{ attrs }}>{{ body }}</a>
|
|
{% elseif is_button %}
|
|
<button type="button" {{ attributes.defaults({class: 'entry-link', 'hx-target': 'body', 'hx-swap': 'beforeend'}).without('url', 'icon', 'parts') }}>{{ body }}</button>
|
|
{% else %}
|
|
<div {{ attrs }}>{{ body }}</div>
|
|
{% endif %}
|
|
</li>
|