brewlog/templates/partials/cafe_list.html
Jon Seager fb67f0659c
feat(ui): redesign with theme tokens, dark mode, and reusable components
Overhaul the web UI with CSS custom property-based theming and
dark mode support. Extract reusable template partials (location
search, scan input) and web components (photo-capture,
searchable-select). Add version and commit info to page footer.

- Replace hardcoded amber palette with semantic theme tokens
- Add dark mode with localStorage persistence and system preference detection
- Extract <brew-photo-capture> and <searchable-select> web components
- Extract location_search and scan_input Askama macros
- Add sun/moon, timeline, database, map icons
- Display version and git commit in footer
- Improve timeline coordinate rounding and map link formatting
- Add roast_name, roaster_name, remaining to BagOptionView
2026-02-05 17:03:09 +00:00

131 lines
6.4 KiB
HTML

{% import "partials/table.html" as table %}
{% import "partials/icons.html" as icons %}
<div id="cafe-list" class="mt-6" data-star-scope="cafes">
{% if cafes.items.is_empty() && !navigator.has_search() %}
<div
class="rounded-lg border border-dashed px-4 py-6 text-sm text-stone-600"
>
<p class="text-center">
{% if is_authenticated %}
No cafes added yet. Click the Add button to add your first cafe.
{% else %}
No cafes added yet.
{% endif %}
</p>
</div>
{% else %}
<section class="rounded-lg border bg-surface"
{% if cafes.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(cafes.next_page().unwrap())|safe }}" data-target="#cafe-list"{% endif %}
>
{% call table::search_header(navigator, "#cafe-list") %}
<div class="overflow-x-auto">
<table class="responsive-table min-w-full divide-y text-left text-sm text-stone-700">
<thead class="bg-surface-alt text-xs font-semibold tracking-wide text-stone-700">
<tr>
{% call table::sortable_header("Added", "created-at", navigator, "#cafe-list") %}
{% call table::sortable_header("Name", "name", navigator, "#cafe-list") %}
{% call table::sortable_header("Location", "country", navigator, "#cafe-list") %}
<th scope="col" class="px-4 py-3 text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y/70">
{% for cafe in cafes.items %}
<tr
data-star-key="{{ cafe.id }}"
data-sort-created-at="{{ cafe.created_at_sort_key }}"
data-sort-name="{{ cafe.name }}"
data-sort-country="{{ cafe.country }}"
data-sort-city="{{ cafe.city }}"
class="transition hover:bg-surface-alt"
>
<td data-label="Added" class="card-date whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
{{ cafe.created_at }}
</td>
<td data-label="Name" class="card-title px-4 py-3 font-medium text-stone-800">
{{ cafe.name }}
</td>
<td data-label="Location" class="px-4 py-3 whitespace-nowrap">
{{ cafe.country }}
<div class="hidden md:block text-xs text-stone-500">{{ cafe.city }}</div>
</td>
<td data-label="City" class="px-4 py-3 whitespace-nowrap md:hidden">{{ cafe.city }}</td>
<td data-label="" class="card-actions px-4 py-3 text-right">
<div class="hidden md:inline-flex items-center gap-1">
<a
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-500 transition hover:text-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"
href="{{ cafe.map_url }}"
target="_blank"
rel="noreferrer noopener"
title="Open in Google Maps"
>
<span class="sr-only">Open {{ cafe.name }} in Google Maps</span>
{% call icons::location("h-4 w-4") %}
</a>
{% if cafe.has_website %}
<a
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-500 transition hover:text-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"
href="{{ cafe.website_url }}"
target="_blank"
rel="noreferrer noopener"
title="Visit website"
>
<span class="sr-only">Visit {{ cafe.name }} website</span>
{% call icons::external_link("h-4 w-4") %}
</a>
{% else %}
<span
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-300 cursor-default"
title="No website"
aria-disabled="true"
>
{% call icons::external_link("h-4 w-4") %}
</span>
{% endif %}
{% if is_authenticated %}
<button
type="button"
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-500 transition hover:text-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-500"
title="Delete cafe"
data-on:click="confirm('Delete this cafe?') && @delete('/api/v1/cafes/{{ cafe.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#cafe-list', mode: 'replace'}})"
>
<span class="sr-only">Delete</span>
{% call icons::delete("h-4 w-4") %}
</button>
{% endif %}
</div>
<details class="card-menu md:hidden">
<summary>{% call icons::ellipsis_vertical("h-5 w-5") %}</summary>
<div class="card-menu-items">
<a href="{{ cafe.map_url }}" target="_blank" rel="noreferrer noopener">
{% call icons::location("h-4 w-4") %} View on map
</a>
{% if cafe.has_website %}
<a href="{{ cafe.website_url }}" target="_blank" rel="noreferrer noopener">
{% call icons::external_link("h-4 w-4") %} Visit website
</a>
{% endif %}
{% if is_authenticated %}
<button type="button" class="menu-item-danger"
data-on:click="this.closest('details').open = false; confirm('Delete this cafe?') && @delete('/api/v1/cafes/{{ cafe.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#cafe-list', mode: 'replace'}})">
{% call icons::delete("h-4 w-4") %} Delete
</button>
{% endif %}
</div>
</details>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if cafes.items.is_empty() %}
<div class="p-8 text-center text-stone-500">No cafes match your search.</div>
{% endif %}
{% call table::pagination_header(cafes, navigator, "#cafe-list") %}
{% if cafes.has_next() %}
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
{% endif %}
</section>
{% endif %}
</div>