{# A category card in Focus management (src/handlers/categories.rs
card_node): its header, then its subcategories as nested cards and the `+`
that adds one inline, as pin_flip's board nests groups. `node` is the card;
`max_depth` the nesting limit. Recursive. #}
<article id="cat-card-{{ node.id }}" data-depth="{{ node.depth }}" aria-label="{{ node.name }}"
class="flex min-w-0 flex-col gap-3 rounded-box border
{% if node.depth == 1 %}border-primary/40 bg-base-200 p-4 shadow-sm
{% elif node.depth == 2 %}border-base-300 bg-base-100 p-3
{% else %}border-base-300 bg-base-200/60 p-2.5{% endif %}
{% if node.fresh %}ring-2 ring-accent ring-offset-2 ring-offset-base-100{% endif %}">
<header class="flex items-start gap-2">
<span class="{% if node.depth == 1 %}size-7{% elif node.depth == 2 %}size-5{% else %}size-4{% endif %} mt-0.5 shrink-0 rounded-full border border-base-content/20"
style="background: {{ node.widget_bg }}" aria-hidden="true"></span>
<div class="min-w-0 flex-1">
<a href="/c/{{ node.slug }}?view=focus"
class="block truncate font-semibold hover:text-primary {% if node.depth == 1 %}text-lg{% elif node.depth == 3 %}text-sm{% endif %}"
title="Open {{ node.name }}">{{ node.name }}</a>
<div class="flex flex-wrap items-center gap-1 text-xs">
<code class="opacity-60">{{ node.slug }}</code>
{% if node.min_trust is none %}<span class="badge badge-ghost badge-xs">Public</span>
{% elif node.min_trust == 0 %}<span class="badge badge-warning badge-xs">Logged-in</span>
{% else %}<span class="badge badge-warning badge-xs">TL{{ node.min_trust }}+</span>{% endif %}
{% for r in node.rules %}<span class="badge badge-info badge-xs" title="Posting rule">{{ r }}</span>{% endfor %}
<span class="font-mono opacity-60" title="{{ node.own_count }} here, {{ node.count }} including subcategories">{{ node.count }} topics</span>
</div>
{% if node.description and node.depth < 3 %}<p class="mt-1 line-clamp-2 text-xs opacity-70">{{ node.description }}</p>{% endif %}
</div>
<div class="flex shrink-0 items-center">
<a href="/admin/categories/{{ node.id }}/edit" class="btn btn-ghost btn-xs btn-square"
title="Edit {{ node.name }}" aria-label="Edit {{ node.name }}"><i class="fas fa-pen"></i></a>
<form method="post" action="/admin/categories/{{ node.id }}/delete" class="inline" hx-boost="false"
onsubmit="return confirm('Delete "{{ node.name }}"? Subcategories move up a level; this category\'s own topics and posts are deleted.');">
<button type="submit" class="btn btn-ghost btn-xs btn-square text-error"
title="Delete {{ node.name }}" aria-label="Delete {{ node.name }}"><i class="fas fa-trash"></i></button>
</form>
</div>
</header>
{% if node.children or node.add %}
<div class="grid gap-2 {% if node.depth == 1 %}grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3{% else %}grid-cols-[repeat(auto-fill,minmax(10rem,1fr))]{% endif %}">
{% for child in node.children %}
{% with node = child %}{% include "admin/_category_card.html" %}{% endwith %}
{% endfor %}
{% if node.add %}{% with add = node.add %}{% include "admin/_category_add.html" %}{% endwith %}{% endif %}
</div>
{% endif %}
</article>
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
3.3 KiB · text
History
263b40b