{# SPDX-License-Identifier: Apache-2.0 Copyright (c) 2026 evoila Group The shared component set. Ten macros, flat signatures, no framework: the shape of meho's `_icons.html`, which is the one shared component that worked -- 65 templates import it and two raw survive in the whole tree. The agreed API is docs/components.md. Read it before changing a signature here: P2.3 displays these, P2.6 and P2.7 convert templates to them, so a prop that changes after this file ships is a change in three repos. Usage: {% from "_components.html" import button, badge, alert %} {{ button("Save", variant="primary") }} {{ badge("running", variant="info") }} `variant` is ONE prop with a named enum, not a colour crossed with a style. Of 402 buttons in meho carrying a class attribute, twelve combine a DaisyUI Style with a Color and all twelve are the same pair (btn-outline btn-error) -- which is `danger-quiet` below. Decided 2026-11-17; the reasoning is in docs/components.md. Every macro emits DaisyUI 5 class names and reads colour only through the theme's slots, never a hex value and never a `style` attribute, so Knowledge can adopt the set after D1 by providing the class names rather than rewriting the components. #} {#- ---------------------------------------------------------------- -#} {#- button -#} {#- ---------------------------------------------------------------- -#} {# A real
: the browser gives {%- endif -%} {%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- badge -#} {#- ---------------------------------------------------------------- -#} {# A label, not a status indicator on its own. Colour alone is not an accessible signal, so the text carries the meaning and the colour reinforces it. A badge whose label is empty does not render. `quiet` and `outline` stay separate values rather than folding into one: they read differently on a dense table row, which is where most of meho's 623 badges live. `secondary` was cut in P2.1 and came back: automation's "approval" activity category is secondary, on five badges, and no other colour means that there. size="md" is DaisyUI's default size: it writes no size class at all. `sm` stays the default, so every existing call renders as before. title a tooltip. Many badges explain themselves on hover ("Forked from an earlier published version"). It adds to the label, it never replaces it. href renders an instead of a , for a badge that links somewhere (another version of the same blueprint). #} {% macro badge(label, variant="neutral", size="sm", class="", title=None, href=None) -%} {%- set _variants = { "neutral": "badge-neutral", "quiet": "badge-ghost", "outline": "badge-outline", "success": "badge-success", "warning": "badge-warning", "error": "badge-error", "info": "badge-info", "primary": "badge-primary", "secondary": "badge-secondary", } -%} {%- set _sizes = {"xs": "badge-xs", "sm": "badge-sm", "md": ""} -%} {%- set _tag = "a" if href else "span" -%} {%- if label -%} <{{ _tag }}{% if href %} href="{{ href }}"{% endif %} class="{{ ["badge", _variants[variant], _sizes[size], class] | select | join(" ") }}"{% if title %} title="{{ title }}"{% endif %}>{{ label }} {%- endif -%} {%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- alert -#} {#- ---------------------------------------------------------------- -#} {# role="alert" for error and warning, role="status" for info and success. The first interrupts a screen reader, the second waits for a pause -- and an informational message that interrupts someone mid-sentence is worse than one that waits. #} {% macro alert(message, variant="info", title=None, class="") -%} {%- set _variants = { "info": "alert-info", "success": "alert-success", "warning": "alert-warning", "error": "alert-error", } -%} {%- set _role = "alert" if variant in ("error", "warning") else "status" -%}
{%- if title %}

{{ title }}

{% endif -%}

{{ message }}

{%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- empty_state -#} {#- ---------------------------------------------------------------- -#} {# `action` is a rendered button(...) passed in, not a set of button arguments: the component does not need to know how the caller builds one, and a nested signature is the first step towards a framework. #} {% macro empty_state(title, body=None, action=None, class="") -%}

{{ title }}

{%- if body %}

{{ body }}

{% endif -%} {%- if action %}
{{ action }}
{% endif -%}
{%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- dialog -#} {#- ---------------------------------------------------------------- -#} {# `title` is a required positional argument and has no default. This is the most load-bearing decision in the set. meho hand-rolls dialog markup in 64 templates with zero macros, and it shows: the close button reads aria-label="Close" in 34 of them and eleven other ways in the rest -- "Close editor", "Close bulk-import panel", "Close node detail drawer". Nobody decided that; it drifted because nothing stopped it. A dialog without an accessible name is announced as an unlabelled group and the person has no idea what opened. Required-and-no-default means an untitled dialog cannot be written, rather than being caught in review most of the time. #} {% macro dialog(id, title, body, actions=None, close_label="Close", class="") -%} {%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- field -#} {#- ---------------------------------------------------------------- -#} {# Label, help text and error as one unit. meho copies the same error_for / error_class / field_value trio verbatim in four templates today. The wiring is the point: `for`/`id` tie the label to the control, aria-describedby points at the help text, and an error sets aria-invalid and aria-errormessage. A field whose error is only a red border tells a screen reader nothing is wrong. automation cannot use this -- it has zero inputs and no form markup at all. Expected, not a gap. #} {% macro field(name, label, value=None, help=None, error=None, type="text", required=False, class="") -%} {%- set _described = [] -%} {%- if help %}{% set _ = _described.append(name ~ "-help") %}{% endif -%}
{%- if help %}

{{ help }}

{% endif -%} {%- if error %}

{{ error }}

{% endif -%}
{%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- table -#} {#- ---------------------------------------------------------------- -#} {# `empty` is a rendered empty_state(...) shown instead of an empty , because a table with a header and no rows reads as a loading failure. The is the table's accessible name. It is visually hidden rather than omitted: a screen-reader user landing on a bare table has no idea what it lists. #} {% macro table(columns, rows, caption=None, empty=None, class="") -%} {%- if caption %}{% endif -%} {% for col in columns %}{% endfor %} {%- if rows -%} {%- for row in rows -%} {% for cell in row %}{% endfor %} {%- endfor -%} {%- endif -%}
{{ caption }}
{{ col }}
{{ cell }}
{%- if not rows and empty %}{{ empty }}{% endif -%} {%- endmacro %} {#- ---------------------------------------------------------------- -#} {#- pager -#} {#- ---------------------------------------------------------------- -#} {# `url_for` is a callable taking a page number and returning a URL, so the component does not have to know how the app builds query strings. An unavailable previous/next renders as a , not a disabled