search notify where we are searching
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled

This commit is contained in:
Priec
2026-06-25 20:46:46 +02:00
parent aea4782e68
commit 2023b24d92
4 changed files with 34 additions and 0 deletions

View File

@@ -47,6 +47,29 @@
</button>
</div>
{# Scope indicator: when a category is active, make clear the search is
limited to it (not the whole shop), with a one-click escape to search
everything. Category only changes via full navigation (the sidebar), so
this stays accurate across the toolbar's results-only htmx swaps. #}
{% if selected_category and selected_category != "all" %}
{# set_global so the value survives the nested if (a plain `set` inside a
block is scoped to that block in Tera and wouldn't be visible below). #}
{% set_global _scope = selected_category_name | default(value="") %}
{% if selected_category == "none" %}{% set_global _scope = t(key="uncategorized", lang=L) %}{% endif %}
{% if _scope %}
<div class="flex max-w-xl flex-wrap items-center gap-2 text-xs">
<span class="inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 font-medium text-primary dark:bg-primary-dark/15 dark:text-primary-dark">
{{ ui::icon(name="search", size="size-3.5", extra="shrink-0") }}
{{ t(key="search-scope-in", lang=L) }} <span class="font-semibold">{{ _scope }}</span>
</span>
<a href="/search{% if query %}?q={{ query | urlencode }}{% endif %}"
class="font-medium text-on-surface/60 underline-offset-2 hover:text-primary hover:underline dark:text-on-surface-dark/60 dark:hover:text-primary-dark">
{{ t(key="search-scope-all", lang=L) }}
</a>
</div>
{% endif %}
{% endif %}
<!-- sort + product card style switch -->
<div class="flex flex-wrap items-center justify-end gap-3">
<label class="flex items-center gap-2 text-xs font-medium text-on-surface/70 dark:text-on-surface-dark/70">