3.1 KiB · text History 6dd7389
{# Shared bits. Rank colours match the map markers in assets/f/js/map.js. #}
{% macro rank_icon(rank) -%}
  {%- if rank == "obsessed" %}fa-fire{% elif 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 == "obsessed" %}btn-warning{% elif 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 == "obsessed" %}badge-warning{% elif 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, since=none) -%}
  {%- if rank -%}
  <span class="badge {{ rank_badge_class(rank) }} gap-1"><i class="fas {{ rank_icon(rank) }}"></i> <span class="capitalize">{{ rank }}</span>{% if since %} since {{ since }}{% endif %}</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:#ea580c"></span> obsessed</span>
  <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 %}

{# Cuisine tags as links to that cuisine's page, scoped to an area if given. #}
{% macro cuisine_links(tags, area_id=none) -%}
  {%- for t in tags -%}
  <a class="link link-hover" href="/cuisines/{{ t | urlencode }}{% if area_id %}?area={{ area_id }}{% endif %}">{{ t }}</a>{% if not loop.last %}, {% endif %}
  {%- endfor -%}
{%- endmacro %}

{# Open/closed at a given time, from crate::hours::State. Nothing for no hours. #}
{% macro hours_badge(state, when="lunch") -%}
  {%- if state == "open" -%}<span class="badge badge-success badge-outline badge-sm gap-1"><i class="fas fa-door-open"></i> open at {{ when }}</span>
  {%- elif state == "closed" -%}<span class="badge badge-error badge-outline badge-sm gap-1"><i class="fas fa-door-closed"></i> closed at {{ when }}</span>
  {%- elif state == "unknown" -%}<span class="badge badge-ghost badge-sm">hours vary</span>
  {%- elif state == "unreadable" -%}<span class="badge badge-ghost badge-sm" title="Couldn't read these opening hours">hours?</span>
  {%- endif -%}
{%- endmacro %}