74 lines
4.1 KiB
Plaintext
74 lines
4.1 KiB
Plaintext
package templates
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.ma-al.com/goc_marek/ps_shop/internal/viewmodel"
|
|
)
|
|
|
|
templ CategoryPage(data viewmodel.CategoryPageData, cssPath string, jsPath string) {
|
|
@Layout(data.Category.Name, cssPath, jsPath, data.Menu, data.Locale, layoutCartItems(data.CartSummary)) {
|
|
<main class="min-h-screen bg-[radial-gradient(circle_at_top_left,_rgba(34,197,94,0.18),_transparent_35%),linear-gradient(180deg,#0b1020,#111827)]">
|
|
<div class="mx-auto flex w-full max-w-[104rem] flex-col gap-10 px-6 py-10 lg:px-8">
|
|
<header class="rounded-[2rem] border border-emerald-500/20 bg-white/5 p-8 backdrop-blur">
|
|
<p class="text-xs uppercase tracking-[0.32em] text-emerald-300">Category</p>
|
|
<h1 class="mt-4 font-serif text-4xl text-white">{ data.Category.Name }</h1>
|
|
<div class="mt-4 flex items-center justify-between gap-6 text-sm text-slate-300">
|
|
<p>{ fmt.Sprintf("Products %d-%d of %d", categoryPageStart(data.Pagination), categoryPageEnd(data.Pagination, len(data.Category.Products)), data.Pagination.TotalItems) }</p>
|
|
if data.Customer != nil {
|
|
<p>{ fmt.Sprintf("%s %s", data.Customer.FirstName, data.Customer.LastName) }</p>
|
|
} else {
|
|
<p>Guest session</p>
|
|
}
|
|
</div>
|
|
if data.Category.Description != "" {
|
|
<div class="prose prose-invert mt-6 max-w-none text-slate-300">
|
|
@templ.Raw(data.Category.Description)
|
|
</div>
|
|
}
|
|
</header>
|
|
|
|
<section class="grid gap-5 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
|
|
for _, product := range data.Category.Products {
|
|
<article class="group rounded-[1.75rem] border border-white/10 bg-slate-900/70 p-6 shadow-[0_24px_80px_rgba(0,0,0,0.35)] transition hover:-translate-y-1 hover:border-emerald-400/40">
|
|
if product.ImageURL != "" {
|
|
<a class="mb-5 block overflow-hidden rounded-[1.25rem] border border-white/10 bg-slate-950/70 shadow-[0_16px_40px_rgba(0,0,0,0.24)]" href={ product.URL }>
|
|
<img class="block h-64 w-full object-cover transition duration-500 group-hover:scale-[1.03]" src={ product.ImageURL } alt={ product.Name }/>
|
|
</a>
|
|
}
|
|
<p class="text-xs uppercase tracking-[0.28em] text-emerald-300">Product</p>
|
|
<h2 class="mt-3 text-2xl font-semibold text-white">{ product.Name }</h2>
|
|
<p class="mt-4 text-sm leading-7 text-slate-300">{ truncatedPlainTextHTML(product.ShortDescription, 220) }</p>
|
|
<div class="mt-8 flex items-center justify-between gap-4">
|
|
<div>
|
|
<p class="text-2xl font-semibold text-white">{ moneyWithCurrency(product.PriceTaxIncl, product.CurrencySign, product.CurrencyCode) }</p>
|
|
<p class="mt-1 text-xs uppercase tracking-[0.2em] text-slate-400">{ taxLabel(product.TaxRate) } · { conversionRateLabel(product.ConversionRate, product.CurrencyCode) }</p>
|
|
</div>
|
|
<a class="rounded-full border border-emerald-400/40 px-4 py-2 text-xs font-semibold uppercase tracking-[0.22em] text-emerald-200 transition hover:bg-emerald-300 hover:text-slate-950" href={ product.URL }>
|
|
View Product
|
|
</a>
|
|
</div>
|
|
</article>
|
|
}
|
|
</section>
|
|
if data.Pagination.TotalPages > 1 {
|
|
<nav class="flex flex-col items-center justify-between gap-4 rounded-[1.75rem] border border-white/10 bg-slate-950/50 px-6 py-5 text-sm text-slate-300 md:flex-row">
|
|
<div>
|
|
<p class="text-xs uppercase tracking-[0.24em] text-emerald-300">Page</p>
|
|
<p class="mt-1">{ fmt.Sprintf("%d of %d", data.Pagination.Page, data.Pagination.TotalPages) }</p>
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
if data.Pagination.PrevURL != "" {
|
|
<a class="rounded-full border border-white/10 px-4 py-2 font-semibold uppercase tracking-[0.2em] text-slate-200 transition hover:border-emerald-400/40 hover:text-white" href={ data.Pagination.PrevURL }>Previous</a>
|
|
}
|
|
if data.Pagination.NextURL != "" {
|
|
<a class="rounded-full border border-emerald-400/40 px-4 py-2 font-semibold uppercase tracking-[0.2em] text-emerald-200 transition hover:bg-emerald-300 hover:text-slate-950" href={ data.Pagination.NextURL }>Next</a>
|
|
}
|
|
</div>
|
|
</nav>
|
|
}
|
|
</div>
|
|
</main>
|
|
}
|
|
}
|