1.8 KiB · text History 25c4237
{# Shared bits. Rank colours match the map markers in assets/f/js/map.js. #}
{% macro rank_icon(rank) -%}
  {%- if rank == "always" %}fa-heart{% elif rank == "positive" %}fa-thumbs-up{% elif rank == "neutral" %}fa-minus{% elif rank == "never" %}fa-ban{% else %}fa-question{% endif -%}
{%- endmacro %}

{# Full class names, never built by concatenation: Tailwind only keeps classes
   it can find spelled out in templates, so "btn-" ~ color would be purged. #}
{% macro rank_btn(rank) -%}
  {%- if rank == "always" %}btn-success{% elif rank == "positive" %}btn-accent{% elif rank == "neutral" %}btn-neutral{% elif rank == "never" %}btn-error{% else %}btn-ghost{% endif -%}
{%- endmacro %}

{% macro rank_badge_class(rank) -%}
  {%- if rank == "always" %}badge-success{% elif rank == "positive" %}badge-accent{% elif rank == "neutral" %}badge-neutral{% elif rank == "never" %}badge-error{% else %}badge-ghost{% endif -%}
{%- endmacro %}

{% macro rank_badge(rank) -%}
  {%- if rank -%}
  <span class="badge {{ rank_badge_class(rank) }} gap-1 capitalize"><i class="fas {{ rank_icon(rank) }}"></i> {{ rank }}</span>
  {%- else -%}
  <span class="badge badge-ghost gap-1 opacity-70">unranked</span>
  {%- endif -%}
{%- endmacro %}

{% macro map_legend() -%}
<p class="flex flex-wrap gap-3 text-xs opacity-80">
  <span><span class="inline-block size-2.5 rounded-full" style="background:#16a34a"></span> always</span>
  <span><span class="inline-block size-2.5 rounded-full" style="background:#84cc16"></span> positive</span>
  <span><span class="inline-block size-2.5 rounded-full" style="background:#a8a29e"></span> neutral</span>
  <span><span class="inline-block size-2.5 rounded-full" style="background:#dc2626"></span> never</span>
  <span><span class="inline-block size-2.5 rounded-full" style="background:#3b82f6"></span> not ranked by you</span>
</p>
{%- endmacro %}