2.6 KiB · text History e763f8f
{# An invite card (src/handlers/invites.rs InviteCard). Active ones carry
   the whole link with a copy button; used and expired ones say what
   happened. #}
<article id="invite-{{ inv.id }}" data-status="{{ inv.status }}"
         class="flex min-w-0 flex-col gap-2 rounded-box border p-3
                {% if inv.status == 'active' %}border-base-300 bg-base-100 shadow-sm{% else %}border-base-300 bg-base-200/60 opacity-70{% endif %}
                {% if inv.fresh %}ring-2 ring-accent ring-offset-2 ring-offset-base-100{% endif %}">
  <header class="flex items-center gap-2">
    {% if inv.status == 'active' %}<span class="badge badge-success badge-sm">Active</span>
    {% elif inv.status == 'used' %}<span class="badge badge-neutral badge-sm">Used</span>
    {% else %}<span class="badge badge-warning badge-sm">Expired</span>{% endif %}
    <span class="min-w-0 flex-1 truncate text-sm {% if not inv.email %}opacity-60{% endif %}"
          title="{% if inv.email %}Only {{ inv.email }} can register with it{% else %}Anyone with the link{% endif %}">
      <i class="fas {% if inv.email %}fa-envelope{% else %}fa-link{% endif %} mr-1 opacity-60" aria-hidden="true"></i>{{ inv.email or "Anyone with the link" }}
    </span>
  </header>

  {% if inv.status == 'active' %}
  <div class="join w-full">
    <input class="input input-bordered input-xs join-item min-w-0 flex-1 font-mono" readonly
           value="{{ inv.url }}" aria-label="Invite link" onclick="this.select()">
    <button type="button" class="btn btn-xs join-item" title="Copy the link" aria-label="Copy the link"
            onclick="navigator.clipboard.writeText(this.previousElementSibling.value).then(() => { const i = this.querySelector('i'); i.className = 'fas fa-check'; setTimeout(() => i.className = 'fas fa-copy', 1500); })">
      <i class="fas fa-copy"></i>
    </button>
  </div>
  {% else %}
  <code class="truncate text-xs opacity-60" title="{{ inv.token }}">{{ inv.token }}</code>
  {% endif %}

  <footer class="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs opacity-70">
    <span title="Created {{ inv.created_abs }}"><i class="fas fa-plus mr-1" aria-hidden="true"></i>{{ inv.created_rel }}</span>
    {% if inv.status == 'used' %}
      <span><i class="fas fa-user-check mr-1" aria-hidden="true"></i>{{ inv.used_by or "someone" }}{% if inv.used_rel %} · {{ inv.used_rel }}{% endif %}</span>
    {% else %}
      <span title="Expires {{ inv.expires_abs }}"><i class="fas fa-hourglass-half mr-1" aria-hidden="true"></i>{% if inv.status == 'expired' %}expired {% else %}expires {% endif %}{{ inv.expires_rel }}</span>
    {% endif %}
  </footer>
</article>