mapcomplete/UI/BigComponents/ThemesList.svelte

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

47 lines
1.6 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 type Loc from "../../Models/Loc"
import ThemeButton from "./ThemeButton.svelte"
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
$: filteredThemes = themes.filter((theme) => MoreScreen.MatchesLayout(theme, $search))
2023-02-03 22:28:11 +01:00
</script>
<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">
{#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>
{#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
{#if filteredThemes.length === 0}
2023-02-03 22:28:11 +01:00
<NoThemeResultButton {search} />
{/if}
</section>