refactor(marketplace): one filter surface per breakpoint (kill horiz+vert redundancy)

The desktop layout showed TWO filter zones — a horizontal browse strip
(Anbieter + Kategorie) AND a vertical refinement rail — which read as
redundant. Consolidate to one surface per breakpoint:

- Desktop: the persistent left rail is the ONLY filter surface and now carries
  the browse facets (source + category) at its top, alongside the refinements.
  The horizontal strip is hidden (lg:hidden).
- Mobile: unchanged — horizontal browse strip + advanced-filter drawer. The
  drawer stays refinements-only (browse lives in the strip), so no redundancy
  there either.

DRY: extract MarketplaceBrowseFacets as the single source of the seller/
category pill rendering, shared by the mobile strip (orientation=horizontal)
and the desktop rail (orientation=vertical) so the two can't drift. Filter
state SSOT (useMarketplaceListings) and option config (config/marketplace)
were already single-source; this removes the last rendering duplication.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mao NakamotoandClaude Opus 4.8 committed 2026-07-02 13:45:03 +02:00
1 parent 070edb0f41
commit 7d1ce407c1
4 files changed
+127 -83

No files matched your search

@@ -181,22 +181,25 @@ export default function MarketplacePage() {
</Select>
</div>
{/* Unified filter bar — source + category in one surface */}
<MarketplaceFilterBar
filters={filters}
resetOffset={resetOffset}
onOpenAdvanced={() => setMobileFiltersOpen(true)}
activeAdvancedCount={advancedFilterCount}
/>
{/* Mobile top strip — browse facets + advanced trigger. On desktop the
persistent rail is the single filter surface, so this is hidden. */}
<div className="lg:hidden">
<MarketplaceFilterBar
filters={filters}
resetOffset={resetOffset}
onOpenAdvanced={() => setMobileFiltersOpen(true)}
activeAdvancedCount={advancedFilterCount}
/>
</div>
{/* Two-column on desktop: persistent refinement rail + results.
Mobile keeps the single column + drawer (below). */}
<div className="lg:grid lg:grid-cols-[260px_minmax(0,1fr)] lg:gap-8 lg:items-start">
{/* Persistent refinement rail — desktop only. Reuses the exact same
MarketplaceFilterSidebar rendered inside the mobile drawer (DRY). */}
<aside className="hidden lg:block" aria-label={t('filters.advanced')}>
<aside className="hidden lg:block" aria-label={t('filters.label')}>
<div className="sticky top-20">
<MarketplaceFilterSidebar {...sharedSidebarProps} />
<MarketplaceFilterSidebar {...sharedSidebarProps} showBrowse />
</div>
</aside>
@@ -0,0 +1,91 @@
'use client'
import { useTranslations } from 'next-intl'
import {
MARKETPLACE_CATEGORY_VALUES,
MARKETPLACE_SELLER_TYPE,
} from '@/config/marketplace'
import { ORG } from '@/config/org'
import type { FiltersObj } from '@/components/marketplace/MarketplaceFilterSidebar'
import { FilterPill } from '@/components/marketplace/FilterPill'
interface MarketplaceBrowseFacetsProps {
filters: FiltersObj
resetOffset: () => void
/**
* `horizontal` — scroll rows for the mobile top strip.
* `vertical` — hairline-divided wrapped groups for the desktop filter rail.
*/
orientation: 'horizontal' | 'vertical'
}
/**
* The primary browse facets — seller source + category. Single source of the
* seller/category pill rendering, shared by the mobile top strip
* (`MarketplaceFilterBar`) and the desktop filter rail
* (`MarketplaceFilterSidebar`), so the two never drift.
*/
export function MarketplaceBrowseFacets({
filters,
resetOffset,
orientation,
}: MarketplaceBrowseFacetsProps) {
const t = useTranslations('marketplace')
const isVertical = orientation === 'vertical'
const sourceOptions = [
{ value: '', label: t('sellerTypes.all') },
{ value: MARKETPLACE_SELLER_TYPE.REVAMPIT, label: t('sellerTypes.revampit', { orgName: ORG.name }) },
{ value: MARKETPLACE_SELLER_TYPE.COMMUNITY, label: t('sellerTypes.community') },
] as const
// Vertical shares the rail's group treatment (hairline + wrap); horizontal is
// a compact scroll row for the mobile strip.
const blockClass = isVertical ? 'border-t border-subtle pt-5' : ''
const rowClass = isVertical
? 'flex flex-wrap gap-1.5'
: 'flex gap-2 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-thin'
const labelClass = 'mb-2 font-mono text-[10px] uppercase tracking-[0.16em] text-text-muted'
return (
<>
{/* Source */}
<div className={blockClass}>
<p className={labelClass}>{t('filters.sellerTypeTitle')}</p>
<div className={rowClass} role="group" aria-label={t('filters.sellerTypeAriaLabel')}>
{sourceOptions.map((opt) => (
<FilterPill
key={opt.value || 'all'}
active={filters.sellerType === opt.value}
onClick={() => { filters.setSellerType(opt.value); resetOffset() }}
>
{opt.label}
</FilterPill>
))}
</div>
</div>
{/* Category */}
<div className={blockClass}>
<p className={labelClass}>{t('filters.categoryTitle')}</p>
<div className={rowClass} role="group" aria-label={t('filters.categoryAriaLabel')}>
<FilterPill
active={!filters.category}
onClick={() => { filters.setCategory(''); resetOffset() }}
>
{t('categories.all')}
</FilterPill>
{MARKETPLACE_CATEGORY_VALUES.map((val) => (
<FilterPill
key={val}
active={filters.category === val}
onClick={() => { filters.setCategory(val); resetOffset() }}
>
{t(`categories.${val}` as never)}
</FilterPill>
))}
</div>
</div>
</>
)
}
@@ -1,13 +1,9 @@
'use client'
import { useTranslations } from 'next-intl'
import {
MARKETPLACE_CATEGORY_VALUES,
MARKETPLACE_SELLER_TYPE,
} from '@/config/marketplace'
import { ORG } from '@/config/org'
import type { FiltersObj } from '@/components/marketplace/MarketplaceFilterSidebar'
import { FilterPill } from '@/components/marketplace/FilterPill'
import { MarketplaceBrowseFacets } from '@/components/marketplace/MarketplaceBrowseFacets'
interface MarketplaceFilterBarProps {
filters: FiltersObj
@@ -17,8 +13,10 @@ interface MarketplaceFilterBarProps {
}
/**
* Unified marketplace filters — source + category as one horizontal control
* surface (no separate "Revamp-IT Geräte" island vs accordion sidebar).
* Mobile top strip — the primary browse facets (source + category) as a
* horizontal scan, plus a trigger into the advanced-filter drawer. On desktop
* the persistent filter rail carries these facets instead, so this strip is
* `lg:hidden` at the call site.
*/
export function MarketplaceFilterBar({
filters,
@@ -28,77 +26,12 @@ export function MarketplaceFilterBar({
}: MarketplaceFilterBarProps) {
const t = useTranslations('marketplace')
const sourceOptions = [
{ value: '', label: t('sellerTypes.all') },
{ value: MARKETPLACE_SELLER_TYPE.REVAMPIT, label: t('sellerTypes.revampit', { orgName: ORG.name }) },
{ value: MARKETPLACE_SELLER_TYPE.COMMUNITY, label: t('sellerTypes.community') },
] as const
return (
<div className="space-y-4 mb-6">
{/* Source — same row as browse, not a separate nav destination */}
<div>
<p className="mb-2 font-mono text-[10px] uppercase tracking-[0.16em] text-text-muted">
{t('filters.sellerTypeTitle')}
</p>
<div
className="flex flex-wrap gap-2"
role="group"
aria-label={t('filters.sellerTypeAriaLabel')}
>
{sourceOptions.map((opt) => (
<FilterPill
key={opt.value || 'all'}
active={filters.sellerType === opt.value}
onClick={() => {
filters.setSellerType(opt.value)
resetOffset()
}}
>
{opt.label}
</FilterPill>
))}
</div>
</div>
{/* Category — horizontal scan, no emoji wall */}
<div>
<p className="mb-2 font-mono text-[10px] uppercase tracking-[0.16em] text-text-muted">
{t('filters.categoryTitle')}
</p>
<div
className="flex gap-2 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-thin"
role="group"
aria-label={t('filters.categoryAriaLabel')}
>
<FilterPill
active={!filters.category}
onClick={() => {
filters.setCategory('')
resetOffset()
}}
>
{t('categories.all')}
</FilterPill>
{MARKETPLACE_CATEGORY_VALUES.map((val) => (
<FilterPill
key={val}
active={filters.category === val}
onClick={() => {
filters.setCategory(val)
resetOffset()
}}
>
{t(`categories.${val}` as never)}
</FilterPill>
))}
</div>
</div>
<MarketplaceBrowseFacets filters={filters} resetOffset={resetOffset} orientation="horizontal" />
{onOpenAdvanced && (
// Compact-viewport affordance only — on lg+ the persistent filter
// rail replaces this trigger, so hide it to avoid a redundant control.
<div className="flex items-center gap-3 pt-1 border-t border-subtle lg:hidden">
<div className="flex items-center gap-3 pt-1 border-t border-subtle">
<FilterPill active={activeAdvancedCount > 0} onClick={onOpenAdvanced}>
{t('filters.advanced')}
{activeAdvancedCount > 0 && (
@@ -13,6 +13,7 @@ import { useMarketplaceListings } from '@/hooks/useMarketplaceListings'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { FilterPill } from '@/components/marketplace/FilterPill'
import { MarketplaceBrowseFacets } from '@/components/marketplace/MarketplaceBrowseFacets'
export type FiltersObj = ReturnType<typeof useMarketplaceListings>['filters']
@@ -22,6 +23,12 @@ interface FilterSidebarProps {
resetOffset: () => void
clearFilters: () => void
hasActiveFilters: boolean
/**
* Include the primary browse facets (source + category) at the top. True for
* the desktop rail (the single filter surface); false in the mobile drawer,
* where the top strip already carries them.
*/
showBrowse?: boolean
}
/**
@@ -80,6 +87,7 @@ export function MarketplaceFilterSidebar({
resetOffset,
clearFilters,
hasActiveFilters,
showBrowse = false,
}: FilterSidebarProps) {
const t = useTranslations('marketplace')
const specFilters = getSpecFiltersForCategory(filters.category)
@@ -128,6 +136,15 @@ export function MarketplaceFilterSidebar({
</div>
<div className="mt-5 space-y-5">
{/* Primary browse facets — only in the desktop rail (single surface) */}
{showBrowse && (
<MarketplaceBrowseFacets
filters={filters}
resetOffset={resetOffset}
orientation="vertical"
/>
)}
{/* Condition */}
<PillGroup
label={t('filters.condition')}