Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import { SidebarHeaderIconButton } from "./SidebarThreadHeader";
import {
changedThreadListFilters,
sidebarFilterIconClass,
EMPTY_THREAD_LIST_FILTER_BUCKETS,
inboxMenuOrder,
type olderSettledFilterCounts,
Expand Down Expand Up @@ -91,7 +92,7 @@ export function SidebarThreadFilterMenu<T extends CountedThread>({
return (
<Menu>
<MenuTrigger render={<SidebarHeaderIconButton label={label} />}>
<SlidersHorizontalIcon className={cn("size-4", summary.length > 0 && "text-primary")} />
<SlidersHorizontalIcon className={sidebarFilterIconClass(summary.length > 0)} />
</MenuTrigger>
<MenuPopup align="end" className="w-[min(19rem,var(--available-width))]">
<SidebarThreadFilterOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { describe, expect, it } from "vite-plus/test";

import {
changedThreadListFilters,
sidebarFilterIconClass,
inboxMenuOrder,
matchesThreadListFilter,
olderSettledFilterCounts,
Expand Down Expand Up @@ -96,6 +97,13 @@ describe("thread list filter", () => {
).toBe(true);
});

it("tints a changed filter with an important primary color", () => {
// SidebarMenuButton's `[&>svg]:text-[var(--sidebar-icon-color)]` beats a
// plain text-primary on the icon, so the default class must not claim one.
expect(sidebarFilterIconClass(false)).toBe("size-4");
expect(sidebarFilterIconClass(true)).toBe("size-4 text-primary!");
});

it("reports only sections that differ from this device's default", () => {
const environments = [laptop, crown];
const unchanged = threadListFilterOf({ founderInboxOwner: "jeff" });
Expand Down
11 changes: 11 additions & 0 deletions apps/web/src/components/sidebar/threadListFilter.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ export function toggleHiddenEnvironment(
const sameMembers = <A>(left: ReadonlyArray<A>, right: ReadonlyArray<A>) =>
left.length === right.length && left.every((value) => right.includes(value));

/**
* Class for the filter sliders icon.
*
* `SidebarMenuButton` sets `[&>svg]:text-[var(--sidebar-icon-color)]` on the
* button, and that rule beats a plain `text-primary` on the icon, at rest and
* on hover. The important utility is what makes a non-default filter visible.
*/
export function sidebarFilterIconClass(changed: boolean): string {
return changed ? "size-4 text-primary!" : "size-4";
}

/** Filter sections that differ from this device's default, ignoring removed environments. */
export function changedThreadListFilters(
filter: ThreadListFilter,
Expand Down
Loading