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
18 changes: 4 additions & 14 deletions src/components/motion/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export function TabsTrigger({
}) {
const { value: current, setValue, layoutId, variant } = useTabs();
const active = current === value;
const usesDefaultIndicator = indicatorClassName === undefined;

if (variant === "underline") {
return (
Expand Down Expand Up @@ -142,9 +141,8 @@ export function TabsTrigger({
);
}

// The default max-contrast pill uses exclusion so labels invert exactly as
// the indicator passes beneath them. Custom indicators retain explicit text
// colors because their background may not be suitable for blending.
// Selected labels use the theme foreground directly. `mix-blend-exclusion` made white
// text turn cyan against the primary red and visibly flicker during hover transitions.
const radius = variant === "pill" ? "rounded-full" : "rounded-md";

return (
Expand All @@ -167,16 +165,8 @@ export function TabsTrigger({
onClick={() => setValue(value)}
className={cn(
"relative z-10 inline-flex items-center justify-center whitespace-nowrap bg-transparent px-3.5 py-1.5 text-sm font-medium outline-none",
usesDefaultIndicator
? "text-white mix-blend-exclusion transition-opacity"
: "transition-colors",
usesDefaultIndicator
? active
? "opacity-100"
: "opacity-70 hover:opacity-100"
: active
? "text-primary-foreground"
: "text-muted-foreground hover:text-foreground",
"transition-colors",
active ? "text-primary-foreground" : "text-muted-foreground hover:text-foreground",
radius,
className,
)}
Expand Down
65 changes: 64 additions & 1 deletion src/player/DiscordRPC.check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
*/
export {};

import { presenceDedupeKey, type DiscordPresenceData } from "./DiscordRPC";
import {
createPresenceSynchronizer,
presenceDedupeKey,
shouldClearPresence,
type DiscordPresenceData,
} from "./DiscordRPC";

function check(condition: boolean, message: string): void {
if (!condition) throw new Error(`FAILED: ${message}`);
Expand Down Expand Up @@ -39,4 +44,62 @@ check(
"play/pause change is not deduped away",
);

check(shouldClearPresence("paused", true, true), "paused presence clears when enabled");
check(!shouldClearPresence("paused", true, false), "paused presence remains when disabled");
check(shouldClearPresence("idle", false, false), "idle presence clears");
check(shouldClearPresence("loading", true, false), "loading presence clears");

const calls: string[] = [];
const synchronizer = createPresenceSynchronizer({
clear: async () => { calls.push("clear"); },
update: async () => { calls.push("update"); },
});
await synchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: true });
await synchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: true });
await synchronizer.sync({ data: { ...base, isPlaying: true }, status: "playing" }, { enabled: true, hideWhenPaused: true });
check(calls.join(",") === "clear,update", "paused clear is deduped and resume republishes");

const toggleCalls: string[] = [];
const toggleSynchronizer = createPresenceSynchronizer({
clear: async () => { toggleCalls.push("clear"); },
update: async () => { toggleCalls.push("update"); },
});
await toggleSynchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: false });
await toggleSynchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: true });
await toggleSynchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: false });
check(toggleCalls.join(",") === "update,clear,update", "changing the pause setting synchronizes immediately");

let releaseClear!: () => void;
const clearStarted = new Promise<void>((resolve) => { releaseClear = resolve; });
const raceCalls: string[] = [];
const racingSynchronizer = createPresenceSynchronizer({
clear: async () => {
raceCalls.push("clear");
await clearStarted;
},
update: async () => { raceCalls.push("update"); },
});
const pause = racingSynchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: true });
await Promise.resolve();
const resume = racingSynchronizer.sync({ data: { ...base, isPlaying: true }, status: "playing" }, { enabled: true, hideWhenPaused: true });
releaseClear();
await Promise.all([pause, resume]);
check(raceCalls.join(",") === "clear,update", "resume publishes after an in-flight pause clear");

let failedClear = true;
const retryCalls: string[] = [];
const retrySynchronizer = createPresenceSynchronizer({
clear: async () => {
retryCalls.push("clear");
if (failedClear) {
failedClear = false;
throw new Error("Discord unavailable");
}
},
update: async () => { retryCalls.push("update"); },
});
await retrySynchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: true });
await retrySynchronizer.sync({ data: base, status: "paused" }, { enabled: true, hideWhenPaused: true });
check(retryCalls.join(",") === "clear,clear", "failed clear is retried without wedging later syncs");

console.log("DiscordRPC.check.ts passed");
Loading
Loading