{% load brickwork_icons brickwork_components i18n %} {% comment %} Empty state (STA-001/002). variant distinguishes "no data yet" (nothing ever created) from "no results" (a filter matched nothing), so the two are never identical: no_results offers a clear-filters action, no_data an onboarding one. The icon is decorative; the heading + body carry the meaning (both required, no package-supplied default copy, STA-003). Required context: heading (except at size="sm", see below), body (required at every scale, STA-003). Trust boundary: action_href is emitted as given; brickwork does not validate URL schemes and callers passing user-supplied URLs must validate them first. DEBUG: `{% bw_require body=body %}` always, and `{% bw_require heading=heading %}` when size is not "sm" (icvoss/django-brickwork#482); production emits nothing. Optional: variant ("no_data" default or "no_results"), icon (registry name), action_href, action_label. variant ("no_data" | "no_results", default "no_data"): emitted as data-variant through {% bw_attr ... allow= %} (ADR-097). An absent value defaults to "no_data"; an unrecognised value omits the attribute entirely (no silent fallback class token). Size and surface stay on the class attribute via author-literal if/elif (the closed-vocab class-composition pattern). size ("sm" | "md", default "md"): emitted as bw-empty-state--size-sm only when "sm" is supplied (ADR-060, STA-019, #218); "lg" is not an earned value. "sm" is the in-panel scale, for an empty state nested inside a card or other bounded container rather than filling a page: it takes the tighter --bw-space-6 block padding, demotes the heading to a
(optional at this scale; body stays required at every scale), suppresses the icon unless one is explicitly passed, and renders any action_href/action_label as a plain bw-empty-state__action-link rather than a bw-btn--primary. At the default "md" the rendered output is unchanged (byte-identical) from before this option existed. Named blocks (semver-public, BR-BW-TPL-001), all empty by default: icon: present SINCE 3.4.0, with no deprecated predecessor: this is NEW capability, not a rename. Wraps the existing icon-resolution branch (CMP-032); an override replaces the whole icon markup. heading: present SINCE 3.4.0, the concise, correct successor to the deprecated title block below (ADR-077 SS4). Wraps the existing {{ heading }} rendering, matching both the context variable it wraps and the bw-empty-state__heading class it sits inside; "title" named neither correctly and is deprecated in the same cycle. body: present SINCE 3.4.0, the concise, correct successor to the deprecated description block below (ADR-077 SS4). Wraps the existing {{ body }} rendering, matching both the context variable it wraps and the bw-empty-state__body class it sits inside; "description" named neither correctly and is deprecated in the same cycle. action: present SINCE 3.4.0, the concise successor to the deprecated empty_state_action block below (CMP-032). Default content is the existing action_href/action_label anchor rendering, so a call site filling only those two context variables renders exactly what it always did. title, description, empty_state_action: present since before 3.4.0 (unchanged back to at least 3.2.1). DEPRECATED, removed at 4.0 (ADR-077 SS4, BR-BW-TPL-001/BR-BW-VER-001). Kept as additional empty extension points for backwards compatibility: a shipped block name cannot be renamed silently. Each deprecated block renders alongside its concise successor when both are filled; a caller migrating to the concise names fills heading/body/action only. TRAP: "title" is the deprecated name HERE, superseded by "heading", but "title" is simultaneously the concise, CURRENT block name in _modal.html, _slide_over.html and _card.html. The same word means opposite version states depending on which file it is copied between; check the file you are actually extending, not a name remembered from another component. A call site that supplies only heading/body/variant/icon/action_href/ action_label (the pre-existing context-variable path) renders byte-identical output to before these blocks existed. A block name this file does not define is SILENTLY DISCARDED by Django: no error, no warning, DEBUG=True does not catch it. If you extend this template using a name read from a newer checkout than the version you have pinned, check that name against your pinned version's own header before relying on it, or the region renders nothing. action stays markup-only by design (icvoss/django-brickwork#398 sweep): its default content is conditional on the action_href/action_label PAIR and picks between a bw-btn and a plain link depending on size, so there is no single action= string a context variable could stand in for; the pair of existing context variables is already the content seam. heading and body already accept context variables (see Required context above); title and description are their deprecated predecessors and deliberately do NOT gain a passthrough of their own, since both are superseded names being retired (ADR-077 SS4) and giving either a new working path would undo that retirement. States: two content variants (no_data default, no_results, each pairing a different default icon and a different suggested action), and two scales (md default, sm). No interactive open/closed state: it is static markup, always fully rendered. Accessibility: the icon is decorative (bw_icon decorative=True); heading and body text carry the meaning, so the icon alone never communicates status. At the default scale the heading is a real
(an in-panel empty state nested inside a card should not contribute a page-level heading). Covered by axe.spec.mjs against console-*.html (size="md", app/console.html's own shape) and console-sm-*.html (size="sm", both themes). Responsive: no breakpoint switch; no width-dependent CSS on any .bw-empty-state* selector. The size axis (sm/md) is a fixed, explicitly chosen scale, never a viewport-driven one. Appearance (Beat Phase C, icvoss/django-brickwork#543): surface ("framed" default | "plain"): framed is the Phase A white-canvas card treatment (edge + ambient). plain strips the frame for embedding in an already-framed region without nesting chrome. size="sm" always unframes (nested panel scale), regardless of surface. {% endcomment %}{% firstof surface '' as surface %}{% firstof variant "no_data" as bw_empty_variant %}{% bw_options component="brickwork/components/_empty_state.html" surface=surface %}{% bw_require body=body %}{% if size != "sm" %}{% bw_require heading=heading %}{% endif %}
{% block body %}{% block description %}{{ body }}{% endblock %}{% endblock %}
{% block action %} {% if action_href and action_label %} {% if size == "sm" %} {{ action_label }} {% else %} {{ action_label }} {% endif %} {% endif %} {% endblock %} {% block empty_state_action %}{% endblock %}