Add search parameter update to brand filter buttons in Grid and List components

This commit is contained in:
sHa
2025-05-04 13:55:53 +03:00
parent a007d67828
commit 7b6fbbf280
2 changed files with 16 additions and 2 deletions

View File

@@ -72,7 +72,14 @@ $: getLogoThemeColor = logo => getDefaultLogoColor(logo.colors, theme);
<div class="logo-info">
<div class="logo-title-row">
<h3>{logo.name}</h3>
<button class="brand-filter-btn" title="Filter by brand" on:click={() => setSearchQuery(logo.brand)}>
<button class="brand-filter-btn" title="Filter by brand" on:click={() => {
setSearchQuery(logo.brand);
// Update URL with search param
const params = new URLSearchParams(window.location.search);
params.set('search', logo.brand);
const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : '');
history.replaceState(null, '', newUrl);
}}>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M20 4H4v2l6 6v8.5l4-2.5v-6l6-6V4z"/></svg>
{#if allLogos && allLogos.filter(l => l.brand === logo.brand).length > 1}
<span class="brand-count">{allLogos.filter(l => l.brand === logo.brand).length}</span>

View File

@@ -163,7 +163,14 @@
<button
class="brand-filter-btn common-btn"
title="Filter by brand"
on:click={() => setSearchQuery(logo.brand)}
on:click={() => {
setSearchQuery(logo.brand);
// Update URL with search param
const params = new URLSearchParams(window.location.search);
params.set('search', logo.brand);
const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : '');
history.replaceState(null, '', newUrl);
}}
>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
<path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M20 4H4v2l6 6v8.5l4-2.5v-6l6-6V4z"/>