brewlog/templates/partials/lists/roast_list.html
Jon Seager 44174b4361
feat(ui): colour-code tasting note pills by SCA wheel category
Add view-layer mapping that categorises tasting notes into 9 colour
families (floral, fruity, citrus, sweet, nutty, spice, roasted, sour,
vegetal) based on the SCA Coffee Tasting Wheel. Matching uses
case-insensitive exact lookup against ~90 known terms, then substring
fallback, with pill-muted as the default for unrecognised notes.

- Add tasting_notes module with NoteCategory enum and categorize()
- Add 9 pill CSS variants with light and dark mode support
- Update roast list and timeline templates to render coloured pills
2026-02-06 16:26:29 +00:00

122 lines
6.3 KiB
HTML

{% import "partials/lists/table.html" as table %}
{% import "partials/icons.html" as icons %}
<div id="roast-list" class="mt-6" data-star-scope="roasts">
{% if roasts.items.is_empty() && !navigator.has_search() %}
<div
class="rounded-lg border border-dashed px-4 py-6 text-sm text-text-secondary"
>
<p class="text-center">
{% if is_authenticated %}
No roasts added yet. Click the Add button to create your first roast.
{% else %}
No roasts added yet.
{% endif %}
</p>
</div>
{% else %}
<section class="rounded-lg border bg-surface"
{% if roasts.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(roasts.next_page().unwrap())|safe }}" data-target="#roast-list"{% endif %}
>
{% call table::search_header(navigator, "#roast-list") %}
<div class="overflow-x-auto">
<table class="responsive-table min-w-full divide-y text-left text-sm text-text">
<thead class="bg-surface-alt text-xs font-semibold tracking-wide text-text">
<tr>
{% call table::sortable_header("Added", "created-at", navigator, "#roast-list") %}
{% call table::sortable_header("Roast", "name", navigator, "#roast-list") %}
{% call table::sortable_header("Origin", "origin", navigator, "#roast-list") %}
<th scope="col" class="px-4 py-3">Tasting Notes</th>
{% if is_authenticated %}
<th scope="col" class="actions-col px-4 py-3 text-right">Actions</th>
{% endif %}
</tr>
</thead>
<tbody class="divide-y/70">
{% for roast in roasts.items %}
<tr
data-star-key="{{ roast.full_id }}"
data-sort-created-at="{{ roast.created_at_sort_key }}"
data-sort-name="{{ roast.name }}"
data-sort-roaster="{{ roast.roaster_label }}"
data-sort-origin="{{ roast.origin }}"
data-sort-producer="{{ roast.producer }}"
class="transition hover:bg-surface-alt"
{% if is_authenticated %}onclick="if(event.target.closest('.card-detail'))return;this.classList.toggle('expanded');this.querySelector('.card-detail')?.classList.toggle('hidden');const r=this.nextElementSibling;if(r?.classList.contains('detail-row'))r.classList.toggle('hidden');this.querySelector('.icon-expand')?.classList.toggle('hidden');this.querySelector('.icon-collapse')?.classList.toggle('hidden');"{% endif %}
>
<td data-label="Added" class="card-date whitespace-nowrap px-4 py-3 text-xs font-medium text-text-secondary">
<div>{{ roast.created_date }}</div>
<div class="hidden md:block font-normal text-text-muted">{{ roast.created_time }}</div>
</td>
<td data-label="Roast" class="card-title px-4 py-3">
<div class="font-medium text-text">{{ roast.name }}</div>
<div class="hidden md:block text-xs text-text-muted">{{ roast.roaster_label }}</div>
</td>
<td data-label="Roaster" class="px-4 py-3 whitespace-nowrap md:hidden">{{ roast.roaster_label }}</td>
<td data-label="Origin" class="px-4 py-3 whitespace-nowrap">
{{ roast.origin }}
{% if !roast.producer.is_empty() %}
<div class="hidden md:block text-xs text-text-muted">{{ roast.producer }}</div>
{% endif %}
</td>
{% if !roast.producer.is_empty() %}
<td data-label="Producer" class="px-4 py-3 whitespace-nowrap md:hidden">{{ roast.producer }}</td>
{% endif %}
<td data-label="Tasting Notes" class="px-4 py-3">
{% if !roast.tasting_notes.is_empty() %}
<div class="flex flex-wrap gap-1 md:justify-start justify-end">
{% for note in roast.tasting_notes %}
<span class="{{ note.pill_class }}">{{ note.label }}</span>
{% endfor %}
</div>
{% else %}
<span class="pill pill-muted">No Notes</span>
{% endif %}
</td>
{% if is_authenticated %}
<td data-label="" class="card-detail hidden">
<div class="flex items-center gap-4">
<button type="button"
class="inline-flex items-center gap-1 text-sm font-medium text-text-muted hover:text-red-600"
data-on:click="confirm('Delete this roast?') && @delete('/api/v1/roasts/{{ roast.full_id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#roast-list', mode: 'replace'}})">
{% call icons::delete("h-4 w-4") %} Delete
</button>
</div>
</td>
<td data-label="" class="card-actions px-4 py-3 text-right">
<button type="button"
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-text-muted transition hover:text-accent hover:bg-surface-alt"
title="Actions">
<span class="icon-expand">{% call icons::ellipsis_vertical("h-5 w-5") %}</span>
<span class="icon-collapse hidden">{% call icons::chevron_up("h-5 w-5") %}</span>
</button>
</td>
{% endif %}
</tr>
{% if is_authenticated %}
<tr class="hidden detail-row">
<td colspan="5" class="bg-surface-alt px-4 py-2">
<div class="flex items-center gap-4">
<button type="button"
class="inline-flex items-center gap-1 text-sm font-medium text-text-muted hover:text-red-600"
data-on:click="confirm('Delete this roast?') && @delete('/api/v1/roasts/{{ roast.full_id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#roast-list', mode: 'replace'}})">
{% call icons::delete("h-4 w-4") %} Delete
</button>
</div>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% if roasts.items.is_empty() %}
<div class="p-8 text-center text-text-muted">No roasts match your search.</div>
{% endif %}
{% call table::pagination_header(roasts, navigator, "#roast-list") %}
{% if roasts.has_next() %}
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
{% endif %}
</section>
{% endif %}
</div>