diff --git a/src/views/Chores/components/ChoreToolbarPrototype.jsx b/src/views/Chores/components/ChoreToolbarPrototype.jsx index f6a144c..6b97276 100644 --- a/src/views/Chores/components/ChoreToolbarPrototype.jsx +++ b/src/views/Chores/components/ChoreToolbarPrototype.jsx @@ -601,7 +601,11 @@ const ChoreToolbar = ({ {/* ── Row 2: pinned filters quick access ──────────────────────────────── */} - {!hasAnyActive && ( + {/* Stays visible even while a saved filter is active (it self-highlights) + so switching between pinned filters never requires clearing first. + Only steps aside for an ad-hoc/temp condition set, which has no + matching pinned identity to show. */} + {tempConditionCount === 0 && ( )} - {/* ── Row 3: active filter chips ──────────────────────────────────────── */} - {hasAnyActive && ( + {/* ── Row 3: active (temp/ad-hoc) filter chips ──────────────────────────── */} + {tempConditionCount > 0 && ( { - if (a.isPinned && !b.isPinned) return -1 - if (!a.isPinned && b.isPinned) return 1 - return (b.usageCount || 0) - (a.usageCount || 0) - }) - if (sortedFilters.filter(f => f.isPinned).length === 0) return null + const pinnedFilters = filters + .filter(f => f.isPinned) + .sort((a, b) => (b.usageCount || 0) - (a.usageCount || 0)) + + if (pinnedFilters.length === 0) return null return ( - - {sortedFilters.map(filter => { - const isActive = activeFilterId === filter.id - const hasWarning = !filter.isValid - const hasCustomColor = !!filter.color && !hasWarning - const textColor = hasCustomColor - ? getTextColorFromBackgroundColor(filter.color) - : undefined + + + {pinnedFilters.map(filter => { + const isActive = activeFilterId === filter.id + const hasWarning = !filter.isValid + const badgeColor = filter.color || 'var(--joy-palette-neutral-400)' + const badgeTextColor = filter.color + ? getTextColorFromBackgroundColor(filter.color) + : '#ffffff' + const displayCount = + filter.count > 99 ? '99+' : (filter.count ?? 0) - return ( - 0 ? ` (${filter.overdueCount} overdue)` : ''}` - } - placement='bottom' - > -
!hasWarning && onFilterClick(filter.id)}> + return ( + 0 ? ` (${filter.overdueCount} overdue)` : ''}` + } + placement='bottom' + > handleContextMenu(e, filter)} + onClick={() => !hasWarning && onFilterClick(filter.id)} sx={{ cursor: hasWarning ? 'not-allowed' : 'pointer', - transition: 'all 0.2s ease', - px: 1.0, - py: 0.5, + transition: 'background-color 0.15s ease, color 0.15s ease', + px: 1, height: 32, - display: 'flex', - alignItems: 'center', - - opacity: hasWarning ? 0.7 : isActive ? 1 : 0.85, - ...(hasCustomColor && { - backgroundColor: `${filter.color} !important`, - color: `${textColor} !important`, - '&:hover': { - backgroundColor: `${filter.color} !important`, - filter: 'brightness(0.95)', - opacity: 1, - }, - }), + flexShrink: 0, + fontWeight: isActive ? 600 : 500, + '&:hover': { + backgroundColor: isActive ? undefined : 'neutral.softHoverBg', + }, }} startDecorator={ - - {isActive ? ( - - ) : ( - - {filter.count} - - )} - + !hasWarning && ( + + {isActive ? ( + + ) : ( + + {displayCount} + + )} + + ) + } + endDecorator={ + { + e.stopPropagation() + handleContextMenu(e, filter) + }} + sx={{ + '--IconButton-size': '20px', + ml: 0.25, + opacity: 0.6, + '&:hover': { opacity: 1, backgroundColor: 'transparent' }, + }} + > + + } - // endDecorator={ - // - // {hasWarning && } - // {!hasWarning && filter.overdueCount > 0 && ( - // - // {filter.overdueCount} - // - // )} - // - // } > {filter.name} -
-
- ) - })} + + ) + })} - { + e.preventDefault() + e.stopPropagation() + navigate('/filters') + }} + > + + +
+ + {/* Fade hint that more chips are scrollable off the trailing edge */} + { - e.preventDefault() - e.stopPropagation() - navigate('/filters') - }} - > - - + />