2023-02-03 22:28:11 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import NoThemeResultButton from "./NoThemeResultButton.svelte"
|
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
|
|
|
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
2023-02-03 22:28:11 +01:00
|
|
|
import ThemeButton from "./ThemeButton.svelte"
|
2023-06-14 20:39:36 +02:00
|
|
|
import { LayoutInformation } from "../../Models/ThemeConfig/LayoutConfig"
|
2023-05-07 23:54:31 +02:00
|
|
|
import MoreScreen from "./MoreScreen"
|
2023-07-05 23:39:40 +02:00
|
|
|
import themeOverview from "../../assets/generated/theme_overview.json"
|
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-06-06 00:03:14 +02:00
|
|
|
export let state: { osmConnection: OsmConnection }
|
2023-02-03 22:28:11 +01:00
|
|
|
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-07-05 23:39:40 +02:00
|
|
|
|
|
|
|
// Determine which is the first theme, after the search, using all themes
|
|
|
|
$: allFilteredThemes = themeOverview.filter((theme) => MoreScreen.MatchesLayout(theme, $search))
|
|
|
|
$: firstTheme = allFilteredThemes[0]
|
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}
|
2023-06-14 20:44:01 +02:00
|
|
|
<div class="gap-4 md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3">
|
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)}
|
2023-07-28 01:02:31 +02:00
|
|
|
<!-- TODO: doesn't work if first theme is hidden -->
|
2023-07-05 23:39:40 +02:00
|
|
|
{#if theme === firstTheme && !isCustom && $search !== "" && $search !== undefined}
|
|
|
|
<ThemeButton
|
|
|
|
{theme}
|
|
|
|
{isCustom}
|
|
|
|
userDetails={state.osmConnection.userDetails}
|
|
|
|
{state}
|
|
|
|
selected={true}
|
|
|
|
/>
|
|
|
|
{:else}
|
|
|
|
<ThemeButton {theme} {isCustom} userDetails={state.osmConnection.userDetails} {state} />
|
|
|
|
{/if}
|
2023-02-09 00:10:59 +01:00
|
|
|
{/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>
|