yksa-web-kit/yksa_web/templates/yksa/ui/_state.html
2026-08-17 22:42:04 +08:00

22 lines
1.1 KiB
HTML

{% load i18n yksa_ui %}{% comment %}
The only sanctioned rendering of state. Two vocabularies -- health (ok, warning,
failed, running, skipped, unknown) and progress (not-started, in-progress,
complete, forced, skipped, failed) -- one visual treatment. Never describe one
object with both.
{% include "yksa/ui/_state.html" with state=run.ui_state %}
{% include "yksa/ui/_state.html" with state=plan.ui_state label=plan.progress_label %}
`label` overrides the default word; `title` sets a tooltip. Colour is never the
only signal, so the icon and the word ship with it.
The mapping from a domain status to a state name lives next to the model, not
here. A conditional chain choosing a colour inside a template is the bug this
partial exists to prevent: it is how the same run status ended up green on one
page and grey on another.
{% endcomment %}{% state state as s %}{% spaceless %}
<span class="yksa-state yksa-state-{{ state|default:'unknown' }}"{% if title %} title="{{ title }}"{% endif %}>
<i class="bi bi-{{ s.icon }}" aria-hidden="true"></i>
<span>{{ label|default:s.label }}</span>
</span>
{% endspaceless %}