product category page: front-end sorting and filtering using turboframes

This commit is contained in:
elvira
2026-08-31 22:56:40 +03:00
parent b070a7d1e6
commit 8a07c772f8
20 changed files with 428 additions and 148 deletions
@@ -14,7 +14,7 @@ import { Controller } from '@hotwired/stimulus'
// max and vice versa. Emits `range-slider:input` while dragging and
// `range-slider:change` on commit, both with { min, max }.
export default class extends Controller {
static targets = ['minInput', 'maxInput', 'field', 'track', 'minThumb', 'maxThumb', 'output', 'reset']
static targets = ['minInput', 'maxInput', 'field', 'track', 'minThumb', 'maxThumb', 'output']
static values = {
min: Number,
max: Number,
@@ -26,7 +26,6 @@ export default class extends Controller {
connect() {
this.#clamp()
this.defaults = { min: this.#lo, max: this.#hi }
this.fieldTargets.forEach((field) => field.classList.add('sr-only'))
this.#render()
}
@@ -78,13 +77,6 @@ export default class extends Controller {
this.#startDrag(event, input)
}
reset() {
this.minInputTarget.value = this.defaults.min
this.maxInputTarget.value = this.defaults.max
this.#render()
this.#emit('change')
}
// ── internals ──────────────────────────────────────────────────────
#startDrag(event, input) {
@@ -158,10 +150,6 @@ export default class extends Controller {
const fmt = (v) => `${this.prefixValue}${v}${this.suffixValue}`
this.outputTarget.textContent = fmt(lo) + this.separatorValue + fmt(hi)
}
if (this.hasResetTarget) {
this.resetTarget.hidden = lo === this.defaults.min && hi === this.defaults.max
}
}
#emit(name) {