feat: add more infos to info sidebar
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import Badge from "$lib/components/ui/badge/badge.svelte";
|
||||
import { getStations } from "$lib/services/MTSK";
|
||||
import RequiresCapability from "../RequiresCapability.svelte";
|
||||
|
||||
let { tags, lat, lng } = $props();
|
||||
</script>
|
||||
@ -9,15 +10,15 @@
|
||||
<ul class="flex gap-2 flex-wrap">
|
||||
{#each Object.entries(tags).filter( ([key]) => key.startsWith("fuel:"), ) as [key, tag] (key)}
|
||||
<!-- <li>{key.replace("fuel:", "")}: {tag}</li> -->
|
||||
{#if tag == "yes"}
|
||||
<Badge>
|
||||
{key.replace("fuel:", "")}
|
||||
{#if tag !== "yes"}
|
||||
({tag})
|
||||
{/if}
|
||||
</Badge>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<RequiresCapability capability="fuel">
|
||||
<h3 class="text-lg font-bold mt-2">Prices</h3>
|
||||
{#await getStations(lat, lng)}
|
||||
<p>Loading fuel prices...</p>
|
||||
@ -39,3 +40,4 @@
|
||||
{:catch err}
|
||||
<p>Error loading fuel prices: {err.message}</p>
|
||||
{/await}
|
||||
</RequiresCapability>
|
||||
|
||||
21
src/lib/components/lnv/info/InternetAccess.svelte
Normal file
21
src/lib/components/lnv/info/InternetAccess.svelte
Normal file
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
import Badge from "$lib/components/ui/badge/badge.svelte";
|
||||
|
||||
let { tags } = $props();
|
||||
|
||||
const tag = $derived(tags.internet_access);
|
||||
const splitter = $derived(tag.split(";"));
|
||||
</script>
|
||||
|
||||
{#if tag != "no"}
|
||||
<h3 class="text-lg font-bold mt-2">Internet Access</h3>
|
||||
{#each splitter as value, _index (value)}
|
||||
<Badge>{value}</Badge>
|
||||
{/each}
|
||||
{#if tags["internet_access:fee"] && tags["internet_access:fee"] != "no"}
|
||||
<Badge>Fee: {tags["internet_access:fee"]}</Badge>
|
||||
{/if}
|
||||
{#if tags["internet_access:ssid"]}
|
||||
<Badge>{tags["internet_access:ssid"]}</Badge>
|
||||
{/if}
|
||||
{/if}
|
||||
22
src/lib/components/lnv/info/RestaurantInfo.svelte
Normal file
22
src/lib/components/lnv/info/RestaurantInfo.svelte
Normal file
@ -0,0 +1,22 @@
|
||||
<script>
|
||||
import Badge from "$lib/components/ui/badge/badge.svelte";
|
||||
|
||||
let { tags } = $props();
|
||||
|
||||
const TAGS = ["cuisine", "indoor_seating", "outdoor_seating", "takeaway", "drive_through"];
|
||||
|
||||
const matchingTags = TAGS.filter(tag => tag in tags);
|
||||
</script>
|
||||
|
||||
{#if matchingTags.length > 0}
|
||||
<h3 class="text-lg font-bold mt-2">Restaurant</h3>
|
||||
<ul class="flex gap-2 flex-wrap">
|
||||
{#each matchingTags as tag}
|
||||
{#if tag != "no"}
|
||||
<Badge>
|
||||
{tag}{tags[tag] == "yes" ? "" : ": " + tags[tag]}
|
||||
</Badge>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
@ -23,12 +23,16 @@
|
||||
import MapAi from "../info/MapAI.svelte";
|
||||
import RequiresCapability from "../RequiresCapability.svelte";
|
||||
import { saved, saveLocations } from "$lib/saved.svelte";
|
||||
import { getDeveloperToggle } from "./settings/developer.svelte";
|
||||
import InternetAccess from "../info/InternetAccess.svelte";
|
||||
import RestaurantInfo from "../info/RestaurantInfo.svelte";
|
||||
|
||||
// let { feature }: { feature: Feature } = $props();
|
||||
|
||||
// let Icon = $derived(POIIcons[feature.properties.osm_key + "=" + feature.properties.osm_value]);
|
||||
|
||||
let { lat, lng }: { lat: number; lng: number } = $props();
|
||||
const dev = getDeveloperToggle();
|
||||
|
||||
function getIcon(
|
||||
tags: Record<string, string>,
|
||||
@ -207,6 +211,16 @@
|
||||
<BriefcaseIcon />
|
||||
Set as Work
|
||||
</Button>
|
||||
{#if dev.current}
|
||||
<Button
|
||||
variant="outline"
|
||||
onclick={() => {
|
||||
alert(JSON.stringify(elements, null, 3))
|
||||
console.log(elements);
|
||||
}}>
|
||||
Show raw data
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
||||
@ -228,10 +242,14 @@
|
||||
<OpeningHours hours={tags.opening_hours} {lat} lon={lng} />
|
||||
{/if}
|
||||
|
||||
{#if tags.internet_access}
|
||||
<InternetAccess {tags} />
|
||||
{/if}
|
||||
|
||||
<RestaurantInfo {tags} />
|
||||
|
||||
{#if tags.amenity == "fuel"}
|
||||
<RequiresCapability capability="fuel">
|
||||
<FuelStation {tags} {lat} {lng} />
|
||||
</RequiresCapability>
|
||||
{/if}
|
||||
|
||||
<!-- any payment:* tag -->
|
||||
@ -239,7 +257,7 @@
|
||||
<h3 class="text-lg font-bold mt-2">Payment Methods</h3>
|
||||
<ul style="display: flex; flex-wrap: wrap; gap: 0.5rem;">
|
||||
{#each Object.entries(tags).filter( ([key]) => key.startsWith("payment:"), ) as [key, value] (key)}
|
||||
<Badge>{key.replace("payment:", "")}: {value}</Badge>
|
||||
<Badge>{key.replace("payment:", "")}{value == "yes" ? "" : ": " + value}</Badge>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
@ -249,8 +267,6 @@
|
||||
</RequiresCapability>
|
||||
|
||||
<span style="color: #acacac;">© OpenStreetMap</span>
|
||||
|
||||
<pre>{JSON.stringify(elements, null, 2)}</pre>
|
||||
{/if}
|
||||
{:catch err}
|
||||
<SidebarHeader
|
||||
|
||||
Reference in New Issue
Block a user