Hide filters by default on mobile

This commit is contained in:
Adrien Maston
2026-01-20 13:39:00 +01:00
parent 161925ab2b
commit 3a685ca2b9
5 changed files with 64 additions and 24 deletions
+1
View File
@@ -0,0 +1 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M23 0L1.00002 0C0.194222 0 -0.283458 0.955359 0.200023 1.6L9.00002 13.423V22C9.01178 23.585 10.9006 24.5769 12.2 23.6L14.2 22.1C14.696 21.7267 14.9989 21.1208 15 20.5V13.423L23.8 1.6C24.2835 0.955343 23.8058 2.70383e-05 23 0Z" fill="black"/></svg>

After

Width:  |  Height:  |  Size: 317 B

+13
View File
@@ -0,0 +1,13 @@
@layer components {
.expandable-on-native {
body:not([data-platform~=native]) & {
&::details-content {
display: contents;
}
summary {
display: none;
}
}
}
}
@@ -0,0 +1,16 @@
import { Controller } from "@hotwired/stimulus"
import { isNative } from "helpers/platform_helpers"
export default class extends Controller {
static get shouldLoad() {
return isNative()
}
static values = { autoExpandSelector: String }
connect() {
if (this.hasAutoExpandSelectorValue && this.element.querySelector(this.autoExpandSelectorValue)) {
this.element.open = true
}
}
}
@@ -13,3 +13,7 @@ export function isAndroid() {
export function isMobile() {
return isIos() || isAndroid()
}
export function isNative() {
return /Hotwire Native/.test(navigator.userAgent)
}
+6
View File
@@ -1,3 +1,8 @@
<%= tag.details class: "expandable-on-native",
data: {
controller: "expandable-on-native",
expandable_on_native_auto_expand_selector_value: "[data-filter-show=true]" } do %>
<%= tag.summary "Toggle filters", class: "btn btn--plain margin-block-end", data: { bridge__buttons_target: "button", bridge_title: "Toggle filters", bridge_icon_url: bridge_icon("funnel") } %>
<%= tag.aside \
class: class_names("filters margin-block-end", { "filters--expanded": user_filtering.expanded? }),
data: {
@@ -27,3 +32,4 @@
<% end %>
<%= render "filters/settings/manage", user_filtering: user_filtering, no_filtering_url: no_filtering_url %>
<% end %>
<% end %>