progressive enhancement for collection filter pills
Flex-wrap base (no JS needed, active pill always visible). JS hook switches to horizontal scroll with scroll-into-view when pills exceed 2.5 rows on mobile. Desktop always wraps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -206,19 +206,66 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Horizontal scroll fade hint for collection category pills (mobile only) */
|
||||
.collection-filter-scroll {
|
||||
/* Collection filter pills — flex-wrap base, JS-enhanced scroll on mobile */
|
||||
.collection-filter-pills {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.collection-filter-pill {
|
||||
display: inline-block;
|
||||
padding: 0.375rem 0.75rem;
|
||||
border-radius: 9999px;
|
||||
font-size: 0.75rem;
|
||||
white-space: nowrap;
|
||||
transition: opacity 0.15s;
|
||||
background-color: var(--t-surface-raised);
|
||||
color: var(--t-text-primary);
|
||||
|
||||
&.active {
|
||||
background-color: var(--t-accent);
|
||||
color: var(--t-text-on-accent);
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
/* When JS detects overflow, it adds this class to switch to horizontal scroll */
|
||||
.collection-filters.is-scrollable {
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
|
||||
-webkit-mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
|
||||
scrollbar-width: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
& .collection-filter-pills {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.collection-filter-pills {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.collection-filter-pill {
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* Desktop always wraps — no scroll needed */
|
||||
.collection-filters.is-scrollable {
|
||||
overflow-x: visible;
|
||||
mask-image: none;
|
||||
-webkit-mask-image: none;
|
||||
|
||||
& .collection-filter-pills {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user