option_card.html 14 lignes · 1188 octets
{# Carte d'option (design.md : option-card / -active / -disabled). Vrai bouton radio,
   sélection rendue en CSS (:has), donc utilisable sans JavaScript et au clavier. #}
{% macro option_card(name, value, titre, description, coche, indisponible, raison) %}
<label class="relative flex cursor-pointer flex-col gap-xs rounded-sm border bg-background p-xl
              has-checked:border-transparent has-checked:p-[23px] has-checked:ring-2 has-checked:ring-primary
              has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring
              {% if indisponible %}cursor-not-allowed border-dashed border-dashed-border{% else %}border-card-border{% endif %}">
  <input type="radio" name="{{ name }}" value="{{ value }}" class="sr-only"
         {% if coche %}checked{% endif %} {% if indisponible %}disabled aria-describedby="raison-{{ name }}-{{ value }}"{% endif %}>
  <span class="text-md text-title-ink">{{ titre }}</span>
  <span class="text-sm text-muted-foreground">{{ description }}</span>
  {% if indisponible %}<span id="raison-{{ name }}-{{ value }}" class="text-xs text-warning">{{ raison }}</span>{% endif %}
</label>
{% endmacro %}