{# The reader (visual mode): one topic over the focus view, with a filmstrip
of the category's topics in the current sort. Always rendered (empty when
closed) so htmx has a #reader to swap. Keys (src.js): ←/→ or k/j step,
Escape closes. As cartosnap's shared trip and pin_flip's lightbox. #}
<div id="reader">
{% if reader %}
<a href="{{ base }}" id="reader-backdrop" tabindex="-1" aria-hidden="true"
hx-get="{{ base }}" hx-target="#reader" hx-select="#reader" hx-swap="outerHTML" hx-push-url="true"
class="fixed inset-0 z-40 bg-neutral/70 backdrop-blur-sm"></a>
<div role="dialog" aria-modal="true" aria-labelledby="reader-title" data-reader="{{ reader.topic.id }}"
class="fixed inset-x-0 bottom-0 top-0 z-50 mx-auto flex max-w-4xl flex-col bg-base-100 shadow-2xl sm:inset-y-4 sm:rounded-box">
<header class="flex items-start gap-2 border-b border-base-300 p-3 sm:p-4">
<div class="min-w-0 flex-1">
<p class="text-xs opacity-60">
<a href="/c/{{ reader.cat_slug }}?view=focus" class="link link-hover">{{ reader.cat_name }}</a>
· by {{ reader.author }}
</p>
<h2 id="reader-title" tabindex="-1" class="text-xl font-bold leading-snug focus:outline-none">
{% if reader.topic.is_pinned %}<i class="fas fa-thumbtack text-accent mr-1" title="Pinned"></i>{% endif %}
{% if reader.topic.is_closed %}<i class="fas fa-lock opacity-60 mr-1" title="Closed"></i>{% endif %}
{{ reader.topic.title }}
</h2>
</div>
<span id="reader-count" class="badge badge-ghost font-mono shrink-0 mt-1">{{ reader.index }} / {{ reader.count }}</span>
<a href="/t/{{ reader.topic.id }}" class="btn btn-ghost btn-sm btn-square" title="Open the topic page" aria-label="Open the topic page">
<i class="fas fa-up-right-from-square"></i>
</a>
<a href="{{ base }}" id="reader-close" title="Close (Esc)" aria-label="Close"
hx-get="{{ base }}" hx-target="#reader" hx-select="#reader" hx-swap="outerHTML" hx-push-url="true"
class="btn btn-ghost btn-sm btn-square"><i class="fas fa-xmark"></i></a>
</header>
<div class="relative min-h-0 flex-1 overflow-y-auto p-3 sm:p-4 space-y-3" id="reader-posts">
{% for post in reader.posts %}{% include "forum/_post.html" %}{% endfor %}
<p class="text-center text-sm opacity-70">
{% if reader.topic.is_closed %}This topic is closed.
{% elif can_write %}<a href="/t/{{ reader.topic.id }}#reply" class="link link-primary">Reply on the topic page</a>
{% elif user %}<a href="/profile#email-verification" class="link">Verify your email address to reply.</a>
{% else %}<a href="/login" class="link">Log in to reply.</a>{% endif %}
</p>
</div>
<footer class="border-t border-base-300 p-2 sm:p-3 space-y-2">
<div class="flex items-center justify-between gap-2">
{% if reader.prev %}
<a href="{{ base }}&topic={{ reader.prev }}" id="reader-prev" aria-label="Previous topic" title="Previous topic (← or k)"
hx-get="{{ base }}&topic={{ reader.prev }}" hx-target="#reader" hx-select="#reader" hx-swap="outerHTML" hx-push-url="true"
class="btn btn-sm btn-circle"><i class="fas fa-chevron-left"></i></a>
{% else %}<span class="btn btn-sm btn-circle btn-disabled" aria-hidden="true"><i class="fas fa-chevron-left"></i></span>{% endif %}
<p class="hidden text-xs opacity-50 sm:block">← → or j k to step · Esc to close</p>
{% if reader.next %}
<a href="{{ base }}&topic={{ reader.next }}" id="reader-next" aria-label="Next topic" title="Next topic (→ or j)"
hx-get="{{ base }}&topic={{ reader.next }}" hx-target="#reader" hx-select="#reader" hx-swap="outerHTML" hx-push-url="true"
class="btn btn-sm btn-circle"><i class="fas fa-chevron-right"></i></a>
{% else %}<span class="btn btn-sm btn-circle btn-disabled" aria-hidden="true"><i class="fas fa-chevron-right"></i></span>{% endif %}
</div>
<ol id="reader-strip" class="flex gap-1.5 overflow-x-auto px-1 py-2" aria-label="Topics in this category">
{% for s in reader.strip %}
<li class="shrink-0">
<a href="{{ base }}&topic={{ s.id }}" id="strip-{{ s.id }}"
hx-get="{{ base }}&topic={{ s.id }}" hx-target="#reader" hx-select="#reader" hx-swap="outerHTML" hx-push-url="true"
{% if s.current %}aria-current="true"{% endif %} aria-label="Topic {{ loop.index }}: {{ s.title }}" title="{{ s.title }}"
class="relative flex size-14 flex-col justify-end overflow-hidden rounded-field border bg-base-200 p-1 text-[0.55rem] leading-tight transition {% if s.current %}-translate-y-1 border-primary ring-2 ring-primary ring-offset-2 ring-offset-base-100 shadow-md{% else %}border-base-300 opacity-70 hover:-translate-y-1 hover:opacity-100 focus-visible:opacity-100{% endif %}">
<span class="absolute inset-x-0 top-0 h-1" style="background: {{ s.widget_bg }}" aria-hidden="true"></span>
{% if s.unread %}<span class="absolute right-1 top-1.5 size-1.5 rounded-full bg-primary" aria-hidden="true"></span>{% endif %}
<span class="line-clamp-3">{{ s.title }}</span>
</a>
</li>
{% endfor %}
</ol>
</footer>
</div>
{% endif %}
</div>
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
5.3 KiB · text
History
da3a685