{# One block in its wrapper (tab.html; alone: GET /health/api/block, layout.js's instant add). The wrapper carries data-id / data-w and --f (its share of the row); a tile's wrapper is the tile itself (a link / hover-tip anchor where the block has one). Import "with context" (V, v, B = {id: block} incl. the guests' — theirs draw themselves, render() —, tab). A tile shown on another tab than its own links to its tab. #} {% import "health/_blocks.html" as bl with context %} {% macro frac(w) %}{{ {33: 0.33333, 66: 0.66667}.get(w, w / 100) }}{% endmacro %} {% macro block(it) %}{% set b = B[it.id] %}{% set out = (b.render() if b.render else bl[b.macro](V)) | trim %} {% set href = b.href or (("/health/" ~ b.tab) if b.tab != tab and b.tab in ("body", "sleep", "heart", "activity") else None) %} {% if b.kind == "tile" %} <{{ "a" if href else "div" }} class="hl-blk{% if b.pin %} hl-pin{% endif %}{% if not out %} hl-void{% endif %}" data-id="{{ b.id }}" data-w="{{ it.w }}" style="--f:{{ frac(it.w) }}"{% if href %} href="{{ href }}"{% elif b.pin %} tabindex="0"{% endif %}>{{ (out if out else '' ~ b.label ~ 'nothing to show') | safe }} {% else %}
{{ (out if out else '

' ~ b.label ~ '

Nothing to show.

') | safe }}
{% endif %}{% endmacro %}