- Add collapsible mobile tab selector with chevron icons - Integrate search bar into tab component (below tabs) - Replace Datastar search handler with vanilla JS for reliability - Add mobile card layout: card-title, card-date, card-actions classes - Add three-dot action menu for mobile with details/summary pattern - Hide duplicate search inside data-content via CSS - Pass search_value to DataTemplate for input preservation
85 lines
4.4 KiB
HTML
85 lines
4.4 KiB
HTML
{% import "partials/table.html" as table %}
|
|
{% import "partials/icons.html" as icons %}
|
|
|
|
<div id="cup-list" class="mt-6" data-star-scope="cups">
|
|
{% if cups.items.is_empty() && !navigator.has_search() %}
|
|
<div
|
|
class="rounded-lg border border-dashed border-amber-300 bg-amber-100/40 px-4 py-6 text-sm text-stone-600"
|
|
>
|
|
<p class="text-center">
|
|
No cups recorded yet. Use the form above to add your first cup.
|
|
</p>
|
|
</div>
|
|
{% else %}
|
|
<section class="rounded-lg border border-amber-300 bg-amber-100/80 shadow-sm"
|
|
{% if cups.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(cups.next_page().unwrap())|safe }}" data-target="#cup-list"{% endif %}
|
|
>
|
|
{% call table::search_header(navigator, "#cup-list") %}
|
|
<div class="overflow-x-auto">
|
|
<table class="responsive-table min-w-full divide-y divide-amber-200 text-left text-sm text-stone-700">
|
|
<thead class="bg-amber-200/60 text-xs font-semibold tracking-wide text-amber-900">
|
|
<tr>
|
|
{% call table::sortable_header("Added", "created-at", navigator, "#cup-list") %}
|
|
{% call table::sortable_header("Coffee", "roast", navigator, "#cup-list") %}
|
|
{% call table::sortable_header("Cafe", "cafe", navigator, "#cup-list") %}
|
|
{% call table::sortable_header("Rating", "rating", navigator, "#cup-list") %}
|
|
<th scope="col" class="px-4 py-3 text-right">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-amber-200/70">
|
|
{% for cup in cups.items %}
|
|
<tr
|
|
data-star-key="{{ cup.id }}"
|
|
class="bg-amber-50/40 transition hover:bg-amber-50"
|
|
>
|
|
<td data-label="Added" class="card-date whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
|
|
{{ cup.created_at }}
|
|
</td>
|
|
<td data-label="Coffee" class="card-title px-4 py-3 whitespace-nowrap">
|
|
<span class="font-semibold text-amber-800">{{ cup.roast_name }}</span>
|
|
<div class="hidden md:block text-xs text-stone-500">{{ cup.roaster_name }}</div>
|
|
</td>
|
|
<td data-label="Roaster" class="px-4 py-3 whitespace-nowrap md:hidden">{{ cup.roaster_name }}</td>
|
|
<td data-label="Cafe" class="px-4 py-3 whitespace-nowrap">
|
|
<span class="text-amber-800">{{ cup.cafe_name }}</span>
|
|
</td>
|
|
<td data-label="Rating" class="px-4 py-3 whitespace-nowrap">{{ cup.rating }}</td>
|
|
<td data-label="" class="card-actions px-4 py-3 text-right">
|
|
{% if is_authenticated %}
|
|
<div class="hidden md:inline-flex items-center gap-1">
|
|
<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 cup"
|
|
data-on:click="confirm('Delete this cup?') && @delete('/api/v1/cups/{{ cup.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#cup-list', mode: 'replace'}})"
|
|
>
|
|
<span class="sr-only">Delete</span>
|
|
{% call icons::delete("h-4 w-4") %}
|
|
</button>
|
|
</div>
|
|
<details class="card-menu md:hidden">
|
|
<summary>{% call icons::ellipsis_vertical("h-5 w-5") %}</summary>
|
|
<div class="card-menu-items">
|
|
<button type="button" class="menu-item-danger"
|
|
data-on:click="this.closest('details').open = false; confirm('Delete this cup?') && @delete('/api/v1/cups/{{ cup.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#cup-list', mode: 'replace'}})">
|
|
{% call icons::delete("h-4 w-4") %} Delete
|
|
</button>
|
|
</div>
|
|
</details>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% if cups.items.is_empty() %}
|
|
<div class="p-8 text-center text-stone-500">No cups match your search.</div>
|
|
{% endif %}
|
|
{% call table::pagination_header(cups, navigator, "#cup-list") %}
|
|
{% if cups.has_next() %}
|
|
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
</div>
|