2023-02-03 22:28:11 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import NoThemeResultButton from "./NoThemeResultButton.svelte"
|
|
|
|
|
2023-05-08 01:55:21 +02:00
|
|
|
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource"
|
2023-02-03 22:28:11 +01:00
|
|
|
import type Loc from "../../Models/Loc"
|
|
|
|
import ThemeButton from "./ThemeButton.svelte"
|
2023-05-08 01:55:21 +02:00
|
|
|
import {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
2023-05-07 23:54:31 +02:00
|
|
|
import MoreScreen from "./MoreScreen"
|
2023-02-03 22:28:11 +01:00
|
|
|
|
|
|
|
export let search: UIEventSource<string>
|
2023-02-11 15:04:20 +01:00
|
|
|
export let themes: LayoutInformation[]
|
2023-02-03 22:28:11 +01:00
|
|
|
export let state: { osmConnection: OsmConnection; locationControl?: UIEventSource<Loc> }
|
|
|
|
export let isCustom: boolean = false
|
|
|
|
export let onMainScreen: boolean = true
|
|
|
|
export let hideThemes: boolean = true
|
|
|
|
|
|
|
|
// Filter theme based on search value
|
2023-04-23 13:22:57 +02:00
|
|
|
$: filteredThemes = themes.filter((theme) => MoreScreen.MatchesLayout(theme, $search))
|
2023-02-03 22:28:11 +01:00
|
|
|
</script>
|
|
|
|
|
2023-05-22 01:37:02 +02:00
|
|
|
<section class="w-full">
|
2023-02-03 22:28:11 +01:00
|
|
|
<slot name="title" />
|
2023-02-09 00:10:59 +01:00
|
|
|
{#if onMainScreen}
|
|
|
|
<div class="md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3 gap-4">
|
2023-03-13 21:31:27 +01:00
|
|
|
{#each filteredThemes as theme (theme.id)}
|
2023-02-09 00:10:59 +01:00
|
|
|
{#if theme !== undefined && !(hideThemes && theme?.hideFromOverview)}
|
|
|
|
<ThemeButton {theme} {isCustom} userDetails={state.osmConnection.userDetails} {state} />
|
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
</div>
|
2023-03-09 20:54:12 +01:00
|
|
|
{:else}
|
2023-02-09 00:10:59 +01:00
|
|
|
<div>
|
|
|
|
|
2023-03-13 21:31:27 +01:00
|
|
|
{#each filteredThemes as theme (theme.id)}
|
2023-02-09 00:10:59 +01:00
|
|
|
{#if theme !== undefined && !(hideThemes && theme?.hideFromOverview)}
|
|
|
|
<ThemeButton {theme} {isCustom} userDetails={state.osmConnection.userDetails} {state} />
|
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
</div>
|
2023-03-09 20:54:12 +01:00
|
|
|
{/if}
|
2023-02-03 22:28:11 +01:00
|
|
|
|
2023-05-22 01:37:02 +02:00
|
|
|
{#if filteredThemes.length === 0}
|
2023-02-03 22:28:11 +01:00
|
|
|
<NoThemeResultButton {search} />
|
|
|
|
{/if}
|
|
|
|
</section>
|