search changing newest to relevance on search now
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
server-side on first load. Holds the result summary, the product grid and
|
||||
pagination. #}
|
||||
{% set L = lang | default(value='sk') %}
|
||||
{# On htmx responses the toolbar's Sort dropdown isn't in this swapped region;
|
||||
re-render it out-of-band so a search-triggered "newest → relevance" switch is
|
||||
reflected in the visible selection. #}
|
||||
{% if is_fragment | default(value=false) %}{% set oob = true %}{% include "shop/_sort_select.html" %}{% endif %}
|
||||
<div class="space-y-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<p class="text-sm text-on-surface/70 dark:text-on-surface-dark/70" aria-live="polite">
|
||||
|
||||
@@ -51,12 +51,7 @@
|
||||
<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">
|
||||
{{ t(key="sort-label", lang=L) }}
|
||||
<select name="sort"
|
||||
class="rounded-radius border border-outline bg-surface px-2 py-1.5 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark dark:text-on-surface-dark">
|
||||
{% for opt in ["newest", "relevance", "price_asc", "price_desc", "name_asc", "name_desc"] %}
|
||||
<option value="{{ opt }}"{% if sort == opt %} selected{% endif %}>{{ t(key="sort-" ~ opt, lang=L) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% include "shop/_sort_select.html" %}
|
||||
</label>
|
||||
|
||||
<!-- per-page count -->
|
||||
|
||||
12
assets/views/shop/_sort_select.html
Normal file
12
assets/views/shop/_sort_select.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{# Sort dropdown, shared by the toolbar (in the search form) and the results
|
||||
fragment. A search promotes the default "newest" to "relevance" server-side,
|
||||
but the toolbar select lives outside the swapped #shop-results region — so on
|
||||
htmx responses _results.html re-renders this with `oob = true` (hx-swap-oob)
|
||||
to keep the visible selection in sync with the actual ordering. #}
|
||||
{% set L = lang | default(value='sk') %}
|
||||
<select id="sort-select" name="sort"{% if oob | default(value=false) %} hx-swap-oob="true"{% endif %}
|
||||
class="rounded-radius border border-outline bg-surface px-2 py-1.5 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark dark:text-on-surface-dark">
|
||||
{% for opt in ["newest", "relevance", "price_asc", "price_desc", "name_asc", "name_desc"] %}
|
||||
<option value="{{ opt }}"{% if sort == opt %} selected{% endif %}>{{ t(key="sort-" ~ opt, lang=L) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
Reference in New Issue
Block a user