brewlog/templates/cups.html
Jon Seager 6e2c59814c
feat(cups): add web views, templates, and navigation
- Add CupView, CafeOptionView, RoastOptionView view models
- Add CupsTemplate (full page) and CupListTemplate (fragment)
- Create cups.html with form and cup_list.html with responsive table
- Add Cups link to desktop and mobile navigation
- Add cup timeline event link and label support
2026-02-03 16:36:35 +00:00

103 lines
3.9 KiB
HTML

{% extends "base.html" %} {% block title %}Brewlog · Cups{% endblock %}
{% block content %}
<section data-signals:_show-form="false">
<header class="flex flex-wrap items-start justify-between gap-4">
<div class="flex flex-col gap-2">
<h1 class="text-3xl font-semibold">Cups</h1>
<p class="max-w-2xl text-sm text-stone-600">Track coffees you've enjoyed at cafes.</p>
</div>
{% if is_authenticated %}
<button
type="button"
class="flex h-10 w-10 items-center justify-center rounded-full border border-amber-500 text-2xl font-semibold text-amber-700 transition hover:border-amber-400 hover:text-amber-600"
data-class:hidden="$_showForm"
data-on:click="$_showForm = true"
aria-label="Add new cup"
>
<span aria-hidden="true">+</span>
</button>
{% endif %}
</header>
{% if is_authenticated %}
<div
class="mt-6 rounded-lg border border-amber-300 bg-amber-100/80 p-5 shadow-sm"
data-show="$_showForm"
style="display: none"
>
<div>
<h2 class="text-lg font-semibold text-amber-700">New Cup</h2>
<p class="mt-1 text-sm text-stone-600">
Record a coffee you had at a cafe.
</p>
</div>
<form
method="post"
action="/api/v1/cups"
class="mt-4 flex flex-col gap-4"
data-on:submit="@post('/api/v1/cups?{{ navigator.query_for_page(1) }}', {contentType: 'form', responseOverrides: {selector: '#cup-list', mode: 'replace'}})"
data-ref="_form"
data-on:datastar-fetch="evt.detail.type === 'finished' && ($_showForm = false, $_form && $_form.reset())"
>
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Coffee *</span>
<select name="roast_id" required class="input-field">
<option value="">Select a roast...</option>
{% for roast in roast_options %}
<option value="{{ roast.id }}">{{ roast.label }}</option>
{% endfor %}
</select>
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Cafe *</span>
<select name="cafe_id" required class="input-field">
<option value="">Select a cafe...</option>
{% for cafe in cafe_options %}
<option value="{{ cafe.id }}">{{ cafe.label }}</option>
{% endfor %}
</select>
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Rating</span>
<select name="rating" class="input-field">
<option value="">No rating</option>
<option value="5">5 - Exceptional</option>
<option value="4">4 - Great</option>
<option value="3">3 - Good</option>
<option value="2">2 - Fair</option>
<option value="1">1 - Poor</option>
</select>
</label>
<label class="sm:col-span-2 flex flex-col gap-1 text-sm">
<span class="text-stone-700">Notes</span>
<textarea
name="notes"
rows="2"
class="input-field"
placeholder="Tasting impressions, preparation style..."
></textarea>
</label>
</div>
<div class="flex items-center justify-end gap-2">
<button
type="button"
class="rounded-md border border-amber-300 px-4 py-2 text-sm font-semibold text-stone-700 transition hover:border-amber-400 hover:text-stone-800"
data-on:click="($_showForm = false, $_form && $_form.reset())"
>
Cancel
</button>
<button
type="submit"
class="rounded-md bg-amber-600 px-4 py-2 text-sm font-semibold text-amber-50 transition hover:bg-amber-500"
>
Save Cup
</button>
</div>
</form>
</div>
{% endif %}
</section>
{% include "partials/cup_list.html" %} {% endblock %}