Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { Priorities } from "@core/constants/core.constants";
import { gridColorByPriority } from "@web/common/styles/theme.util";
import { type Schema_GridEvent } from "@web/common/types/web.event.types";
import { describe, expect, it, mock } from "bun:test";
import "@testing-library/jest-dom";
Expand Down Expand Up @@ -89,6 +90,31 @@ describe("CalendarEventCard", () => {
expect(onEventMouseDown).not.toHaveBeenCalled();
});

it("keeps the timed selected state on the priority color", () => {
render(
<CalendarTimedEventCard
displayMode="saved"
event={createEvent({
priority: Priorities.WORK,
})}
isSelected={true}
motionMode="idle"
position={position}
/>,
);

const card = screen.getByRole("button", {
name: "Timed event: Planning block, 9 - 10 AM",
});

expect(card).toHaveClass("bg-(--event-bg)");
expect(card).not.toHaveClass("bg-event-selected");
expect(card.style.getPropertyValue("--event-bg")).toBe(
gridColorByPriority[Priorities.WORK],
);
expect(card.style.boxShadow).toContain("rgba(255,255,255,0.55)");
});

it("does not open pending timed events from the keyboard", () => {
const onEventKeyDown = mock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ const CalendarTimedEventCardBase = (
const baseColor = gridColorByPriority[priority];
const draftColor = darken(baseColor, 18);
const hoverColor = gridHoverColorByPriority[priority];
const selectedBoxShadow = "0 0 0 1px rgba(255,255,255,0.55)";

const bgColor = (() => {
if (isDraft) return draftColor;
if (isCommitAcknowledged) return hoverColor;
if (isResizing || isDragging) return brighten(baseColor);
return baseColor;
})();
const eventBoxShadow = isSelected
? boxShadow
? `${selectedBoxShadow}, ${boxShadow}`
: selectedBoxShadow
: boxShadow;

const hoverBgColor =
!isDraft && !isPlaceholder && !isResizing
Expand All @@ -139,7 +145,7 @@ const CalendarTimedEventCardBase = (
top: position.top,
width: position.width || 0,
zIndex: position.zIndex ?? ZIndex.LAYER_1,
boxShadow,
boxShadow: eventBoxShadow,
filter: isDraft
? "drop-shadow(2px 4px 4px black)"
: isInPast
Expand Down Expand Up @@ -201,9 +207,7 @@ const CalendarTimedEventCardBase = (
tabIndex={0}
className={cn(
"absolute min-h-2.5 select-none overflow-hidden rounded-xs pr-0.75 pl-1.25 transition-[background-color,filter] duration-[260ms] ease-[cubic-bezier(0.16,1,0.3,1)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary",
isSelected
? "bg-event-selected shadow-[0_4px_10px_-4px_#00000080]"
: "bg-(--event-bg) hover:bg-(--event-hover-bg)",
"bg-(--event-bg) hover:bg-(--event-hover-bg)",
{
"animate-someday-commit-acknowledge": isCommitAcknowledged,
},
Expand Down
1 change: 0 additions & 1 deletion packages/web/src/common/styles/theme-css.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const semanticColorTokens = [
"border-secondary",
"date-picker-outside-dark",
"date-picker-outside-light",
"event-selected",
"fg-primary",
"fg-primary-dark",
"gradient-accent-light-start",
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
--compass-color-border-primary: hsl(219 18 34 / 20%);
--compass-color-border-primary-dark: hsl(0 0 0 / 50.2%);
--compass-color-border-secondary: hsl(47 7 73);
--compass-color-event-selected: hsl(206 18 72);
--compass-color-date-picker-outside-dark: hsl(47 7 63);
--compass-color-date-picker-outside-light: hsl(222 12 17);
--compass-color-fg-primary: hsl(47 7 73);
Expand Down Expand Up @@ -63,7 +62,6 @@
--color-border-primary: var(--compass-color-border-primary);
--color-border-primary-dark: var(--compass-color-border-primary-dark);
--color-border-secondary: var(--compass-color-border-secondary);
--color-event-selected: var(--compass-color-event-selected);
--color-date-picker-outside-dark: var(
--compass-color-date-picker-outside-dark
);
Expand Down