From dc92cf377f52e5f165020ea5a8407a14d279264c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Feb 2026 14:14:53 -0800 Subject: store ark state --- src/components/LocationsMap.svelte | 47 +++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'src/components') diff --git a/src/components/LocationsMap.svelte b/src/components/LocationsMap.svelte index cd6bd69f..7529edcb 100644 --- a/src/components/LocationsMap.svelte +++ b/src/components/LocationsMap.svelte @@ -102,22 +102,31 @@ if (showFilters) showList = false; }; - const categoryLabels: { slug: string; name: string }[] = [ - { slug: "restaurant", name: "Restaurant" }, - { slug: "cafe", name: "Café" }, - { slug: "bar", name: "Bar" }, - { slug: "fast-food", name: "Fast Food" }, - { slug: "grocery", name: "Grocery" }, - { slug: "hairdresser", name: "Hairdresser" }, - { slug: "hotel", name: "Hotel" }, - { slug: "shop", name: "Shop" }, - { slug: "atm", name: "ATM" }, - { slug: "health", name: "Health" }, - { slug: "office", name: "Office" }, - { slug: "default", name: "Other" }, + const categorySlugs = [ + "restaurant", "cafe", "bar", "fast-food", "grocery", "hairdresser", + "hotel", "shop", "atm", "health", "office", "default", ]; - let activeFilters: Set = $state(new Set(categoryLabels.map((c) => c.slug))); + const categoryTranslationKeys: Record = { + "restaurant": "map.restaurant", + "cafe": "map.cafe", + "bar": "map.bar", + "fast-food": "map.fastFood", + "grocery": "map.grocery", + "hairdresser": "map.hairdresser", + "hotel": "map.hotel", + "shop": "map.shop", + "atm": "map.atm", + "health": "map.health", + "office": "map.office", + "default": "map.other", + }; + + let categoryLabels = $derived( + categorySlugs.map((slug) => ({ slug, name: $t(categoryTranslationKeys[slug]) })) + ); + + let activeFilters: Set = $state(new Set(categorySlugs)); let lastToggledOn: string | undefined = $state(); @@ -141,7 +150,7 @@ } function setAllFilters() { - activeFilters = new Set(categoryLabels.map((c) => c.slug)); + activeFilters = new Set(categorySlugs); } function clearAllFilters() { @@ -565,7 +574,7 @@ : inview, ); - let categoryLabelMap = Object.fromEntries(categoryLabels.map((c) => [c.slug, c.name])); + let categoryLabelMap = $derived(Object.fromEntries(categoryLabels.map((c) => [c.slug, c.name]))); let presentCategories = $derived( categoryLabels.filter((c) => inview.some((m) => m.category === c.slug)), @@ -609,7 +618,7 @@
- +
{#if search} + >{$t("map.all")} + >{$t("map.none")} -- cgit v1.2.3