2.2 KiB · text History e763f8f
{# The inline new invite (src/handlers/invites.rs): a `+` tile that swaps to
   a form, which swaps to a fresh `+` plus the new card (or back to the `+`
   on Cancel / Escape). Requests target the slot itself, not #content. #}
{% if not add.adding %}
<button type="button" id="invite-add"
        hx-get="/invites/slot?form=1" hx-target="this" hx-select="unset" hx-swap="outerHTML"
        title="New invite" aria-label="New invite"
        class="flex min-h-28 items-center justify-center gap-2 rounded-box border-2 border-dashed border-base-300 text-2xl text-base-content/50 transition-all hover:-translate-y-0.5 hover:border-primary/60 hover:text-primary focus-visible:outline-2 focus-visible:outline-primary">
  <i class="fas fa-plus" aria-hidden="true"></i><span class="text-sm font-medium">New invite</span>
</button>
{% else %}
<form id="invite-add" hx-post="/invites/inline" hx-target="this" hx-select="unset" hx-swap="outerHTML"
      hx-on:keydown="if (event.key === 'Escape') { event.preventDefault(); this.querySelector('[data-cancel]').click(); }"
      class="flex flex-col gap-2 rounded-box border-2 border-primary/60 bg-base-100 p-3 shadow-md">
  <p class="text-xs font-semibold opacity-70">New invite</p>
  <input type="email" name="email" value="{{ add.email }}" autofocus
         placeholder="Only this address (optional)" aria-label="Restrict to email (optional)"
         class="input input-sm input-bordered w-full">
  <label class="flex items-center gap-2 text-xs">
    <span class="opacity-70">Valid for</span>
    <input type="number" name="days" value="{{ add.days }}" min="1" max="365" placeholder="{{ add.default_days }}"
           aria-label="Days valid" class="input input-sm input-bordered w-20">
    <span class="opacity-70">days</span>
  </label>
  {% if add.error %}<p class="text-xs text-error" role="alert">{{ add.error }}</p>{% endif %}
  <div class="flex justify-end gap-1">
    <button type="button" data-cancel class="btn btn-ghost btn-xs"
            hx-get="/invites/slot" hx-target="closest form" hx-select="unset" hx-swap="outerHTML">Cancel</button>
    <button type="submit" class="btn btn-primary btn-xs"><i class="fas fa-plus mr-1"></i>Create</button>
  </div>
</form>
{% endif %}