From d5d7d39ef4da588fd0ef4910cdb2572737981f59 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:33:51 +0100 Subject: [PATCH] feat: show the calendar's name on events when names next to colours is on --- components/calendar/__tests__/event-card.test.tsx | 11 +++++++++++ components/calendar/event-card.tsx | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/components/calendar/__tests__/event-card.test.tsx b/components/calendar/__tests__/event-card.test.tsx index e9e7b2616..11316f99e 100644 --- a/components/calendar/__tests__/event-card.test.tsx +++ b/components/calendar/__tests__/event-card.test.tsx @@ -120,6 +120,17 @@ describe('EventCard colour settings', () => { useSettingsStore.setState({ showColorNames: false, colorBlindPalette: false }); }); + it.each(['chip', 'span', 'block'] as const)('shows the calendar name on the %s with "Show names next to colours"', (variant) => { + useSettingsStore.setState({ showColorNames: true }); + render(); + expect(screen.getByText('Work')).toBeInTheDocument(); + }); + + it('shows only the colour without it', () => { + render(); + expect(screen.queryByText('Work')).not.toBeInTheDocument(); + }); + it("draws the event in the colour-blind-safe colour and keeps the calendar's own", () => { useSettingsStore.setState({ colorBlindPalette: true }); render(); diff --git a/components/calendar/event-card.tsx b/components/calendar/event-card.tsx index 7bd91f642..41c0fa219 100644 --- a/components/calendar/event-card.tsx +++ b/components/calendar/event-card.tsx @@ -124,9 +124,13 @@ export function EventCard({ event, calendar, variant, onClick, onMouseEnter, onM const timeFormat = useSettingsStore((state) => state.timeFormat); const showTimeInMonthView = useSettingsStore((state) => state.showTimeInMonthView); const tinted = useSettingsStore((state) => state.calendarTintedEvents); + // "Show names next to colours": the calendar's name on the event, so the + // colour is not the only way to tell Work from Personal (WCAG 1.4.1). + const showColorNames = useSettingsStore((state) => state.showColorNames); const timeFmt = timeFormat === "12h" ? "h:mm a" : "HH:mm"; const calendarName = calendar?.name || ""; + const visibleCalendarName = showColorNames && calendarName ? calendarName : null; const durationMinutes = parseDuration(event.duration); const endTime = getEventEndDate(event); const safeFormat = (d: Date, fmt: string) => { @@ -218,6 +222,9 @@ export function EventCard({ event, calendar, variant, onClick, onMouseEnter, onM {/* The whole width, aligned to the title's own start: a short English title in Arabic sat at the right, a cut one filled to the left. */} {event.title || t("events.no_title")} + {visibleCalendarName && ( + {visibleCalendarName} + )} ); } @@ -249,6 +256,9 @@ export function EventCard({ event, calendar, variant, onClick, onMouseEnter, onM {format(startDate, timeFmt)} )} {event.title || t("events.no_title")} + {visibleCalendarName && ( + {visibleCalendarName} + )} ); @@ -302,6 +312,9 @@ export function EventCard({ event, calendar, variant, onClick, onMouseEnter, onM {timeString} )} + {visibleCalendarName && ( +
{visibleCalendarName}
+ )} {getParticipantCount(event) > 0 && (