{# A legend and its swatches, as macros: components/legend.html (the Python Legend) and any template that explains its colours. {% from "components/_legend.html" import legend, swatch %} {{ legend([{"label": "Free", "color": "var(--fcu-surface-alt)"}, {"label": "Off", "pattern": "hatch"}, {"label": "Over", "outline": "solid", "edge": "danger"}], label=t("legend")) }}
{{ swatch({"color": "var(--grove-series-1)", "shape": "line"}) }} Planned
An item is a dict of LegendItem's fields (components/legend.py): label, color, pattern (hatch / stripe / dots), outline (solid / dashed / ring), edge (muted / danger / warning / success / primary), shape (bar / square / dot / line), glyph, css_class. The swatch is decoration — the label says what it means — so it alone is aria-hidden; the list is real text. #} {% macro swatch(item, shape="bar") -%} {%- endmacro %} {% macro legend(items, label=none, shape="bar", id=none, css_class=none) -%} {%- endmacro %}