filter buttons now show whether they are selected

This commit is contained in:
2026-03-31 15:43:16 +02:00
parent 4ea6d168a6
commit 4641d2357a
3 changed files with 14 additions and 8 deletions

View File

@@ -1,11 +1,10 @@
<script lang="ts">
import Banner2 from "$lib/banner2.svelte";
import Content from "$lib/viewport/content.svelte";
import { BlogPostTag, posts, type BlogPostDetails, type BlogPostLink } from "./posts";
import { BlogPostTag, posts, type BlogPostLink } from "./posts";
import BlogGallery from "$lib/lists/blog-gallery.svelte";
let filter = $state(BlogPostTag.NULL);
let filteredPosts = filterPosts();
function setFilter(tag: BlogPostTag) {
filter = tag;
@@ -36,9 +35,11 @@
<!-- TODO descriptions on filter click -->
<div class="tag-filter-container">
{#each Object.values(BlogPostTag) as tag}
<button class="post-tag tag-filter" onclick={() => {
setFilter(tag)
}}>{tag}</button>
{#if tag == filter}
<button class="post-tag tag-filter tag-filter-selected" onclick={() => { setFilter(tag) }}>{tag}</button>
{:else}
<button class="post-tag tag-filter" onclick={() => { setFilter(tag) }}>{tag}</button>
{/if}
{/each}
</div>
@@ -59,9 +60,14 @@
padding: 8px;
border-radius: 12px;
cursor: pointer;
transition: background-color var(--duration-animation) var(--anim-curve);
}
.tag-filter-selected {
background-color: var(--color-highlight-alt);
}
.tag-filter:hover {
background-color: aqua;
background-color: var(--color-highlight-alt);
}
</style>