{# 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 %}