Replace duplicated inline SVGs across 16 templates with reusable Askama macros from a new icons.html partial, reducing repetition and making icon updates a single-point change.
76 lines
3.6 KiB
HTML
76 lines
3.6 KiB
HTML
{% import "partials/table.html" as table %}
|
|
{% import "partials/icons.html" as icons %}
|
|
|
|
<div id="gear-list" class="mt-6" data-star-scope="gear">
|
|
{% if gear.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 gear found. Use the form above to add your first piece of brewing equipment.
|
|
</p>
|
|
</div>
|
|
{% else %}
|
|
<section class="rounded-lg border border-amber-300 bg-amber-100/80 shadow-sm"
|
|
{% if gear.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(gear.next_page().unwrap())|safe }}" data-target="#gear-list"{% endif %}
|
|
>
|
|
{% call table::search_header(navigator, "#gear-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, "#gear-list") %}
|
|
{% call table::sortable_header("Category", "category", navigator, "#gear-list") %}
|
|
{% call table::sortable_header("Make", "make", navigator, "#gear-list") %}
|
|
{% call table::sortable_header("Model", "model", navigator, "#gear-list") %}
|
|
{% if is_authenticated %}
|
|
<th scope="col" class="px-4 py-3 text-right">Actions</th>
|
|
{% endif %}
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-amber-200/70">
|
|
{% for item in gear.items %}
|
|
<tr class="bg-amber-50/40 transition hover:bg-amber-50">
|
|
<td data-label="Added" class="whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
|
|
{{ item.created_at }}
|
|
</td>
|
|
<td data-label="Category" class="px-4 py-3 whitespace-nowrap">
|
|
<span class="inline-flex rounded-full bg-amber-100 px-2 py-1 text-xs font-medium text-amber-800">
|
|
{{ item.category_label }}
|
|
</span>
|
|
</td>
|
|
<td data-label="Make" class="px-4 py-3 whitespace-nowrap font-medium text-stone-600">
|
|
{{ item.make }}
|
|
</td>
|
|
<td data-label="Model" class="px-4 py-3 whitespace-nowrap">
|
|
{{ item.model }}
|
|
</td>
|
|
{% if is_authenticated %}
|
|
<td data-label="" class="px-4 py-3 text-right">
|
|
<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 gear"
|
|
data-on:click="confirm('Delete this gear?') && @delete('/api/v1/gear/{{ item.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#gear-list', mode: 'replace'}})"
|
|
>
|
|
<span class="sr-only">Delete</span>
|
|
{% call icons::delete("h-4 w-4") %}
|
|
</button>
|
|
</td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% if gear.items.is_empty() %}
|
|
<div class="p-8 text-center text-stone-500">No gear matches your search.</div>
|
|
{% endif %}
|
|
{% call table::pagination_header(gear, navigator, "#gear-list") %}
|
|
{% if gear.has_next() %}
|
|
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
</div>
|