Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(calendar): Event details ui changes (#5460)

dev-rba3787929c202
diff --git a/apps/web/src/features/calendar/CalendarPeriodSelector.tsx b/apps/web/src/features/calendar/CalendarPeriodSelector.tsx
index 1e684b999d..00a46ae170 100644
--- a/apps/web/src/features/calendar/CalendarPeriodSelector.tsx
+++ b/apps/web/src/features/calendar/CalendarPeriodSelector.tsx
@@ -80,7 +80,8 @@ export function CalendarPeriodSelector() {
<Dropdown.Trigger
depth={2}
aria-label="Choose calendar view"
- class="h-7 shrink-0 gap-1 rounded-lg border-edge-muted bg-panel px-2 text-xs font-medium text-ink"
+ size="sm"
+ class="shrink-0 gap-1 rounded-lg border-edge-muted bg-panel text-xs font-medium text-ink"
>
{CALENDAR_VIEWS.find((view) => view.value === activeView())?.label ??
'Week'}
diff --git a/apps/web/src/features/calendar/CalendarSettingsDropdown.tsx b/apps/web/src/features/calendar/CalendarSettingsDropdown.tsx
index 41dac8e108..7a8ae275c7 100644
--- a/apps/web/src/features/calendar/CalendarSettingsDropdown.tsx
+++ b/apps/web/src/features/calendar/CalendarSettingsDropdown.tsx
@@ -70,7 +70,7 @@ export function CalendarSettingsDropdown() {
<Dropdown.Trigger
variant="ghost"
size="icon-sm"
- class="h-7 w-7 shrink-0 rounded-lg"
+ class="shrink-0 rounded-lg"
label="Calendar settings"
>
<GearIcon class="size-3.5" />
diff --git a/apps/web/src/features/calendar/CalendarSidePanelSections.tsx b/apps/web/src/features/calendar/CalendarSidePanelSections.tsx
index 7c9b9eba34..d5af69f858 100644
--- a/apps/web/src/features/calendar/CalendarSidePanelSections.tsx
+++ b/apps/web/src/features/calendar/CalendarSidePanelSections.tsx
@@ -1,62 +1,10 @@
import { SidePanel, useSidePanel } from '@components/app/side-panel/SidePanel';
-import CloseIcon from '@phosphor/x.svg';
-import { Button, Calendar as MiniCalendar } from '@ui';
+import { Calendar as MiniCalendar } from '@ui';
import { createEffect, createMemo, createSignal, on, Show } from 'solid-js';
import { useCalendarView } from './CalendarViewContext';
import { CalendarControls } from './events/CalendarControls';
-import { EventDetails } from './events/EventDetails';
import { useFullCalendar } from './fullcalendar-solid';
-function CalendarEventSidePanelSection() {
- const calendarView = useCalendarView();
- const sidePanel = useSidePanel();
-
- createEffect(
- on(
- () => [calendarView.selectedEvent()?.id, sidePanel?.isNarrow()] as const,
- ([eventId, isNarrow]) => {
- if (!eventId || !sidePanel || isNarrow) return;
-
- sidePanel.setIsOpen(true);
- if (!sidePanel.openSectionIds().includes('calendar-event')) {
- sidePanel.setOpenSectionIds([
- ...sidePanel.openSectionIds(),
- 'calendar-event',
- ]);
- }
- }
- )
- );
-
- return (
- <Show when={calendarView.selectedEvent()}>
- {(event) => (
- <SidePanel.Section
- id="calendar-event"
- title="Event"
- order={0}
- defaultOpen
- actions={
- <Button
- variant="ghost"
- size="icon-sm"
- label="Close event details"
- onClick={calendarView.closeEventDetails}
- >
- <CloseIcon class="size-3.5" />
- </Button>
- }
- >
- <EventDetails
- event={event()}
- timeFormat={calendarView.displaySettings.timeFormat}
- />
- </SidePanel.Section>
- )}
- </Show>
- );
-}
-
function CalendarMiniCalendarSidePanelSection() {
const calendarView = useCalendarView();
const calendar = useFullCalendar();
@@ -143,7 +91,6 @@ export function CalendarSidePanelSections() {
return (
<Show when={!sidePanel?.isNarrow()}>
- <CalendarEventSidePanelSection />
<CalendarMiniCalendarSidePanelSection />
<CalendarSourcesSidePanelSection />
</Show>
diff --git a/apps/web/src/features/calendar/CalendarViewContext.tsx b/apps/web/src/features/calendar/CalendarViewContext.tsx
index 7fcd1f704f..cca2ae7a94 100644
--- a/apps/web/src/features/calendar/CalendarViewContext.tsx
+++ b/apps/web/src/features/calendar/CalendarViewContext.tsx
@@ -6,7 +6,7 @@ import {
useCalendarOccurrencesQuery,
} from '@queries/calendar/occurrences';
import { CalendarSyncStatus } from '@service-storage/generated/schemas/calendarSyncStatus';
-import { createEffect, createMemo, createSignal, on } from 'solid-js';
+import { batch, createEffect, createMemo, createSignal, on } from 'solid-js';
import { createStore } from 'solid-js/store';
import { isCalendarRangeSupported } from './calendar-supported-range';
import {
@@ -86,8 +86,10 @@ export const [CalendarViewContextProvider, useCalendarView] =
occurrencesQuery.data?.syncStatus === CalendarSyncStatus.syncing;
const closeEventDetails = () => {
- setEventState('selectedEventId', undefined);
- setSelectedEventAnchor(undefined);
+ batch(() => {
+ setEventState('selectedEventId', undefined);
+ setSelectedEventAnchor(undefined);
+ });
};
createEffect(
@@ -138,8 +140,10 @@ export const [CalendarViewContextProvider, useCalendarView] =
};
const selectEvent = (eventId: string, anchor: HTMLElement) => {
- setEventState('selectedEventId', eventId);
- setSelectedEventAnchor(anchor);
+ batch(() => {
+ setEventState('selectedEventId', eventId);
+ setSelectedEventAnchor(anchor);
+ });
};
return {
diff --git a/apps/web/src/features/calendar/calendar-view.tsx b/apps/web/src/features/calendar/calendar-view.tsx
index 0db4251973..e1adaf5878 100644
--- a/apps/web/src/features/calendar/calendar-view.tsx
+++ b/apps/web/src/features/calendar/calendar-view.tsx
@@ -1,10 +1,11 @@
-import { SidePanel, useSidePanel } from '@components/app/side-panel/SidePanel';
+import { SidePanel } from '@components/app/side-panel/SidePanel';
import { HeaderIsland } from '@components/app/split-layout/components/HeaderIsland';
import {
SplitHeaderLeft,
SplitHeaderRight,
} from '@components/app/split-layout/components/SplitHeader';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';
import type { DatesSetArg } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
@@ -22,6 +23,7 @@ import {
onMount,
Show,
} from 'solid-js';
+import { Portal } from 'solid-js/web';
import { CalendarDataStatus } from './CalendarDataStatus';
import { CalendarPeriodSelector } from './CalendarPeriodSelector';
import { CalendarRangeUnavailableBanner } from './CalendarRangeUnavailableBanner';
@@ -32,7 +34,7 @@ import {
useCalendarView,
} from './CalendarViewContext';
import { CalendarEventContent } from './events/EventContent';
-import { EventDetailsPopover } from './events/EventDetailsPopover';
+import { SelectedEventDetailsPopover } from './events/EventDetailsPopover';
import type { CalendarTimeFormat } from './events/types';
import { FullCalendar, useFullCalendar } from './fullcalendar-solid';
import {
@@ -92,35 +94,76 @@ function getLocalScrollTime() {
return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:00`;
}
-function useCalendarScrollFades(
- calendarElement: Accessor<HTMLElement | undefined>
-) {
- createEffect(
- on(calendarElement, (element) => {
- if (!element) return;
+interface CalendarScrollTarget {
+ scrollElement: HTMLElement;
+ fadeContainer: HTMLElement;
+}
- const handleCalendarScroll = (event: Event) => {
- const scroller = event.target;
- if (!(scroller instanceof HTMLElement)) return;
+function CalendarScrollIndicators(props: {
+ calendarElement: Accessor<HTMLElement | undefined>;
+}) {
+ const [target, setTarget] = createSignal<CalendarScrollTarget>();
- const harness = scroller.closest<HTMLElement>(
- '.fc-scroller-harness-liquid'
- );
- if (!harness || scroller.parentElement !== harness) return;
+ createEffect(
+ on(props.calendarElement, (element) => {
+ if (!element) {
+ setTarget(undefined);
+ return;
+ }
- harness.toggleAttribute(
- 'data-scrolled-from-top',
- scroller.scrollTop > 1
+ let updateFrame: number | undefined;
+ const updateScrollElements = () => {
+ const scrollElement = element.querySelector<HTMLElement>(
+ '.fc-timegrid .fc-scroller-harness-liquid > .fc-scroller'
);
+ const fadeContainer = scrollElement?.parentElement;
+ setTarget((current) => {
+ if (!scrollElement || !fadeContainer) return undefined;
+ return current?.scrollElement === scrollElement &&
+ current.fadeContainer === fadeContainer
+ ? current
+ : { scrollElement, fadeContainer };
+ });
+ };
+ const scheduleScrollElementUpdate = () => {
+ if (updateFrame !== undefined) cancelAnimationFrame(updateFrame);
+ updateFrame = requestAnimationFrame(() => {
+ updateFrame = undefined;
+ updateScrollElements();
+ });
};
- element.addEventListener('scroll', handleCalendarScroll, true);
+ const mutationObserver = new MutationObserver(
+ scheduleScrollElementUpdate
+ );
+ mutationObserver.observe(element, { childList: true, subtree: true });
+ scheduleScrollElementUpdate();
onCleanup(() => {
- element.removeEventListener('scroll', handleCalendarScroll, true);
+ mutationObserver.disconnect();
+ if (updateFrame !== undefined) cancelAnimationFrame(updateFrame);
});
})
);
+
+ return (
+ <Show keyed when={target()}>
+ {(scrollTarget) => (
+ <Portal
+ mount={scrollTarget.fadeContainer}
+ ref={(container) => {
+ container.style.display = 'contents';
+ }}
+ >
+ <ScrollIndicators
+ scrollRef={() => scrollTarget.scrollElement}
+ appearance="gradient"
+ class="h-6"
+ />
+ </Portal>
+ )}
+ </Show>
+ );
}
function ResponsiveCalendarHost() {
@@ -129,7 +172,6 @@ function ResponsiveCalendarHost() {
const [element, setElement] = createSignal<HTMLDivElement>();
useCalendarTimeGridHoverIndicator(element);
- useCalendarScrollFades(element);
createEffect(
on(
@@ -178,6 +220,7 @@ function ResponsiveCalendarHost() {
}}
class="calendar-view-host min-w-0 min-h-0 flex-1 overflow-hidden rounded-xl"
/>
+ <CalendarScrollIndicators calendarElement={element} />
<CalendarDataStatus />
</div>
</div>
@@ -353,13 +396,11 @@ function createLocalToday() {
function CalendarWorkspace() {
const panel = useSplitPanelOrThrow();
- const sidePanel = useSidePanel();
const calendar = useFullCalendar();
const calendarView = useCalendarView();
const initialDate = new Date();
const today = createLocalToday();
- const isNarrow = () => sidePanel?.isNarrow() ?? false;
const currentDate = createMemo(
() => calendar.dateInfo()?.view.calendar.getDate() ?? initialDate
);
@@ -390,7 +431,7 @@ function CalendarWorkspace() {
<Button
variant="active"
size="sm"
- class="h-7 rounded-lg px-3"
+ class="rounded-lg px-3"
depth={2}
label="Go to today"
onClick={() => calendar.api()?.today()}
@@ -410,7 +451,7 @@ function CalendarWorkspace() {
<Button
variant="ghost"
size="icon-sm"
- class="size-7 rounded-lg [&_svg]:size-4!"
+ class="rounded-lg"
label="Previous period"
onClick={() => calendar.api()?.prev()}
>
@@ -419,7 +460,7 @@ function CalendarWorkspace() {
<Button
variant="ghost"
size="icon-sm"
- class="size-7 rounded-lg [&_svg]:size-4!"
+ class="rounded-lg"
label="Next period"
onClick={() => calendar.api()?.next()}
>
@@ -433,19 +474,12 @@ function CalendarWorkspace() {
<CalendarSidePanelSections />
- <Show when={isNarrow() ? calendarView.selectedEvent() : undefined}>
- {(event) => (
- <EventDetailsPopover
- anchor={calendarView.selectedEventAnchor()}
- event={event()}
- open={calendarView.selectedEventAnchor() !== undefined}
- timeFormat={calendarView.displaySettings.timeFormat}
- onOpenChange={(open) => {
- if (!open) calendarView.closeEventDetails();
- }}
- />
- )}
- </Show>
+ <SelectedEventDetailsPopover
+ anchor={calendarView.selectedEventAnchor}
+ event={calendarView.selectedEvent}
+ timeFormat={() => calendarView.displaySettings.timeFormat}
+ onClose={calendarView.closeEventDetails}
+ />
<main class="calendar-view flex size-full min-h-0">
<div class="calendar-view-content flex min-w-0 min-h-0 flex-1 flex-col">
diff --git a/apps/web/src/features/calendar/calendar.css b/apps/web/src/features/calendar/calendar.css
index 8ab6745d71..9887d21ef6 100644
--- a/apps/web/src/features/calendar/calendar.css
+++ b/apps/web/src/features/calendar/calendar.css
@@ -345,44 +345,6 @@
border-top-color: transparent;
}
-.calendar-view .fc .fc-timegrid .fc-scroller-harness-liquid::before,
-.calendar-view .fc .fc-timegrid .fc-scroller-harness-liquid::after {
- position: absolute;
- right: 0;
- left: 0;
- z-index: 5;
- height: 1.5rem;
- pointer-events: none;
- content: "";
-}
-
-.calendar-view .fc .fc-timegrid .fc-scroller-harness-liquid::before {
- top: 0;
- background: linear-gradient(
- to bottom,
- color-mix(in oklch, var(--color-surface) 75%, transparent),
- transparent
- );
- opacity: 0;
- transition: opacity 150ms ease-out;
-}
-
-.calendar-view
- .fc
- .fc-timegrid
- .fc-scroller-harness-liquid[data-scrolled-from-top]::before {
- opacity: 1;
-}
-
-.calendar-view .fc .fc-timegrid .fc-scroller-harness-liquid::after {
- bottom: 0;
- background: linear-gradient(
- to top,
- color-mix(in oklch, var(--color-surface) 75%, transparent),
- transparent
- );
-}
-
.calendar-view .fc .fc-timegrid-axis-cushion,
.calendar-view .fc .fc-timegrid-slot-label-cushion {
color: var(--color-ink-extra-muted);
@@ -477,7 +439,7 @@
overflow: visible;
border: 0;
background: transparent;
- transform: translateY(-50%);
+ transform: translateY(calc(-50% + 0.5px));
}
.calendar-view .fc .fc-timeGridWeek-view .fc-timegrid-axis {
@@ -523,7 +485,7 @@
position: absolute;
top: 0;
right: 100%;
- transform: translateY(-50%);
+ transform: translateY(calc(-50% + 0.5px));
}
.calendar-view
diff --git a/apps/web/src/features/calendar/events/EventContent.test.tsx b/apps/web/src/features/calendar/events/EventContent.test.tsx
index dda9bacec6..a205ab5ef9 100644
--- a/apps/web/src/features/calendar/events/EventContent.test.tsx
+++ b/apps/web/src/features/calendar/events/EventContent.test.tsx
@@ -20,6 +20,7 @@ function calendarEvent(durationMinutes: number): CalendarEvent {
eventId: 'event-1',
occurrenceKey: 'occurrence-1',
isReadOnly: false,
+ isCancelled: false,
attendees: [],
recurrenceLines: [],
title: 'Planning',
diff --git a/apps/web/src/features/calendar/events/EventDetails.tsx b/apps/web/src/features/calendar/events/EventDetails.tsx
index 33428eec35..7be950a0f2 100644
--- a/apps/web/src/features/calendar/events/EventDetails.tsx
+++ b/apps/web/src/features/calendar/events/EventDetails.tsx
@@ -1,19 +1,30 @@
+import { UserIcon, type UserIconProps } from '@core/component/UserIcon';
+import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';
+import { emailToMacroId, useDisplayName } from '@core/user';
+import { plural } from '@core/util/string';
import { openExternalUrl } from '@core/util/url';
-import CalendarIcon from '@phosphor/calendar-blank.svg';
-import ClockIcon from '@phosphor/clock.svg';
+import { Collapsible } from '@kobalte/core/collapsible';
+import ArrowSquareOutIcon from '@phosphor/arrow-square-out.svg';
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import CheckIcon from '@phosphor/check.svg';
import GlobeIcon from '@phosphor/globe.svg';
import MapPinIcon from '@phosphor/map-pin.svg';
-import RepeatIcon from '@phosphor/repeat.svg';
-import UserIcon from '@phosphor/user.svg';
+import QuestionMarkIcon from '@phosphor/question-mark.svg';
+import TextAlignLeftIcon from '@phosphor/text-align-left.svg';
+import PersonIcon from '@phosphor/user.svg';
import UsersIcon from '@phosphor/users.svg';
import VideoCameraIcon from '@phosphor/video-camera.svg';
+import XIcon from '@phosphor/x.svg';
import type { AttendeeResponseStatus } from '@service-storage/generated/schemas/attendeeResponseStatus';
+import type { CalendarAttendee } from '@service-storage/generated/schemas/calendarAttendee';
import { Button } from '@ui';
-import { createMemo, For, Show } from 'solid-js';
+import { type Accessor, createMemo, createSignal, For, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
import {
CALENDAR_TIME_FORMAT_OPTIONS,
formatCalendarTime,
} from '../time-format';
+import { formatRecurrenceDescription } from './recurrence-description';
import type { CalendarEvent, CalendarTimeFormat } from './types';
const formatDate = new Intl.DateTimeFormat(undefined, {
@@ -25,14 +36,161 @@ const formatShortDate = new Intl.DateTimeFormat(undefined, {
month: 'short',
day: 'numeric',
});
-const isDateOnly = (value: string) => /^\d{4}-\d{2}-\d{2}$/.test(value);
+const DATE_ONLY_REGEX = /^\d{4}-\d{2}-\d{2}$/;
+const isDateOnly = (value: string) => DATE_ONLY_REGEX.test(value);
const ATTENDEE_RESPONSE = {
- accepted: { label: 'Accepted', class: 'text-success' },
- declined: { label: 'Declined', class: 'text-failure' },
- tentative: { label: 'Tentative', class: 'text-warning' },
- needs_action: { label: 'No response', class: 'text-ink-extra-muted' },
-} satisfies Record<AttendeeResponseStatus, { label: string; class: string }>;
+ accepted: {
+ label: 'Accepted',
+ class: 'text-success',
+ icon: CheckIcon,
+ },
+ declined: {
+ label: 'Declined',
+ class: 'text-failure',
+ icon: XIcon,
+ },
+ tentative: {
+ label: 'Tentative',
+ class: 'text-warning',
+ icon: QuestionMarkIcon,
+ },
+} satisfies Record<
+ Exclude<AttendeeResponseStatus, 'needs_action'>,
+ { label: string; class: string; icon: typeof CheckIcon }
+>;
+
+function isUsableDisplayName(value: string, email: string) {
+ return value !== '' && value !== email && !value.includes('@');
+}
+
+interface ResolvedCalendarAttendee {
+ attendee: CalendarAttendee;
+ displayName: Accessor<string>;
+ iconProps: UserIconProps;
+}
+
+const compareAttendeeNames = new Intl.Collator(undefined, {
+ sensitivity: 'base',
+}).compare;
+
+function resolveCalendarAttendee(
+ attendee: CalendarAttendee
+): ResolvedCalendarAttendee {
+ const macroId = emailToMacroId(attendee.email);
+ const [macroDisplayName] = useDisplayName(macroId);
+ const iconProps: UserIconProps = macroId
+ ? { id: macroId }
+ : { email: attendee.email };
+ const displayName = () => {
+ const macroName = macroDisplayName().trim();
+ return isUsableDisplayName(macroName, attendee.email)
+ ? macroName
+ : attendee.email;
+ };
+
+ return { attendee, displayName, iconProps };
+}
+
+function CalendarAttendeeItem(props: { item: ResolvedCalendarAttendee }) {
+ const response =
+ props.item.attendee.responseStatus === 'needs_action'
+ ? undefined
+ : ATTENDEE_RESPONSE[props.item.attendee.responseStatus];
+ const hasSecondaryLabel =
+ props.item.attendee.isOrganizer || props.item.attendee.isOptional;
+
+ return (
+ <div class="flex min-w-0 items-center gap-3">
+ <UserIcon
+ {...props.item.iconProps}
+ isDeleted={false}
+ size="md"
+ suppressClick
+ showTooltip={false}
+ />
+ <div class="min-w-0 flex-1">
+ <div class="min-w-0">
+ <span class="block select-text truncate text-ink-muted">
+ {props.item.displayName()}
+ <Show when={props.item.attendee.isSelf}> (you)</Show>
+ </span>
+ </div>
+ <Show when={hasSecondaryLabel}>
+ <div class="flex gap-1 text-xxs text-ink-extra-muted">
+ <Show when={props.item.attendee.isOrganizer}>
+ <span>Organizer</span>
+ </Show>
+ <Show when={props.item.attendee.isOptional}>
+ <span>Optional</span>
+ </Show>
+ </div>
+ </Show>
+ <Show when={props.item.attendee.comment}>
+ {(comment) => (
+ <div class="line-clamp-2 select-text text-xxs italic text-ink-extra-muted">
+ {comment()}
+ </div>
+ )}
+ </Show>
+ </div>
+ <Show when={response}>
+ {(attendeeResponse) => (
+ <span
+ role="img"
+ aria-label={attendeeResponse().label}
+ title={attendeeResponse().label}
+ class={`shrink-0 ${attendeeResponse().class}`}
+ >
+ <Dynamic
+ component={attendeeResponse().icon}
+ aria-hidden="true"
+ class="size-3.5"
+ />
+ </span>
+ )}
+ </Show>
+ </div>
+ );
+}
+
+function CalendarAttendeeList(props: { attendees: CalendarAttendee[] }) {
+ const attendees = props.attendees.map(resolveCalendarAttendee);
+ const sortedAttendees = createMemo(() =>
+ attendees
+ .map((item) => ({ item, name: item.displayName() }))
+ .toSorted(
+ (first, second) =>
+ compareAttendeeNames(first.name, second.name) ||
+ compareAttendeeNames(
+ first.item.attendee.email,
+ second.item.attendee.email
+ )
+ )
+ .map(({ item }) => item)
+ );
+
+ return (
+ <For each={sortedAttendees()}>
+ {(item) => <CalendarAttendeeItem item={item} />}
+ </For>
+ );
+}
+
+function ScrollableAttendeeList(props: { attendees: CalendarAttendee[] }) {
+ const [scrollContainer, setScrollContainer] = createSignal<HTMLDivElement>();
+
+ return (
+ <div class="relative min-w-0 flex-1">
+ <div ref={setScrollContainer} class="max-h-40 overflow-y-auto pr-4">
+ <div class="flex flex-col gap-3">
+ <CalendarAttendeeList attendees={props.attendees} />
+ </div>
+ </div>
+ <ScrollIndicators scrollRef={scrollContainer} appearance="gradient" />
+ </div>
+ );
+}
function parseCalendarDate(value: string) {
if (!isDateOnly(value)) return new Date(value);
@@ -88,9 +246,7 @@ function findOrganizer(event: CalendarEvent) {
organizerAttendee?.displayName ??
event.organizerEmail ??
organizerAttendee?.email;
- const email = event.organizerEmail ?? organizerAttendee?.email;
-
- return name ? { name, email } : undefined;
+ return name;
}
function formatOriginalTimeZone(
@@ -123,190 +279,143 @@ export function EventDetails(props: {
const originalTimeZone = createMemo(() =>
formatOriginalTimeZone(props.event, props.timeFormat)
);
- const isRecurring = () =>
- props.event.recurrenceLines.length > 0 ||
- props.event.recurrenceId !== undefined;
+ const recurrenceDescription = createMemo(() => {
+ const description = formatRecurrenceDescription(
+ props.event.recurrenceLines
+ );
+ if (description) return description;
+
+ return props.event.recurrenceLines.length > 0 ||
+ props.event.recurrenceId !== undefined
+ ? 'Recurring event'
+ : undefined;
+ });
return (
<div class="min-w-0 p-1 text-ink">
- <div class="flex items-start gap-2">
- <div
+ <div class="flex items-start gap-3">
+ <span
aria-hidden="true"
- class="mt-1 size-2.5 shrink-0 rounded-sm"
- style={{ 'background-color': props.event.calendar.color }}
- />
+ class="mt-0.5 flex size-4 shrink-0 items-center justify-center"
+ >
+ <span
+ class="size-2.5 rounded-sm"
+ style={{ 'background-color': props.event.calendar.color }}
+ />
+ </span>
<div class="min-w-0 flex-1">
- <div class="text-sm font-semibold leading-snug text-ink">
- {props.event.title}
- </div>
-
- <Show when={conferenceUrl()}>
- {(url) => (
- <Button
- fullWidth
- variant="cta"
- size="sm"
- class="mt-3 h-7 rounded-lg"
- label="Join meeting"
- onClick={() => openExternalUrl(url())}
- >
- <VideoCameraIcon class="size-3.5" />
- Join meeting
- </Button>
- )}
- </Show>
-
- <div class="mt-3 flex flex-col gap-2 text-xs text-ink-muted">
- <div class="flex items-start gap-2">
- <Show
- when={props.event.allDay}
- fallback={
- <ClockIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
- }
- >
- <CalendarIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
- </Show>
- <span>{formatEventSchedule(props.event, props.timeFormat)}</span>
+ <div class="flex flex-col gap-1 pr-8">
+ <div class="select-text text-base font-semibold leading-snug text-ink">
+ {props.event.title}
</div>
+ <div class="select-text text-xs text-ink-muted">
+ {formatEventSchedule(props.event, props.timeFormat)}
+ </div>
+ <Show when={recurrenceDescription()}>
+ {(description) => (
+ <div class="select-text text-xs text-ink-extra-muted">
+ {description()}
+ </div>
+ )}
+ </Show>
+ </div>
+ <div class="mt-5 flex flex-col gap-3 text-xs text-ink-muted">
+ <Show when={conferenceUrl()}>
+ {(url) => (
+ <div class="-ml-7 flex items-center gap-3">
+ <VideoCameraIcon class="size-4 shrink-0 text-ink-extra-muted" />
+ <Button
+ fullWidth
+ variant="cta"
+ size="sm"
+ class="h-8 rounded-lg"
+ label="Join meeting"
+ onClick={() => openExternalUrl(url())}
+ >
+ Join meeting
+ <ArrowSquareOutIcon class="size-3.5" />
+ </Button>
+ </div>
+ )}
+ </Show>
<Show when={originalTimeZone()}>
{(timeZone) => (
- <div class="flex items-start gap-2">
- <GlobeIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
- <span>{timeZone()}</span>
+ <div class="-ml-7 flex items-start gap-3">
+ <GlobeIcon class="mt-0.5 size-4 shrink-0 text-ink-extra-muted" />
+ <span class="select-text">{timeZone()}</span>
</div>
)}
</Show>
- <Show when={isRecurring()}>
- <div class="flex items-start gap-2">
- <RepeatIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
- <span>Recurring event</span>
- </div>
- </Show>
-
<Show when={props.event.location}>
{(location) => (
- <div class="flex items-start gap-2">
- <MapPinIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
- <span>{location()}</span>
+ <div class="-ml-7 flex items-start gap-3">
+ <MapPinIcon class="mt-0.5 size-4 shrink-0 text-ink-extra-muted" />
+ <span class="select-text">{location()}</span>
+ </div>
+ )}
+ </Show>
+
+ <Show when={props.event.description}>
+ {(description) => (
+ <div class="-ml-7 flex items-start gap-3">
+ <TextAlignLeftIcon class="mt-0.5 size-4 shrink-0 text-ink-extra-muted" />
+ <p class="select-text leading-relaxed text-ink-muted">
+ {description()}
+ </p>
</div>
)}
</Show>
<Show when={organizer()}>
{(eventOrganizer) => (
- <div class="flex items-start gap-2">
- <UserIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
+ <div class="-ml-7 flex items-start gap-3">
+ <PersonIcon class="mt-0.5 size-4 shrink-0 text-ink-extra-muted" />
<div class="min-w-0">
- <div class="text-[0.6875rem] text-ink-extra-muted">
- Organizer
- </div>
- <div class="truncate text-ink-muted">
- {eventOrganizer().name}
+ <div class="text-xxs text-ink-extra-muted">Organizer</div>
+ <div class="select-text truncate text-ink-muted">
+ {eventOrganizer()}
</div>
- <Show
- when={
- eventOrganizer().email &&
- eventOrganizer().email !== eventOrganizer().name
- }
- >
- <div class="truncate text-[0.6875rem] text-ink-extra-muted">
- {eventOrganizer().email}
- </div>
- </Show>
</div>
</div>
)}
</Show>
-
- <Show when={props.event.attendees.length > 0}>
- <div class="flex items-start gap-2">
- <UsersIcon class="mt-0.5 size-3.5 shrink-0 text-ink-extra-muted" />
- <div class="min-w-0 flex-1">
- <div>
- {props.event.attendees.length}{' '}
- {props.event.attendees.length === 1
- ? 'attendee'
- : 'attendees'}
- </div>
- <div class="mt-1.5 flex max-h-40 flex-col gap-1.5 overflow-y-auto pr-1">
- <For each={props.event.attendees}>
- {(attendee) => {
- const response =
- ATTENDEE_RESPONSE[attendee.responseStatus];
- const name = attendee.displayName ?? attendee.email;
-
- return (
- <div class="flex min-w-0 items-start gap-2">
- <div class="min-w-0 flex-1">
- <div class="flex min-w-0 items-center gap-1">
- <span class="truncate text-ink-muted">
- {name}
- <Show when={attendee.isSelf}> (you)</Show>
- </span>
- <Show when={attendee.isOrganizer}>
- <span class="shrink-0 text-[0.625rem] text-ink-extra-muted">
- Organizer
- </span>
- </Show>
- <Show when={attendee.isOptional}>
- <span class="shrink-0 text-[0.625rem] text-ink-extra-muted">
- Optional
- </span>
- </Show>
- </div>
- <Show
- when={
- attendee.displayName &&
- attendee.displayName !== attendee.email
- }
- >
- <div class="truncate text-[0.6875rem] text-ink-extra-muted">
- {attendee.email}
- </div>
- </Show>
- <Show when={attendee.comment}>
- {(comment) => (
- <div class="line-clamp-2 text-[0.6875rem] italic text-ink-extra-muted">
- {comment()}
- </div>
- )}
- </Show>
- </div>
- <span
- class={`shrink-0 text-[0.6875rem] ${response.class}`}
- >
- {response.label}
- </span>
- </div>
- );
- }}
- </For>
- </div>
- </div>
- </div>
- </Show>
-
- <div class="flex items-center gap-2">
- <span
- aria-hidden="true"
- class="size-2 shrink-0 rounded-sm"
- style={{ 'background-color': props.event.calendar.color }}
- />
- <span>{props.event.calendar.name}</span>
- </div>
</div>
-
- <Show when={props.event.description}>
- {(description) => (
- <p class="mt-3 border-t border-edge-muted pt-3 text-xs leading-relaxed text-ink-muted">
- {description()}
- </p>
- )}
- </Show>
</div>
</div>
</div>
);
}
+
+/** Displays attendees in a full-width collapsible popover section. */
+export function EventAttendeesSection(props: {
+ attendees: CalendarAttendee[];
+}) {
+ return (
+ <Show when={props.attendees.length > 0}>
+ <Collapsible
+ defaultOpen
+ class="border-edge-muted border-t text-xs text-ink-muted"
+ >
+ <Collapsible.Trigger class="group flex w-full items-center gap-3 px-4 py-2 text-left hover:bg-hover hover:text-ink">
+ <UsersIcon class="size-4 shrink-0 text-ink-extra-muted" />
+ <span>
+ {props.attendees.length}{' '}
+ {plural('attendee', props.attendees.length)}
+ </span>
+ <CaretDownIcon
+ aria-hidden="true"
+ class="ml-auto size-3 shrink-0 -rotate-90 text-ink-extra-muted transition-transform group-data-expanded:rotate-0"
+ />
+ </Collapsible.Trigger>
+ <Collapsible.Content class="data-closed:hidden">
+ <div class="flex gap-3 pb-3 pl-4 pt-1.5">
+ <span aria-hidden="true" class="size-4 shrink-0" />
+ <ScrollableAttendeeList attendees={props.attendees} />
+ </div>
+ </Collapsible.Content>
+ </Collapsible>
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/calendar/events/EventDetailsPopover.tsx b/apps/web/src/features/calendar/events/EventDetailsPopover.tsx
index 5dc99451ec..27d92ba97a 100644
--- a/apps/web/src/features/calendar/events/EventDetailsPopover.tsx
+++ b/apps/web/src/features/calendar/events/EventDetailsPopover.tsx
@@ -1,30 +1,57 @@
import { Popover } from '@kobalte/core/popover';
import CloseIcon from '@phosphor/x.svg';
-import { Layer } from '@ui';
-import { createEffect } from 'solid-js';
-import { EventDetails } from './EventDetails';
+import { Button, Layer } from '@ui';
+import { type Accessor, createMemo, Show } from 'solid-js';
+import { EventAttendeesSection, EventDetails } from './EventDetails';
import type { CalendarEvent, CalendarTimeFormat } from './types';
+interface SelectedEventDetailsPopoverProps {
+ anchor: Accessor<HTMLElement | undefined>;
+ event: Accessor<CalendarEvent | undefined>;
+ timeFormat: Accessor<CalendarTimeFormat>;
+ onClose: () => void;
+}
+
+/** Renders selected event details without retaining stale narrowing accessors. */
+export function SelectedEventDetailsPopover(
+ props: SelectedEventDetailsPopoverProps
+) {
+ const selection = createMemo(() => {
+ const event = props.event();
+ const anchor = props.anchor();
+
+ return event && anchor ? { anchor, event } : undefined;
+ });
+
+ return (
+ <Show keyed when={selection()}>
+ {(selected) => (
+ <EventDetailsPopover
+ anchor={selected.anchor}
+ event={selected.event}
+ timeFormat={props.timeFormat()}
+ onOpenChange={(open) => {
+ if (!open) props.onClose();
+ }}
+ />
+ )}
+ </Show>
+ );
+}
+
interface EventDetailsPopoverProps {
- anchor: HTMLElement | undefined;
+ anchor: HTMLElement;
event: CalendarEvent;
- open: boolean;
timeFormat: CalendarTimeFormat;
onOpenChange: (open: boolean) => void;
}
-/** Anchors read-only event details to a rendered event on narrow layouts. */
-export function EventDetailsPopover(props: EventDetailsPopoverProps) {
- let lastAnchor: HTMLElement | undefined;
-
- createEffect(() => {
- if (props.anchor) lastAnchor = props.anchor;
- });
-
+/** Anchors read-only event details to a rendered calendar event. */
+function EventDetailsPopover(props: EventDetailsPopoverProps) {
return (
<Popover
anchorRef={() => props.anchor}
- open={props.open}
+ open
onOpenChange={props.onOpenChange}
placement="right-start"
gutter={8}
@@ -35,23 +62,43 @@ export function EventDetailsPopover(props: EventDetailsPopoverProps) {
<Layer depth={3}>
<Popover.Content
class="z-modal max-w-[calc(100vw-2rem)] outline-none"
+ onInteractOutside={(event) => {
+ // FullCalendar selects on click (pointer release), so dismissing on
+ // pointer down would briefly close the popover before reopening it.
+ const target = event.detail.originalEvent.target;
+ if (
+ target instanceof Element &&
+ target.closest('.fc-event') !== null
+ ) {
+ event.preventDefault();
+ }
+ }}
onCloseAutoFocus={(event) => {
const shouldRestoreFocus = !event.defaultPrevented;
event.preventDefault();
- if (shouldRestoreFocus && lastAnchor?.isConnected) {
- lastAnchor.focus();
+ if (shouldRestoreFocus && props.anchor.isConnected) {
+ props.anchor.focus();
}
}}
>
<Popover.Arrow class="fill-surface" />
- <div class="relative w-80 max-w-full rounded-xl bg-surface p-3 pr-10 text-ink shadow-menu ring ring-edge-muted">
+ <div class="relative w-fit min-w-[min(20rem,calc(100vw-2rem))] max-w-[min(24rem,calc(100vw-2rem))] overflow-hidden rounded-xl bg-surface text-ink shadow-menu ring ring-edge-muted">
<Popover.Title class="sr-only">{props.event.title}</Popover.Title>
- <EventDetails event={props.event} timeFormat={props.timeFormat} />
+ <div class="p-3">
+ <EventDetails
+ event={props.event}
+ timeFormat={props.timeFormat}
+ />
+ </div>
+ <EventAttendeesSection attendees={props.event.attendees} />
<Popover.CloseButton
+ as={Button}
aria-label="Close event details"
- class="absolute right-2 top-2 flex size-6 items-center justify-center rounded-md text-ink-extra-muted outline-none hover:bg-hover hover:text-ink focus-visible:ring focus-visible:ring-accent"
+ variant="ghost"
+ size="icon-sm"
+ class="absolute right-2 top-2 rounded-md text-ink-muted"
>
- <CloseIcon class="size-3.5" />
+ <CloseIcon class="size-3" />
</Popover.CloseButton>
</div>
</Popover.Content>
diff --git a/apps/web/src/features/calendar/events/calendar-occurrence-mapper.test.ts b/apps/web/src/features/calendar/events/calendar-occurrence-mapper.test.ts
index ed3e16cb86..dfec2e0ad6 100644
--- a/apps/web/src/features/calendar/events/calendar-occurrence-mapper.test.ts
+++ b/apps/web/src/features/calendar/events/calendar-occurrence-mapper.test.ts
@@ -31,6 +31,7 @@ const item = (time: CalendarOccurrenceItem['occurrence']['time']) =>
occurrence: {
occurrenceKey: '2026-08-04T14:00:00+00:00',
recurrenceId: 'recurrence-1',
+ isCancelled: true,
time,
},
}) as CalendarOccurrenceItem;
@@ -53,6 +54,7 @@ describe('mapCalendarOccurrence', () => {
start: '2026-08-04T15:00:00Z',
end: '2026-08-04T16:00:00Z',
allDay: false,
+ isCancelled: true,
isReadOnly: true,
conferenceUrl: 'https://meet.example.com/planning',
organizerName: 'Alex Rivera',
diff --git a/apps/web/src/features/calendar/events/calendar-occurrence-mapper.ts b/apps/web/src/features/calendar/events/calendar-occurrence-mapper.ts
index 5dd9a95a6f..d36d67777b 100644
--- a/apps/web/src/features/calendar/events/calendar-occurrence-mapper.ts
+++ b/apps/web/src/features/calendar/events/calendar-occurrence-mapper.ts
@@ -26,6 +26,7 @@ export function mapCalendarOccurrence(
occurrenceKey: occurrence.occurrenceKey,
recurrenceId: occurrence.recurrenceId ?? undefined,
recurrenceLines: event.recurrenceLines ?? [],
+ isCancelled: occurrence.isCancelled,
isReadOnly: event.isReadOnly,
conferenceUrl: event.conferenceUrl ?? undefined,
organizerName: event.organizerName ?? undefined,
diff --git a/apps/web/src/features/calendar/events/recurrence-description.test.ts b/apps/web/src/features/calendar/events/recurrence-description.test.ts
new file mode 100644
index 0000000000..240cd55ddf
--- /dev/null
+++ b/apps/web/src/features/calendar/events/recurrence-description.test.ts
@@ -0,0 +1,179 @@
+import { describe, expect, it } from 'vitest';
+import {
+ formatRecurrenceDescription,
+ parseRecurrenceLines,
+} from './recurrence-description';
+
+describe('parseRecurrenceLines', () => {
+ it('parses useful rule fields and explicit recurrence dates', () => {
+ expect(
+ parseRecurrenceLines([
+ 'RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=WE,MO;COUNT=6;UNTIL=20261231T235959Z',
+ 'RDATE:20260801T090000Z,20260808T090000Z',
+ 'RDATE:20260808T090000Z',
+ 'EXDATE:20260815T090000Z',
+ ])
+ ).toEqual({
+ hasRecurrenceRule: true,
+ rule: {
+ frequency: 'WEEKLY',
+ interval: 2,
+ byDay: [
+ { weekday: 'WE', ordinal: undefined },
+ { weekday: 'MO', ordinal: undefined },
+ ],
+ byMonthDay: [],
+ byMonth: [],
+ count: 6,
+ until: '20261231T235959Z',
+ },
+ additionalDates: ['20260801T090000Z', '20260808T090000Z'],
+ excludedDates: ['20260815T090000Z'],
+ });
+ });
+
+ it('ignores invalid selectors and defaults invalid intervals to one', () => {
+ expect(
+ parseRecurrenceLines([
+ 'rrule:FREQ=monthly;INTERVAL=0;BYDAY=0MO,XX,2TU;BYMONTHDAY=0,32,-1;BYMONTH=0,12,13',
+ ]).rule
+ ).toEqual({
+ frequency: 'MONTHLY',
+ interval: 1,
+ byDay: [{ weekday: 'TU', ordinal: 2 }],
+ byMonthDay: [-1],
+ byMonth: [12],
+ count: undefined,
+ until: undefined,
+ });
+ });
+});
+
+describe('formatRecurrenceDescription', () => {
+ it.each([
+ {
+ name: 'daily',
+ lines: ['RRULE:FREQ=DAILY'],
+ expected: 'Daily',
+ },
+ {
+ name: 'multi-day interval',
+ lines: ['RRULE:FREQ=DAILY;INTERVAL=3'],
+ expected: 'Every 3 days',
+ },
+ {
+ name: 'weekly',
+ lines: ['RRULE:FREQ=WEEKLY'],
+ expected: 'Weekly',
+ },
+ {
+ name: 'weekly on selected days',
+ lines: ['RRULE:FREQ=WEEKLY;BYDAY=FR,MO,WE'],
+ expected: 'Weekly on Monday, Wednesday, and Friday',
+ },
+ {
+ name: 'biweekly on selected days',
+ lines: ['RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH'],
+ expected: 'Every 2 weeks on Tuesday and Thursday',
+ },
+ {
+ name: 'workweek',
+ lines: ['RRULE:FREQ=WEEKLY;BYDAY=FR,WE,MO,TH,TU'],
+ expected: 'Every weekday',
+ },
+ {
+ name: 'monthly on numbered days',
+ lines: ['RRULE:FREQ=MONTHLY;BYMONTHDAY=1,15'],
+ expected: 'Monthly on the 1st and 15th',
+ },
+ {
+ name: 'monthly on the last day',
+ lines: ['RRULE:FREQ=MONTHLY;BYMONTHDAY=-1'],
+ expected: 'Monthly on the last day',
+ },
+ {
+ name: 'monthly on an ordinal weekday',
+ lines: ['RRULE:FREQ=MONTHLY;BYDAY=1MO'],
+ expected: 'Monthly on the first Monday',
+ },
+ {
+ name: 'monthly on every matching weekday',
+ lines: ['RRULE:FREQ=MONTHLY;BYDAY=MO'],
+ expected: 'Monthly on Monday',
+ },
+ {
+ name: 'yearly on a date',
+ lines: ['RRULE:FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1'],
+ expected: 'Yearly on January 1',
+ },
+ {
+ name: 'yearly in selected months',
+ lines: ['RRULE:FREQ=YEARLY;BYMONTH=1,7'],
+ expected: 'Yearly in January and July',
+ },
+ {
+ name: 'yearly on an ordinal weekday in a month',
+ lines: ['RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=-1TH'],
+ expected: 'Yearly on the last Thursday in November',
+ },
+ {
+ name: 'hourly interval',
+ lines: ['RRULE:FREQ=HOURLY;INTERVAL=6'],
+ expected: 'Every 6 hours',
+ },
+ {
+ name: 'occurrence count',
+ lines: ['RRULE:FREQ=DAILY;COUNT=3'],
+ expected: 'Daily · 3 occurrences',
+ },
+ {
+ name: 'single occurrence count',
+ lines: ['RRULE:FREQ=DAILY;COUNT=1'],
+ expected: 'Daily · 1 occurrence',
+ },
+ {
+ name: 'end date',
+ lines: ['RRULE:FREQ=WEEKLY;UNTIL=20260831T235959Z'],
+ expected: 'Weekly · until August 31, 2026',
+ },
+ {
+ name: 'additional and excluded dates',
+ lines: [
+ 'RRULE:FREQ=WEEKLY',
+ 'RDATE:20260801,20260808',
+ 'EXDATE:20260815,20260815',
+ ],
+ expected: 'Weekly · 2 additional dates · 1 exception',
+ },
+ {
+ name: 'RDATE-only recurrence',
+ lines: ['RDATE:20260801,20260808'],
+ expected: 'Repeats on 2 additional dates',
+ },
+ {
+ name: 'malformed rule',
+ lines: ['RRULE:INTERVAL=2'],
+ expected: 'Recurring event',
+ },
+ {
+ name: 'unsupported frequency',
+ lines: ['RRULE:FREQ=FORTNIGHTLY'],
+ expected: 'Recurring event',
+ },
+ {
+ name: 'invalid interval and month day values',
+ lines: ['RRULE:FREQ=MONTHLY;INTERVAL=-2;BYMONTHDAY=0,35'],
+ expected: 'Monthly',
+ },
+ ])('formats $name', ({ lines, expected }) => {
+ expect(formatRecurrenceDescription(lines, { locale: 'en-US' })).toBe(
+ expected
+ );
+ });
+
+ it('returns undefined when the lines do not declare recurrence', () => {
+ expect(formatRecurrenceDescription([])).toBeUndefined();
+ expect(formatRecurrenceDescription(['EXDATE:20260815'])).toBeUndefined();
+ expect(formatRecurrenceDescription(['UNKNOWN:value'])).toBeUndefined();
+ });
+});
diff --git a/apps/web/src/features/calendar/events/recurrence-description.ts b/apps/web/src/features/calendar/events/recurrence-description.ts
new file mode 100644
index 0000000000..735d7be779
--- /dev/null
+++ b/apps/web/src/features/calendar/events/recurrence-description.ts
@@ -0,0 +1,415 @@
+import { formatOrdinal, plural } from '@core/util/string';
+
+const POSITIVE_INTEGER_REGEX = /^\d+$/;
+const BYDAY_VALUE_REGEX = /^([+-]?\d{1,2})?(MO|TU|WE|TH|FR|SA|SU)$/i;
+const RECURRENCE_DATE_REGEX = /^(\d{4})-?(\d{2})-?(\d{2})/;
+
+const RECURRENCE_FREQUENCIES = [
+ 'SECONDLY',
+ 'MINUTELY',
+ 'HOURLY',
+ 'DAILY',
+ 'WEEKLY',
+ 'MONTHLY',
+ 'YEARLY',
+] as const;
+
+const WEEKDAYS = {
+ MO: { day: 1, name: 'Monday' },
+ TU: { day: 2, name: 'Tuesday' },
+ WE: { day: 3, name: 'Wednesday' },
+ TH: { day: 4, name: 'Thursday' },
+ FR: { day: 5, name: 'Friday' },
+ SA: { day: 6, name: 'Saturday' },
+ SU: { day: 7, name: 'Sunday' },
+} as const;
+
+const WORKWEEK_CODES = ['MO', 'TU', 'WE', 'TH', 'FR'] as const;
+
+type RecurrenceFrequency = (typeof RECURRENCE_FREQUENCIES)[number];
+type WeekdayCode = keyof typeof WEEKDAYS;
+
+/** One weekday selector from an RFC 5545 `BYDAY` rule. */
+export interface RecurrenceWeekday {
+ /** Weekday code such as `MO` or `FR`. */
+ weekday: WeekdayCode;
+ /** Positional selector such as `1` for first or `-1` for last. */
+ ordinal?: number;
+}
+
+/** The recurrence fields used by the calendar event details UI. */
+export interface ParsedRecurrenceRule {
+ /** RFC 5545 recurrence frequency, when supported. */
+ frequency?: RecurrenceFrequency;
+ /** Frequency interval. Defaults to one. */
+ interval: number;
+ /** Weekday selectors. */
+ byDay: RecurrenceWeekday[];
+ /** Days of the month, including negative values counted from the end. */
+ byMonthDay: number[];
+ /** One-based month numbers. */
+ byMonth: number[];
+ /** Maximum number of occurrences. */
+ count?: number;
+ /** Raw RFC 5545 recurrence end value. */
+ until?: string;
+}
+
+/** Parsed recurrence metadata from an event's raw recurrence properties. */
+export interface ParsedRecurrenceLines {
+ /** Whether an `RRULE` property was present, even if it was malformed. */
+ hasRecurrenceRule: boolean;
+ /** First parsed recurrence rule. */
+ rule?: ParsedRecurrenceRule;
+ /** Explicitly included recurrence dates. */
+ additionalDates: string[];
+ /** Explicitly excluded recurrence dates. */
+ excludedDates: string[];
+}
+
+function parsePositiveInteger(value: string | undefined) {
+ if (!value || !POSITIVE_INTEGER_REGEX.test(value)) return undefined;
+ const parsed = Number(value);
+ return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
+}
+
+function parseIntegerList(
+ value: string | undefined,
+ isValid: (value: number) => boolean
+) {
+ if (!value) return [];
+
+ return value
+ .split(',')
+ .map((part) => Number(part))
+ .filter((part) => Number.isInteger(part) && isValid(part));
+}
+
+function parseByDay(value: string | undefined): RecurrenceWeekday[] {
+ if (!value) return [];
+
+ return value.split(',').flatMap((part) => {
+ const match = BYDAY_VALUE_REGEX.exec(part.trim());
+ if (!match) return [];
+
+ const weekday = match[2]?.toUpperCase() as WeekdayCode;
+ const ordinal = match[1] === undefined ? undefined : Number(match[1]);
+ if (ordinal === 0 || (ordinal !== undefined && Math.abs(ordinal) > 53)) {
+ return [];
+ }
+
+ return [{ weekday, ordinal }];
+ });
+}
+
+function parseRule(value: string): ParsedRecurrenceRule {
+ const fields = new Map<string, string>();
+ for (const part of value.split(';')) {
+ const separator = part.indexOf('=');
+ if (separator < 1) continue;
+ fields.set(
+ part.slice(0, separator).trim().toUpperCase(),
+ part.slice(separator + 1).trim()
+ );
+ }
+
+ const rawFrequency = fields.get('FREQ')?.toUpperCase();
+ const frequency = RECURRENCE_FREQUENCIES.find(
+ (candidate) => candidate === rawFrequency
+ );
+
+ return {
+ frequency,
+ interval: parsePositiveInteger(fields.get('INTERVAL')) ?? 1,
+ byDay: parseByDay(fields.get('BYDAY')),
+ byMonthDay: parseIntegerList(
+ fields.get('BYMONTHDAY'),
+ (day) => day !== 0 && day >= -31 && day <= 31
+ ),
+ byMonth: parseIntegerList(
+ fields.get('BYMONTH'),
+ (month) => month >= 1 && month <= 12
+ ),
+ count: parsePositiveInteger(fields.get('COUNT')),
+ until: fields.get('UNTIL') || undefined,
+ };
+}
+
+function addDateValues(target: Set<string>, value: string) {
+ for (const date of value.split(',')) {
+ const trimmed = date.trim();
+ if (trimmed) target.add(trimmed);
+ }
+}
+
+/** Parses raw `RRULE`, `RDATE`, and `EXDATE` properties. */
+export function parseRecurrenceLines(lines: string[]): ParsedRecurrenceLines {
+ let hasRecurrenceRule = false;
+ let rule: ParsedRecurrenceRule | undefined;
+ const additionalDates = new Set<string>();
+ const excludedDates = new Set<string>();
+
+ for (const rawLine of lines) {
+ const separator = rawLine.indexOf(':');
+ if (separator < 1) continue;
+
+ const property = rawLine
+ .slice(0, separator)
+ .split(';', 1)[0]
+ ?.trim()
+ .toUpperCase();
+ const value = rawLine.slice(separator + 1).trim();
+
+ if (property === 'RRULE') {
+ hasRecurrenceRule = true;
+ if (!rule) rule = parseRule(value);
+ } else if (property === 'RDATE') {
+ addDateValues(additionalDates, value);
+ } else if (property === 'EXDATE') {
+ addDateValues(excludedDates, value);
+ }
+ }
+
+ return {
+ hasRecurrenceRule,
+ rule,
+ additionalDates: [...additionalDates],
+ excludedDates: [...excludedDates],
+ };
+}
+
+function formatBaseFrequency(frequency: RecurrenceFrequency, interval: number) {
+ if (interval > 1) {
+ const unit = {
+ SECONDLY: 'second',
+ MINUTELY: 'minute',
+ HOURLY: 'hour',
+ DAILY: 'day',
+ WEEKLY: 'week',
+ MONTHLY: 'month',
+ YEARLY: 'year',
+ }[frequency];
+ return `Every ${interval} ${plural(unit, interval)}`;
+ }
+
+ return {
+ SECONDLY: 'Every second',
+ MINUTELY: 'Every minute',
+ HOURLY: 'Hourly',
+ DAILY: 'Daily',
+ WEEKLY: 'Weekly',
+ MONTHLY: 'Monthly',
+ YEARLY: 'Yearly',
+ }[frequency];
+}
+
+function ordinalWord(value: number) {
+ const words: Record<number, string> = {
+ 1: 'first',
+ 2: 'second',
+ 3: 'third',
+ 4: 'fourth',
+ 5: 'fifth',
+ [-1]: 'last',
+ [-2]: 'second-to-last',
+ [-3]: 'third-to-last',
+ [-4]: 'fourth-to-last',
+ [-5]: 'fifth-to-last',
+ };
+ return (
+ words[value] ??
+ (value > 0
+ ? formatOrdinal(value)
+ : `${formatOrdinal(Math.abs(value))}-to-last`)
+ );
+}
+
+function listFormatter(locale?: Intl.LocalesArgument) {
+ return new Intl.ListFormat(locale, { style: 'long', type: 'conjunction' });
+}
+
+function sortedByDays(byDay: RecurrenceWeekday[]) {
+ return byDay.toSorted(
+ (first, second) =>
+ WEEKDAYS[first.weekday].day - WEEKDAYS[second.weekday].day ||
+ (first.ordinal ?? 0) - (second.ordinal ?? 0)
+ );
+}
+
+function isWorkweek(byDay: RecurrenceWeekday[]) {
+ if (byDay.some((day) => day.ordinal !== undefined)) return false;
+ const weekdays = new Set(byDay.map((day) => day.weekday));
+ return (
+ weekdays.size === WORKWEEK_CODES.length &&
+ WORKWEEK_CODES.every((weekday) => weekdays.has(weekday))
+ );
+}
+
+function formatByDay(
+ byDay: RecurrenceWeekday[],
+ locale?: Intl.LocalesArgument
+) {
+ const labels = sortedByDays(byDay).map(({ ordinal, weekday }) => {
+ const day = WEEKDAYS[weekday].name;
+ return ordinal === undefined ? day : `${ordinalWord(ordinal)} ${day}`;
+ });
+ return listFormatter(locale).format(labels);
+}
+
+function formatMonthDays(days: number[], locale?: Intl.LocalesArgument) {
+ const labels = days.map((day) =>
+ day > 0
+ ? formatOrdinal(day)
+ : day === -1
+ ? 'last day'
+ : `${ordinalWord(day)} day`
+ );
+ return listFormatter(locale).format(labels);
+}
+
+function formatMonths(months: number[], locale?: Intl.LocalesArgument) {
+ const formatter = new Intl.DateTimeFormat(locale, {
+ month: 'long',
+ timeZone: 'UTC',
+ });
+ return listFormatter(locale).format(
+ months.map((month) => formatter.format(new Date(Date.UTC(2020, month - 1))))
+ );
+}
+
+function formatRuleDetails(
+ rule: ParsedRecurrenceRule,
+ locale?: Intl.LocalesArgument
+) {
+ const frequency = rule.frequency;
+ if (!frequency) return undefined;
+
+ if (
+ rule.interval === 1 &&
+ (frequency === 'DAILY' || frequency === 'WEEKLY') &&
+ isWorkweek(rule.byDay)
+ ) {
+ return 'Every weekday';
+ }
+
+ const base = formatBaseFrequency(frequency, rule.interval);
+ const days = rule.byDay.length > 0 ? formatByDay(rule.byDay, locale) : '';
+
+ if (frequency === 'WEEKLY' && days) return `${base} on ${days}`;
+ if (frequency === 'DAILY' && days) return `${base} on ${days}`;
+
+ if (frequency === 'MONTHLY') {
+ if (rule.byMonthDay.length > 0) {
+ return `${base} on the ${formatMonthDays(rule.byMonthDay, locale)}`;
+ }
+ if (days) {
+ const article = rule.byDay.some((day) => day.ordinal !== undefined)
+ ? 'the '
+ : '';
+ return `${base} on ${article}${days}`;
+ }
+ }
+
+ if (frequency === 'YEARLY') {
+ const months =
+ rule.byMonth.length > 0 ? formatMonths(rule.byMonth, locale) : '';
+ const monthDay = rule.byMonthDay[0];
+
+ if (months && monthDay !== undefined) {
+ if (rule.byMonth.length === 1 && monthDay > 0) {
+ return `${base} on ${months} ${monthDay}`;
+ }
+ if (monthDay === -1) return `${base} on the last day of ${months}`;
+ return `${base} on day ${monthDay} in ${months}`;
+ }
+ if (months && days) {
+ const article = rule.byDay.some((day) => day.ordinal !== undefined)
+ ? 'the '
+ : '';
+ return `${base} on ${article}${days} in ${months}`;
+ }
+ if (months) return `${base} in ${months}`;
+ if (days) {
+ const article = rule.byDay.some((day) => day.ordinal !== undefined)
+ ? 'the '
+ : '';
+ return `${base} on ${article}${days}`;
+ }
+ if (rule.byMonthDay.length > 0) {
+ return `${base} on the ${formatMonthDays(rule.byMonthDay, locale)}`;
+ }
+ }
+
+ return base;
+}
+
+function parseUntilDate(value: string) {
+ const match = RECURRENCE_DATE_REGEX.exec(value);
+ if (!match) return undefined;
+
+ const year = Number(match[1]);
+ const month = Number(match[2]);
+ const day = Number(match[3]);
+ const date = new Date(Date.UTC(year, month - 1, day));
+ return date.getUTCFullYear() === year &&
+ date.getUTCMonth() === month - 1 &&
+ date.getUTCDate() === day
+ ? date
+ : undefined;
+}
+
+/** Options for formatting a recurrence description. */
+export interface RecurrenceDescriptionOptions {
+ /** Locale used for weekday, month, date, and list formatting. */
+ locale?: Intl.LocalesArgument;
+}
+
+/** Formats recurrence properties as concise, human-readable text. */
+export function formatRecurrenceDescription(
+ lines: string[],
+ options: RecurrenceDescriptionOptions = {}
+): string | undefined {
+ const { locale } = options;
+ const parsed = parseRecurrenceLines(lines);
+ let description = parsed.rule
+ ? formatRuleDetails(parsed.rule, locale)
+ : undefined;
+
+ if (!description && parsed.additionalDates.length > 0) {
+ const count = parsed.additionalDates.length;
+ description = `Repeats on ${count} additional ${plural('date', count)}`;
+ }
+
+ if (!description && parsed.hasRecurrenceRule) description = 'Recurring event';
+ if (!description) return undefined;
+
+ const suffixes: string[] = [];
+ if (parsed.rule?.count) {
+ suffixes.push(
+ `${parsed.rule.count} ${plural('occurrence', parsed.rule.count)}`
+ );
+ }
+ if (parsed.rule?.until) {
+ const until = parseUntilDate(parsed.rule.until);
+ if (until) {
+ suffixes.push(
+ `until ${new Intl.DateTimeFormat(locale, {
+ month: 'long',
+ day: 'numeric',
+ year: 'numeric',
+ timeZone: 'UTC',
+ }).format(until)}`
+ );
+ }
+ }
+ if (parsed.rule && parsed.additionalDates.length > 0) {
+ const count = parsed.additionalDates.length;
+ suffixes.push(`${count} additional ${plural('date', count)}`);
+ }
+ if (parsed.excludedDates.length > 0) {
+ const count = parsed.excludedDates.length;
+ suffixes.push(`${count} ${plural('exception', count)}`);
+ }
+
+ return [description, ...suffixes].join(' · ');
+}
diff --git a/apps/web/src/features/calendar/events/types.ts b/apps/web/src/features/calendar/events/types.ts
index fc5e8f2ba2..41fc2ed0bb 100644
--- a/apps/web/src/features/calendar/events/types.ts
+++ b/apps/web/src/features/calendar/events/types.ts
@@ -26,6 +26,8 @@ export interface CalendarEvent {
occurrenceKey: string;
/** Provider recurrence identifier, when applicable. */
recurrenceId?: string;
+ /** Whether this materialized occurrence was cancelled. */
+ isCancelled: boolean;
/** Whether the canonical event source is read-only. */
isReadOnly: boolean;
/** Direct conference join URL, when available. */
diff --git a/apps/web/src/lib/core/component/VerticalScrollIndicators.tsx b/apps/web/src/lib/core/component/VerticalScrollIndicators.tsx
index 720f13a610..1291c3770d 100644
--- a/apps/web/src/lib/core/component/VerticalScrollIndicators.tsx
+++ b/apps/web/src/lib/core/component/VerticalScrollIndicators.tsx
@@ -1,42 +1,46 @@
import { cn } from '@ui';
-import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js';
+import { type Accessor, createEffect, onCleanup } from 'solid-js';
const SCROLL_THRESHOLD = 20;
+function thresholdOpacity(distance: number) {
+ return Math.max(0, Math.min(distance, SCROLL_THRESHOLD) / SCROLL_THRESHOLD);
+}
+
/**
- * Used to add decorative indications that content is scrollable, in scenarios where the scrollbar is hidden.
- * Supports both vertical (default) and horizontal scroll directions.
+ * Adds decorative indications that content is scrollable. The indicators hide
+ * at their respective scroll boundaries and support vertical or horizontal
+ * scrolling.
*/
export const ScrollIndicators = (props: {
scrollRef: Accessor<HTMLElement | undefined>;
direction?: 'vertical' | 'horizontal';
+ appearance?: 'pattern' | 'gradient';
+ class?: string;
noBorderStart?: boolean;
noBorderEnd?: boolean;
}) => {
- const [startOpacity, setStartOpacity] = createSignal(0);
- const [endOpacity, setEndOpacity] = createSignal(0);
+ let startIndicator: HTMLDivElement | undefined;
+ let endIndicator: HTMLDivElement | undefined;
const isHorizontal = () => props.direction === 'horizontal';
+ const isGradient = () => props.appearance === 'gradient';
const updateIndicators = () => {
const ref = props.scrollRef();
- if (!ref) return;
+ if (!ref || !startIndicator || !endIndicator) return;
if (isHorizontal()) {
const { scrollLeft, scrollWidth, clientWidth } = ref;
- setStartOpacity(
- Math.min(scrollLeft, SCROLL_THRESHOLD) / SCROLL_THRESHOLD
- );
- setEndOpacity(
- Math.min(scrollWidth - clientWidth - scrollLeft, SCROLL_THRESHOLD) /
- SCROLL_THRESHOLD
+ startIndicator.style.opacity = String(thresholdOpacity(scrollLeft));
+ endIndicator.style.opacity = String(
+ thresholdOpacity(scrollWidth - clientWidth - scrollLeft)
);
} else {
const { scrollTop, scrollHeight, clientHeight } = ref;
- setStartOpacity(Math.min(scrollTop, SCROLL_THRESHOLD) / SCROLL_THRESHOLD);
- setEndOpacity(
- Math.min(scrollHeight - clientHeight - scrollTop, SCROLL_THRESHOLD) /
- SCROLL_THRESHOLD
+ startIndicator.style.opacity = String(thresholdOpacity(scrollTop));
+ endIndicator.style.opacity = String(
+ thresholdOpacity(scrollHeight - clientHeight - scrollTop)
);
}
};
@@ -45,52 +49,67 @@ export const ScrollIndicators = (props: {
const ref = props.scrollRef();
if (!ref) return;
- ref.addEventListener('scroll', updateIndicators);
+ ref.addEventListener('scroll', updateIndicators, { passive: true });
const resizeObserver = new ResizeObserver(updateIndicators);
resizeObserver.observe(ref);
+ const observeScrollContent = () => {
+ const content = ref.firstElementChild;
+ if (content instanceof HTMLElement) resizeObserver.observe(content);
+ };
+ observeScrollContent();
+
+ updateIndicators();
onCleanup(() => {
ref.removeEventListener('scroll', updateIndicators);
resizeObserver.disconnect();
});
-
- updateIndicators();
});
return (
<>
- {/* Start scroll boundary indicator */}
<div
+ ref={startIndicator}
+ aria-hidden="true"
class={cn(
- 'absolute pointer-events-none z-annotation-layer pattern-diagonal-4 pattern-edge',
- isHorizontal()
- ? cn(
- 'inset-y-px left-0 w-3 mask-r-from-0%',
- !props.noBorderStart && 'border-l border-edge-muted'
- )
- : cn(
- 'inset-x-px top-0 h-3 mask-b-from-0%',
- !props.noBorderStart && 'border-t border-edge-muted'
- )
+ 'pointer-events-none absolute z-annotation-layer',
+ isGradient()
+ ? isHorizontal()
+ ? 'inset-y-0 left-0 w-4 bg-linear-to-r from-surface to-transparent transition-opacity'
+ : 'inset-x-0 top-0 h-4 bg-linear-to-b from-surface to-transparent transition-opacity'
+ : isHorizontal()
+ ? cn(
+ 'inset-y-px left-0 w-3 mask-r-from-0% pattern-diagonal-4 pattern-edge',
+ !props.noBorderStart && 'border-edge-muted border-l'
+ )
+ : cn(
+ 'inset-x-px top-0 h-3 mask-b-from-0% pattern-diagonal-4 pattern-edge',
+ !props.noBorderStart && 'border-edge-muted border-t'
+ ),
+ props.class
)}
- style={{ opacity: startOpacity() }}
/>
- {/* End scroll boundary indicator */}
<div
+ ref={endIndicator}
+ aria-hidden="true"
class={cn(
- 'absolute pointer-events-none z-annotation-layer pattern-diagonal-4 pattern-edge',
- isHorizontal()
- ? cn(
- 'inset-y-px right-0 w-3 mask-l-from-0%',
- !props.noBorderEnd && 'border-r border-edge-muted'
- )
- : cn(
- 'inset-x-px bottom-0 h-3 mask-t-from-0%',
- !props.noBorderEnd && 'border-b border-edge-muted'
- )
+ 'pointer-events-none absolute z-annotation-layer',
+ isGradient()
+ ? isHorizontal()
+ ? 'inset-y-0 right-0 w-4 bg-linear-to-l from-surface to-transparent transition-opacity'
+ : 'inset-x-0 bottom-0 h-4 bg-linear-to-t from-surface to-transparent transition-opacity'
+ : isHorizontal()
+ ? cn(
+ 'inset-y-px right-0 w-3 mask-l-from-0% pattern-diagonal-4 pattern-edge',
+ !props.noBorderEnd && 'border-edge-muted border-r'
+ )
+ : cn(
+ 'inset-x-px bottom-0 h-3 mask-t-from-0% pattern-diagonal-4 pattern-edge',
+ !props.noBorderEnd && 'border-edge-muted border-b'
+ ),
+ props.class
)}
- style={{ opacity: endOpacity() }}
/>
</>
);
diff --git a/apps/web/src/lib/core/util/string.test.ts b/apps/web/src/lib/core/util/string.test.ts
index de5659e62a..a542d71fc9 100644
--- a/apps/web/src/lib/core/util/string.test.ts
+++ b/apps/web/src/lib/core/util/string.test.ts
@@ -1,5 +1,23 @@
import { describe, expect, it } from 'vitest';
-import { isEmojiOnly } from './string';
+import { formatOrdinal, isEmojiOnly } from './string';
+
+describe('formatOrdinal', () => {
+ it.each([
+ [1, '1st'],
+ [2, '2nd'],
+ [3, '3rd'],
+ [4, '4th'],
+ [11, '11th'],
+ [12, '12th'],
+ [13, '13th'],
+ [21, '21st'],
+ [22, '22nd'],
+ [23, '23rd'],
+ [-1, '-1st'],
+ ])('formats %d as %s', (value, expected) => {
+ expect(formatOrdinal(value)).toBe(expected);
+ });
+});
describe('isEmojiOnly', () => {
it('returns true for single emoji', () => {
diff --git a/apps/web/src/lib/core/util/string.ts b/apps/web/src/lib/core/util/string.ts
index bf01bf13ce..4972571f71 100644
--- a/apps/web/src/lib/core/util/string.ts
+++ b/apps/web/src/lib/core/util/string.ts
@@ -54,6 +54,25 @@ export function plural(singular: string, length: number, suffix = 's') {
return `${singular}${suffix}`;
}
+/** Formats an integer as an English ordinal, such as `1st` or `23rd`. */
+export function formatOrdinal(value: number) {
+ const integer = Math.trunc(value);
+ const absolute = Math.abs(integer);
+ const tens = absolute % 100;
+ const suffix =
+ tens >= 11 && tens <= 13
+ ? 'th'
+ : absolute % 10 === 1
+ ? 'st'
+ : absolute % 10 === 2
+ ? 'nd'
+ : absolute % 10 === 3
+ ? 'rd'
+ : 'th';
+
+ return `${integer < 0 ? '-' : ''}${absolute}${suffix}`;
+}
+
/**
* Regex pattern to match emoji-only strings.
* Uses alternation to match: