2.8 KiB · text History 644543b
{% extends "root.html" %}
{# Visual home: a tile per top-level category (src/handlers/focus.rs
   home_focus). Each opens that category in focus; its squares open the reader. #}
{% block width %}w-full max-w-none{% endblock %}
{% block main_class %}px-3 py-3 sm:px-4 lg:px-5{% endblock %}
{% block content %}
<div class="space-y-6 text-left">
  <div class="flex flex-wrap items-center justify-between gap-3">
    <h1 class="text-3xl font-bold">Categories</h1>
    <div class="flex items-center gap-2">
      {% set toggle_base = "/c/" %}{% set view_mode = "focus" %}
      {% include "forum/_view_toggle.html" %}
      {% if user and user.is_staff %}
      <a href="/admin/categories" class="btn btn-ghost btn-sm"><i class="fas fa-folder-tree mr-1"></i> Manage</a>
      {% endif %}
    </div>
  </div>

  {% if not categories %}
    <p class="opacity-70">No categories yet.</p>
  {% else %}
  <div class="grid grid-cols-[repeat(auto-fill,minmax(22rem,1fr))] gap-4">
    {% for c in categories %}
    <section id="home-{{ c.slug }}" aria-label="{{ c.name }}" class="flex flex-col gap-3 rounded-box border border-base-300 bg-base-200 p-4">
      <a href="{{ c.href }}" id="focus-link-{{ c.slug }}" title="Focus on {{ c.name }}" aria-label="Focus on {{ c.name }}"
         class="group flex items-start gap-3 rounded hover:text-primary focus-visible:outline-2 focus-visible:outline-primary">
        <span class="size-8 shrink-0 rounded-full border border-base-content/20" style="background: {{ c.widget_bg }}" aria-hidden="true"></span>
        <span class="min-w-0 flex-1">
          <span class="block font-semibold text-lg leading-tight">{{ c.name }}</span>
          {% if c.description %}<span class="block text-sm opacity-70 line-clamp-2">{{ c.description }}</span>{% endif %}
        </span>
        <span class="font-mono text-sm opacity-60" title="Topics">{{ c.count }}</span>
      </a>
      {% if c.children %}
      <div class="flex flex-wrap gap-1.5">
        {% for s in c.children %}
        <a href="{{ s.href }}" class="badge badge-outline gap-1 py-3" title="Focus on {{ s.name }}">
          <span class="size-3 rounded-full border border-base-content/20" style="background: {{ s.widget_bg }}" aria-hidden="true"></span>{{ s.name }}
          <span class="font-mono opacity-50">{{ s.count }}</span>
        </a>
        {% endfor %}
      </div>
      {% endif %}
      {% if c.topics %}
      <div class="grid grid-cols-[repeat(auto-fill,minmax(4.5rem,1fr))] gap-1.5">
        {% for t in c.topics %}{% set href = c.href ~ "&topic=" ~ t.id %}{% set reader_swap = false %}{% include "forum/_topic_square.html" %}{% endfor %}
      </div>
      {% else %}
      <p class="text-xs opacity-50">No topics yet.</p>
      {% endif %}
    </section>
    {% endfor %}
  </div>
  {% endif %}
</div>
{% endblock %}