Compare commits

..

No commits in common. "d279e45467edc6c0974776d0f53cf9ff14dc1b1f" and "98710dd3a828579a585381acb96e3000fe6e0174" have entirely different histories.

2 changed files with 25 additions and 48 deletions

View file

@ -31,7 +31,7 @@
</div> </div>
<div <div
class="mt-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-4" class="mt-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-4"
> >
{{ range .Params.catalog }} {{ if ne .item "" }} {{ range .Params.catalog }} {{ if ne .item "" }}
<div <div
@ -49,6 +49,7 @@
<div <div
class="w-full h-52 rounded-md object-cover border-2 border-gray-200 bg-gray-100" class="w-full h-52 rounded-md object-cover border-2 border-gray-200 bg-gray-100"
></div> ></div>
{{ end }} {{ end }}
<div class="px-1 pt-4"> <div class="px-1 pt-4">
<div class="flex flex-row gap-2 justify-between font-bold text-xl mb-2"> <div class="flex flex-row gap-2 justify-between font-bold text-xl mb-2">
@ -139,34 +140,7 @@
<h3 class="text-xl mb-2" id="modal-title"> <h3 class="text-xl mb-2" id="modal-title">
<strong>{{ .item }}</strong> <strong>{{ .item }}</strong>
</h3> </h3>
{{ if .gallery }} {{ partial "catalog-gallery.html" . }}
<div
class="w-full mt-8 columns-1 gap-2 sm:columns-2 sm:gap-4 [&>div:not(:first-child)]:mt-4"
>
{{ range .gallery }}
<div
class="relative hover:scale-105 ease-in-out duration-200 transition-all hover:shadow-2xl"
>
<img
loading="lazy"
class="rounded-lg w-full"
src="{{ .image }}"
/>
<button class="absolute right-2 top-2">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
class="fill-black w-6 h-6 bg-white p-1 rounded-sm"
>
<path
d="M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z"
/>
</svg>
</button>
</div>
{{ end }}
</div>
{{ end }}
<div class="px-4 pt-6 w-full"> <div class="px-4 pt-6 w-full">
<div class="text-sm text-gray-800 text-base mb-4"> <div class="text-sm text-gray-800 text-base mb-4">
{{ if ne .quant "" }} {{ if ne .quant "" }}
@ -209,9 +183,7 @@
<strong>Rental Unavailable</strong> <strong>Rental Unavailable</strong>
</div> </div>
{{ end }} {{ if ne .purchaseCost "" }} {{ end }} {{ if ne .purchaseCost "" }}
<div <div class="border border-s-0 rounded-e-lg p-2 flex justify-between">
class="border border-s-0 rounded-e-lg p-2 flex justify-between"
>
<strong>Purchase Cost:</strong> <strong>Purchase Cost:</strong>
<span>{{ .purchaseCost }}</span> <span>{{ .purchaseCost }}</span>
</div> </div>
@ -244,7 +216,7 @@
</div> </div>
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const modalButtons = document.querySelectorAll(".grid.grid-cols-1 a"); const modalButtons = document.querySelectorAll(".grid-cols-1 a");
const closeButtons = document.querySelectorAll("#close-modal"); const closeButtons = document.querySelectorAll("#close-modal");
const modals = document.querySelectorAll(".fixed"); const modals = document.querySelectorAll(".fixed");
const radioButtons = document.querySelectorAll( const radioButtons = document.querySelectorAll(
@ -253,13 +225,14 @@
function filterItems(category) { function filterItems(category) {
console.log("Filtering items for category:", category); console.log("Filtering items for category:", category);
const items = document.querySelectorAll(".grid.grid-cols-1 > div"); const items = document.querySelectorAll(".grid > div");
items.forEach((item) => { items.forEach((item) => {
const itemCategory = item.querySelector(".bg-blue-100"); const itemCategory = item.querySelector(".bg-blue-100");
// Decode category to match actual category names in catalog if (
const decodedCategory = decodeURIComponent(category); !category ||
if (!category || itemCategory.textContent.trim() === decodedCategory) { decodeURIComponent(itemCategory.textContent.trim()) === category
) {
item.classList.remove("hidden"); item.classList.remove("hidden");
} else { } else {
item.classList.add("hidden"); item.classList.add("hidden");
@ -272,27 +245,31 @@
} }
function updateUrl(category) { function updateUrl(category) {
const url = new URL(window.location.href); const url = window.location.href.split("#")[0];
url.hash = encodeURIComponent(category); // Encode category for URL const newUrl = category ? `${url}#${encodeURIComponent(category)}` : url;
window.history.replaceState({}, "", url.toString()); window.history.replaceState({}, "", newUrl);
} }
const category = window.location.hash.substring(1); function handleCategoryChange(category) {
console.log("Selected category:", category);
updateUrl(category);
filterItems(category);
}
const category = decodeURIComponent(window.location.hash.substring(1));
console.log("Initial category:", category); console.log("Initial category:", category);
filterItems(category); handleCategoryChange(category);
window.addEventListener("hashchange", function () { window.addEventListener("hashchange", function () {
const newCategory = window.location.hash.substring(1); const newCategory = decodeURIComponent(window.location.hash.substring(1));
console.log("New category:", newCategory); console.log("New category:", newCategory);
filterItems(newCategory); handleCategoryChange(newCategory);
}); });
radioButtons.forEach((radio) => { radioButtons.forEach((radio) => {
radio.addEventListener("change", function () { radio.addEventListener("change", function () {
const category = this.value; const category = this.value;
console.log("Selected category:", category); handleCategoryChange(category);
updateUrl(category);
filterItems(category);
}); });
}); });

File diff suppressed because one or more lines are too long