33 lines
1.1 KiB
HTML
33 lines
1.1 KiB
HTML
|
|
{#
|
|||
|
|
chip.html — Filter/Tag-Chip
|
|||
|
|
|
|||
|
|
Props:
|
|||
|
|
label : Anzeigetext
|
|||
|
|
active : bool — ob der Chip selektiert ist (default False)
|
|||
|
|
variant : "default" | "green" | "dark"
|
|||
|
|
href : Optionaler Link. Ohne href wird ein <button> gerendert.
|
|||
|
|
attrs : Optionaler Dict mit zusätzlichen HTML-Attributen (z.B. data-*)
|
|||
|
|
|
|||
|
|
Verwendung:
|
|||
|
|
{% from "v2/components/chip.html" import chip %}
|
|||
|
|
{{ chip("Bundesweit", active=True) }}
|
|||
|
|
{{ chip("BW", href="/v2?bl=BW") }}
|
|||
|
|
{{ chip("Score 8–10", active=True, variant="green") }}
|
|||
|
|
#}
|
|||
|
|
|
|||
|
|
{% macro chip(label, active=False, variant="default", href="", attrs={}) %}
|
|||
|
|
{% set classes = "v2-chip" %}
|
|||
|
|
{% if variant != "default" %}{% set classes = classes ~ " " ~ variant %}{% endif %}
|
|||
|
|
{% if active %}{% set classes = classes ~ " active" %}{% endif %}
|
|||
|
|
|
|||
|
|
{% if href %}
|
|||
|
|
<a class="{{ classes }}" href="{{ href }}"
|
|||
|
|
{% for k, v in attrs.items() %}{{ k }}="{{ v }}" {% endfor %}
|
|||
|
|
>{{ label }}</a>
|
|||
|
|
{% else %}
|
|||
|
|
<button class="{{ classes }}" type="button"
|
|||
|
|
{% for k, v in attrs.items() %}{{ k }}="{{ v }}" {% endfor %}
|
|||
|
|
>{{ label }}</button>
|
|||
|
|
{% endif %}
|
|||
|
|
{% endmacro %}
|