{# Stat-card component. Replaces the open-coded

...

...

...

pattern (25+ duplicates across the dashboard, opportunities, layout, and failures pages) with a single macro. Usage: {% from "components/_stat_card.html" import stat_card %} {{ stat_card("Total Spend", totals.total_cost_usd | format_usd, meta="across 7,027 jobs") }} {{ stat_card("Affected downstreams", "17", meta="models with active issues", accent="rose") }} {{ stat_card("Bytes Processed", value_html, accent="brand", padding="p-6") }} Parameters: - label (str) uppercase caption above the value - value (str | safe HTML) main value; pass already-formatted - meta (str, optional) caption below the value - accent (str) value colour: default | brand | emerald | rose | amber | teal | slate - padding (str) Tailwind padding class, defaults to "p-4" - tooltip (str, optional) hover popover text. Renders an info icon to the right of the label and a hidden box that shows on hover. Supports HTML (caller is trusted). #} {% macro stat_card(label, value, meta=None, accent="default", padding="p-4", tooltip=None) -%} {%- set _accent_class = { "default": "text-slate-900 dark:text-slate-100", "brand": "text-brand-500 dark:text-brand-300", "emerald": "text-emerald-600 dark:text-emerald-400", "rose": "text-rose-600 dark:text-rose-400", "amber": "text-amber-600 dark:text-amber-300", "teal": "text-teal-700 dark:text-teal-300", "slate": "text-slate-400", }.get(accent, "text-slate-900 dark:text-slate-100") -%}
{%- if tooltip %}

{{ label }}

{%- else %}

{{ label }}

{%- endif %}

{{ value }}

{%- if meta %}

{{ meta }}

{%- endif %}
{%- endmacro %}