From 2a5751afd589b943f072045207a9a78f6fe3d68c Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Tue, 12 Sep 2023 12:47:50 +0200 Subject: [PATCH] Show only active campsite types Relaxed the `max-width: 25%` to fill the whole row in the home page; it is very unlikely that they will have lees than four types, though. --- pkg/app/public.go | 2 +- pkg/template/page.go | 2 +- web/static/public.css | 37 ++++++++++++++++--------------------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/pkg/app/public.go b/pkg/app/public.go index 46c3978..6f50441 100644 --- a/pkg/app/public.go +++ b/pkg/app/public.go @@ -65,7 +65,7 @@ type campsiteType struct { } func mustCollectCampsiteTypes(ctx context.Context, company *auth.Company, conn *database.Conn, loc *locale.Locale) []*campsiteType { - rows, err := conn.Query(ctx, "select name, '/campsites/types/' || slug, '/media/' || encode(hash, 'hex') || '/' || original_filename from campsite_type join media using (media_id) where campsite_type.company_id = $1", company.ID) + rows, err := conn.Query(ctx, "select name, '/campsites/types/' || slug, '/media/' || encode(hash, 'hex') || '/' || original_filename from campsite_type join media using (media_id) where campsite_type.company_id = $1 and campsite_type.active", company.ID) if err != nil { panic(err) } diff --git a/pkg/template/page.go b/pkg/template/page.go index e3cfdad..76071a6 100644 --- a/pkg/template/page.go +++ b/pkg/template/page.go @@ -40,7 +40,7 @@ func (p *PublicPage) Setup(r *http.Request, user *auth.User, company *auth.Compa sort.Slice(p.LocalizedAlternates, func(i, j int) bool { return p.LocalizedAlternates[i].Lang < p.LocalizedAlternates[j].Lang }) p.Menu = &siteMenu{ - CampsiteTypes: mustCollectMenuItems(r.Context(), conn, user.Locale, "select name, '/campsites/types/' || slug from campsite_type where company_id = $1", company.ID), + CampsiteTypes: mustCollectMenuItems(r.Context(), conn, user.Locale, "select name, '/campsites/types/' || slug from campsite_type where company_id = $1 and active", company.ID), } } diff --git a/web/static/public.css b/web/static/public.css index 58d9e3a..cf9456e 100644 --- a/web/static/public.css +++ b/web/static/public.css @@ -378,7 +378,6 @@ nav .has-submenu:hover ul, nav .has-submenu:focus-within ul { .nature section { flex: 1; - max-width: 25%; } .nature section h3 { @@ -398,6 +397,22 @@ nav .has-submenu:hover ul, nav .has-submenu:focus-within ul { border-bottom-right-radius: 5px; } +@media (max-width: 64rem) { + .nature div + div { + flex-direction: column; + } +} + +@media (max-width: 48rem) { + .nature div:first-child { + flex-direction: column; + } + + .nature h2 { + width: 100%; + } +} + .services { justify-content: end; background-color: var(--accent); @@ -497,23 +512,3 @@ footer { text-align: center; padding: 2.5rem; } - -@media (max-width: 64rem) { - .nature div + div { - flex-direction: column; - } - - .nature section { - max-width: 100%; - } -} - -@media (max-width: 48rem) { - .nature div:first-child { - flex-direction: column; - } - - .nature h2 { - width: 100%; - } -}