Add QuickLinks based on 'frecency' pattern

This commit is contained in:
2026-04-21 19:54:00 +01:00
parent a07315cec2
commit 8c0d385772
6 changed files with 181 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { onMount } from 'svelte';
import { slide } from 'svelte/transition';
import { slide } from 'svelte/transition';
let isNotLondon = $state(false);
let londonZone = $state('Greenwich Mean Time');
@@ -19,24 +19,26 @@
</script>
{#if isNotLondon}
<div transition:slide={{duration: 300}} class="tzWarn"><p class="tzText">
All times are shown in <strong>{londonZone}</strong>
</p></div>
<div transition:slide={{ duration: 300 }} class="tzWarn">
<p class="tzText">
All times are shown in <strong>{londonZone}</strong>
</p>
</div>
{/if}
<style>
.tzWarn {
display: flex;
justify-content: center;
width: 100%;
padding: 1rem 0 0 0;
}
.tzWarn {
display: flex;
justify-content: center;
width: 100%;
padding: 1rem 0 0 0;
}
.tzText {
width: 80%;
text-align: center;
margin: auto;
font-family: 'URW Gothic', sans-serif;
font-size: 1.2rem;
}
</style>
.tzText {
width: 80%;
text-align: center;
margin: auto;
font-family: 'URW Gothic', sans-serif;
font-size: 1.2rem;
}
</style>

View File

@@ -0,0 +1,71 @@
<script lang="ts">
import BaseCard from '$lib/components/ui/cards/BaseCard.svelte';
import Button from '$lib/components/ui/Button.svelte';
import { fade } from 'svelte/transition';
import { flip } from 'svelte/animate';
import { quickLinks } from '$lib/quick-links.svelte';
const flipDuration = 300;
</script>
<BaseCard header={'Quick Links'}>
<div class="card-content">
{#if quickLinks.list.length === 0}
<p class="msg">Your most viewed stations will appear here</p>
{:else}
<div class="stations-flex">
{#each quickLinks.list as station (station.id)}
<div
class="btn-container"
animate:flip={{ duration: flipDuration }}
in:fade|global={{ duration: 200 }}
>
<Button href={`/board?loc=${station.id}`}
><span class="stn-name">{station.id}</span></Button
>
</div>
{/each}
</div>
{/if}
</div>
</BaseCard>
<style>
.card-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
width: 90%;
min-height: 98px;
margin: auto;
padding: 10px 0 10px 0;
}
.stations-flex {
display: flex;
flex-wrap: wrap;
gap: 0.1rem 0.5rem;
justify-content: center;
align-items: flex-start;
}
.btn-container {
display: block;
width: fit-content;
will-change: transform;
}
.msg {
font-size: 1.1rem;
font-weight: 600;
color: var(--color-title);
}
.stn-name {
text-transform: capitalize;
}
</style>