{# Reusable UI macros adapted from vendored Penguin UI components. These are OUR adaptation layer; the byte-for-byte upstream sources live under assets/views/penguinui/. Tailwind sees the full literal class strings here (assets/css/app.css has @source "../views"), so every branch must spell its classes out in full — never build class names by concatenation. Usage: {% import "macros/ui.html" as ui %} {{ ui::button_primary(label=t(key="save", lang=lang)) }} {{ ui::button_primary(label="Add", attrs='hx-post="/x"' | safe) }} {{ ui::button_outline(label="Cancel", href="/back") }} {{ ui::badge(label="Published", variant="success") }} Notes: - Macros can't see template context vars (e.g. `lang`); pass already-translated strings as `label`. - `attrs` is injected raw (caller must pass it through `| safe`); use it for htmx / name / value / @click etc. For buttons whose attrs carry nested quotes (e.g. hx-on with toast(...)), keep them inline instead. - Source: penguinui/buttons/{default,outline,ghost}-button.html and penguinui/badge/soft-color-badge.html. Upstream's color-button typos (text-onDanger etc.) are fixed to our real tokens (text-on-danger). #} {% macro button_primary(label, type="button", href="", attrs="", extra="") -%} {% if href %}{{ label }} {%- endmacro button_primary %} {% macro button_outline(label, type="button", href="", attrs="", extra="") -%} {% if href %}{{ label }} {%- endmacro button_outline %} {% macro button_danger(label, type="button", href="", attrs="", extra="") -%} {% if href %}{{ label }} {%- endmacro button_danger %} {% macro button_ghost(label, type="button", href="", attrs="", extra="") -%} {% if href %}{{ label }} {%- endmacro button_ghost %} {# Compact danger alert (form/inline errors). Adapted from penguinui/alert/default-alert.html (danger variant), trimmed to a single line with the danger icon. #} {% macro alert_danger(message, extra="") -%} {%- endmacro alert_danger %} {# Soft-color badge. variant ∈ success | danger | warning | info | primary | neutral #} {% macro badge(label, variant="neutral") -%} {% if variant == "success" -%} {{ label }} {%- elif variant == "danger" -%} {{ label }} {%- elif variant == "warning" -%} {{ label }} {%- elif variant == "info" -%} {{ label }} {%- elif variant == "primary" -%} {{ label }} {%- else -%} {{ label }} {%- endif %} {%- endmacro badge %}