MapComplete/src/UI/BigComponents/ThemesList.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.4 KiB
Svelte
Raw Normal View History

2023-02-03 22:28:11 +01:00
<script lang="ts">
import NoThemeResultButton from "./NoThemeResultButton.svelte"
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
import { UIEventSource } from "../../Logic/UIEventSource"
2023-02-03 22:28:11 +01:00
import ThemeButton from "./ThemeButton.svelte"
import { MinimalThemeInformation } from "../../Models/ThemeConfig/ThemeConfig"
import Translations from "../i18n/Translations"
import Tr from "../Base/Tr.svelte"
import { Utils } from "../../Utils"
2023-02-03 22:28:11 +01:00
export let search: UIEventSource<string> = new UIEventSource<string>(undefined)
export let themes: MinimalThemeInformation[]
export let state: { osmConnection: OsmConnection }
export let onlyIcons: boolean = false
2024-10-19 14:44:55 +02:00
export let hasSelection: boolean = true
2023-02-03 22:28:11 +01:00
</script>
<section class="w-full">
2023-02-03 22:28:11 +01:00
<slot name="title" />
<div
2025-03-06 16:21:55 +01:00
class={onlyIcons
? "flex flex-wrap items-center justify-center gap-x-2"
: "theme-list my-2 gap-4 md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3"}
>
2025-04-09 17:11:46 +02:00
{#each Utils.DedupOnId(Utils.NoNull(themes)) as theme (theme.id)}
<ThemeButton {theme} {state} iconOnly={onlyIcons}>
{#if $search && hasSelection && themes?.[0] === theme}
2024-10-19 14:44:55 +02:00
<span class="thanks hidden-on-mobile" aria-hidden="true">
<Tr t={Translations.t.general.morescreen.enterToOpen} />
</span>
2023-02-09 00:10:59 +01:00
{/if}
</ThemeButton>
{/each}
</div>
{#if themes?.length === 0}
2023-02-03 22:28:11 +01:00
<NoThemeResultButton {search} />
{/if}
</section>