Feature: add "recently visited themes" on index page

This commit is contained in:
Pieter Vander Vennet 2025-02-16 00:04:48 +01:00
parent 1723f268c0
commit 4db2c86c0f
5 changed files with 47 additions and 21 deletions

View file

@ -1,5 +1,4 @@
<script lang="ts">
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
import type { MinimalThemeInformation } from "../../Models/ThemeConfig/ThemeConfig"
import Tr from "../Base/Tr.svelte"
@ -10,7 +9,7 @@
export let theme: MinimalThemeInformation & { isOfficial?: boolean }
let isCustom: boolean = theme.id.startsWith("https://") || theme.id.startsWith("http://")
export let state: { layoutToUse?: { id: string }; osmConnection: OsmConnection }
export let iconOnly: boolean = false
$: title = Translations.T(
theme.title,
!isCustom && !theme.mustHaveLanguage ? "themes:" + theme.id + ".title" : undefined
@ -71,12 +70,17 @@
)
</script>
<a class="low-interaction my-1 flex w-full items-center text-ellipsis rounded p-1" href={$href}>
<Marker icons={theme.icon} size="block h-8 w-8 sm:h-11 sm:w-11 m-1 sm:mx-2 md:mx-4 shrink-0" />
<span class="flex flex-col overflow-hidden text-ellipsis text-xl font-bold">
<Tr cls="" t={title} />
<Tr cls="subtle text-base" t={description} />
<slot />
</span>
</a>
{#if iconOnly}
<a class="low-interaction my-1 rounded p-1" href={$href}>
<Marker icons={theme.icon} size="w-8 h-8 sm:w-11 sm:h-11" />
</a>
{:else}
<a class="low-interaction my-1 flex w-full items-center text-ellipsis rounded p-1" href={$href}>
<Marker icons={theme.icon} size="block h-8 w-8 sm:h-11 sm:w-11 m-1 sm:mx-2 md:mx-4 shrink-0" />
<span class="flex flex-col overflow-hidden text-ellipsis text-xl font-bold">
<Tr cls="" t={title} />
<Tr cls="subtle text-base" t={description} />
<slot />
</span>
</a>
{/if}

View file

@ -7,19 +7,21 @@
import { MinimalThemeInformation } from "../../Models/ThemeConfig/ThemeConfig"
import Translations from "../i18n/Translations"
import Tr from "../Base/Tr.svelte"
import { twMerge } from "tailwind-merge"
export let search: UIEventSource<string>
export let search: UIEventSource<string> = new UIEventSource<string>(undefined)
export let themes: MinimalThemeInformation[]
export let state: { osmConnection: OsmConnection }
export let onlyIcons: boolean = false
export let hasSelection: boolean = true
</script>
<section class="w-full">
<slot name="title" />
<div class="theme-list my-2 gap-4 md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3">
<div
class={onlyIcons ? "flex gap-x-2 flex-wrap items-center justify-center" : ("theme-list my-2 gap-4 md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3")}>
{#each themes as theme (theme.id)}
<ThemeButton {theme} {state}>
<ThemeButton {theme} {state} iconOnly={onlyIcons}>
{#if $search && hasSelection && themes?.[0] === theme}
<span class="thanks hidden-on-mobile" aria-hidden="true">
<Tr t={Translations.t.general.morescreen.enterToOpen} />