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(sidebar): calendar hover card (#5722)

dev-rbacfe4fa9f284
diff --git a/apps/web/src/components/app/app-sidebar/calendar-sidebar-preview.tsx b/apps/web/src/components/app/app-sidebar/calendar-sidebar-preview.tsx
new file mode 100644
index 0000000000..d5dd9d1358
--- /dev/null
+++ b/apps/web/src/components/app/app-sidebar/calendar-sidebar-preview.tsx
@@ -0,0 +1,491 @@
+import { useOpenEventComposer } from '@app/features/block-calendar/components/use-open-event-composer';
+import {
+ CALENDAR_BLOCK_ID,
+ type CalendarBlockProps,
+} from '@app/features/block-calendar/types';
+import type { CalendarGridHandle } from '@app/features/calendar/components/CalendarGrid';
+import { CalendarGridSkeleton } from '@app/features/calendar/components/CalendarGridSkeleton';
+import { useCalendarOccurrenceData } from '@app/features/calendar/hooks/use-calendar-occurrence-data';
+import { useCalendarSources } from '@app/features/calendar/hooks/use-calendar-sources';
+import type {
+ CalendarEvent,
+ CalendarTimeFormat,
+} from '@app/features/calendar/types';
+import { parseLocalDate } from '@app/features/calendar/utils/calendar-date';
+import {
+ formatCalendarTime,
+ getDefaultCalendarTimeFormat,
+} from '@app/features/calendar/utils/time-format';
+import { globalSplitManager } from '@app/signal/splitLayout';
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { HoverCard } from '@core/component/HoverCard';
+import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';
+import { openExternalUrl } from '@core/util/url';
+import ArrowRightIcon from '@phosphor/arrow-right.svg';
+import CaretRightIcon from '@phosphor/caret-right.svg';
+import CheckIcon from '@phosphor/check.svg';
+import GearIcon from '@phosphor/gear.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import VideoCameraIcon from '@phosphor/video-camera.svg';
+import XIcon from '@phosphor/x.svg';
+import type { CalendarOccurrenceQueryRange } from '@queries/calendar/occurrences';
+import { createCalendarOccurrenceQueryRange } from '@queries/calendar/occurrences';
+import { Button } from '@ui/components/Button';
+import { Dropdown } from '@ui/components/Dropdown';
+import { Layer } from '@ui/components/Layer';
+import { Surface } from '@ui/components/Surface';
+import {
+ createEffect,
+ createSignal,
+ For,
+ lazy,
+ onCleanup,
+ type ParentProps,
+ type Setter,
+ Show,
+ Suspense,
+} from 'solid-js';
+
+const CalendarEmbed = lazy(() =>
+ import('@app/features/calendar/components/CalendarEmbed').then((module) => ({
+ default: module.CalendarEmbed,
+ }))
+);
+
+function dayRange(date: Date): CalendarOccurrenceQueryRange {
+ const start = new Date(date.getFullYear(), date.getMonth(), date.getDate());
+ const end = new Date(start);
+ end.setDate(end.getDate() + 1);
+ return createCalendarOccurrenceQueryRange(start, end);
+}
+
+function PreviewSkeleton() {
+ return <CalendarGridSkeleton showDayHeader={false} showAllDaySlot={false} />;
+}
+
+function CalendarScrollElement(props: {
+ grid: CalendarGridHandle;
+ setScrollElement: Setter<HTMLElement | undefined>;
+}) {
+ createEffect(() => {
+ const host = props.grid.element();
+ if (!host) return;
+
+ const updateScrollElement = () => {
+ const scroller = Array.from(
+ host.querySelectorAll<HTMLElement>('.fc-scroller')
+ ).find((element) => element.querySelector('.fc-timegrid-body'));
+ props.setScrollElement(scroller);
+ };
+ const observer = new MutationObserver(updateScrollElement);
+ observer.observe(host, { childList: true, subtree: true });
+ updateScrollElement();
+
+ onCleanup(() => {
+ observer.disconnect();
+ props.setScrollElement(undefined);
+ });
+ });
+
+ return null;
+}
+
+const PREVIEW_TIME_FORMAT_OPTIONS: Array<{
+ value: CalendarTimeFormat;
+ label: string;
+}> = [
+ { value: '12-hour', label: '12-hour' },
+ { value: '24-hour', label: '24-hour' },
+];
+
+const eventDateFormat = new Intl.DateTimeFormat(undefined, {
+ weekday: 'short',
+ month: 'short',
+ day: 'numeric',
+});
+
+function eventDate(value: string) {
+ return parseLocalDate(value) ?? new Date(value);
+}
+
+function eventSchedule(event: CalendarEvent) {
+ const start = eventDate(event.start);
+ if (event.allDay) return `${eventDateFormat.format(start)} · All day`;
+
+ const end = eventDate(event.end);
+ const timeFormat = getDefaultCalendarTimeFormat();
+ return `${eventDateFormat.format(start)} · ${formatCalendarTime(start, timeFormat)}–${formatCalendarTime(end, timeFormat)}`;
+}
+
+function conferenceUrl(event: CalendarEvent) {
+ if (!event.conferenceUrl) return undefined;
+
+ try {
+ const url = new URL(event.conferenceUrl);
+ return url.protocol === 'https:' || url.protocol === 'http:'
+ ? url.toString()
+ : undefined;
+ } catch {
+ return undefined;
+ }
+}
+
+function EventSummary(props: {
+ event: CalendarEvent;
+ onClose: () => void;
+ onViewInCalendar: () => void;
+}) {
+ return (
+ <div class="shrink-0 border-t border-edge bg-surface">
+ <div class="flex h-10 items-center justify-between px-2">
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ class="rounded-lg"
+ label="Close event details"
+ onClick={props.onClose}
+ >
+ <XIcon class="size-4" />
+ </Button>
+ <Button
+ variant="base"
+ size="sm"
+ depth={4}
+ class="rounded-lg bg-surface px-2"
+ data-calendar-event-target-navigation
+ onClick={props.onViewInCalendar}
+ >
+ Open
+ <ArrowRightIcon class="size-4" />
+ </Button>
+ </div>
+ <div class="flex flex-col gap-2 px-3 pb-3 pt-2">
+ <div class="flex min-w-0 items-start gap-2">
+ <span
+ aria-hidden="true"
+ class="mt-0.5 size-3 shrink-0 rounded-sm"
+ style={{ 'background-color': props.event.calendar.color }}
+ />
+ <div class="min-w-0">
+ <h3 class="truncate text-sm font-semibold text-ink">
+ {props.event.title}
+ </h3>
+ <p class="text-xs text-ink-muted">{eventSchedule(props.event)}</p>
+ </div>
+ </div>
+ <Show when={conferenceUrl(props.event)}>
+ {(url) => (
+ <Button
+ fullWidth
+ variant="cta"
+ size="sm"
+ class="h-8 rounded-lg"
+ onClick={() => openExternalUrl(url())}
+ >
+ <VideoCameraIcon class="size-4" />
+ {props.event.conferenceProvider === 'google_meet'
+ ? 'Join Google Meet'
+ : 'Join meeting'}
+ </Button>
+ )}
+ </Show>
+ </div>
+ </div>
+ );
+}
+
+function PreviewContent(props: { dropdownMount?: HTMLElement }) {
+ const initialDate = new Date();
+ const [range, setRange] = createSignal<CalendarOccurrenceQueryRange>(
+ dayRange(initialDate)
+ );
+ const [selectedEventId, setSelectedEventId] = createSignal<string>();
+ const [scrollElement, setScrollElement] = createSignal<HTMLElement>();
+ const [hiddenSourceIds, setHiddenSourceIds] = createSignal<
+ ReadonlySet<string>
+ >(new Set());
+ const [timeFormat, setTimeFormat] = createSignal<CalendarTimeFormat>(
+ getDefaultCalendarTimeFormat()
+ );
+ const layout = useSplitLayout();
+ const openEventComposer = useOpenEventComposer();
+ const { sourceById, sources } = useCalendarSources();
+ const isSourceVisible = (sourceId: string) =>
+ !hiddenSourceIds().has(sourceId);
+ const data = useCalendarOccurrenceData({
+ range,
+ sourceById,
+ isSourceVisible,
+ });
+ const selectedEvent = () => {
+ const eventId = selectedEventId();
+ return eventId ? data.eventsById().get(eventId) : undefined;
+ };
+ const setSourceVisibility = (sourceId: string, visible: boolean) => {
+ setHiddenSourceIds((current) => {
+ const next = new Set(current);
+ if (visible) next.delete(sourceId);
+ else next.add(sourceId);
+ return next;
+ });
+ if (!visible && selectedEvent()?.calendar.id === sourceId) {
+ setSelectedEventId(undefined);
+ }
+ };
+ const openEventInCalendar = async (event: CalendarEvent) => {
+ const params: CalendarBlockProps = {
+ eventId: event.eventId,
+ occurrenceKey: event.occurrenceKey,
+ range: range(),
+ };
+ const manager = globalSplitManager();
+ const existing = manager?.getSplitByContent('calendar', CALENDAR_BLOCK_ID);
+ if (existing) {
+ existing.activate();
+ } else {
+ layout.openWithSplit(
+ { type: 'calendar', id: CALENDAR_BLOCK_ID, params },
+ {
+ allowDuplicate: false,
+ mergeHistory: false,
+ referredFrom: 'sidebar',
+ }
+ );
+ }
+
+ const calendarHandle = await manager
+ ?.getOrchestrator()
+ .getBlockHandle(CALENDAR_BLOCK_ID, 'calendar');
+ await calendarHandle?.goToLocationFromParams(params);
+ };
+
+ return (
+ <div class="calendar-sidebar-preview portal-scope flex size-full min-h-0 flex-col bg-surface">
+ <div class="relative min-h-0 flex-1">
+ <CalendarEmbed
+ initialDate={initialDate}
+ events={data.visibleEvents()}
+ eventsById={data.eventsById()}
+ settings={{
+ initialView: 'timeGridDay',
+ dayCount: 1,
+ showDayHeaders: false,
+ collapseEmptyAllDaySlot: true,
+ showWeekends: true,
+ weekStartsOn: 0,
+ timeFormat: timeFormat(),
+ }}
+ selection={{
+ color: 'var(--color-accent)',
+ eventId: selectedEventId(),
+ onEventSelect: (event) => setSelectedEventId(event.id),
+ }}
+ onDatesSet={({ start, end }) => {
+ const nextRange = createCalendarOccurrenceQueryRange(start, end);
+ const previousRange = range();
+ if (
+ previousRange.start !== nextRange.start ||
+ previousRange.end !== nextRange.end ||
+ previousRange.startDate !== nextRange.startDate ||
+ previousRange.endDate !== nextRange.endDate
+ ) {
+ setRange(nextRange);
+ }
+ }}
+ >
+ {(grid) => (
+ <CalendarScrollElement
+ grid={grid}
+ setScrollElement={setScrollElement}
+ />
+ )}
+ </CalendarEmbed>
+ <ScrollIndicators
+ scrollRef={scrollElement}
+ appearance="gradient"
+ noBorderStart
+ noBorderEnd
+ />
+
+ <Layer depth={4}>
+ <div class="absolute right-2 bottom-2 z-anchored-controls flex items-center gap-2">
+ <Button
+ aria-label="New event"
+ label="New event"
+ tooltipPlacement="top"
+ variant="ghost"
+ size="icon-md"
+ depth={4}
+ class="rounded-lg bg-surface shadow-menu ring ring-edge-muted"
+ onClick={() => openEventComposer()}
+ >
+ <PlusIcon class="size-4" />
+ </Button>
+ <Dropdown placement="right" gutter={6}>
+ <Dropdown.Trigger
+ aria-label="Calendar settings"
+ label="Calendar settings"
+ tooltipPlacement="top"
+ variant="ghost"
+ size="icon-md"
+ depth={4}
+ class="rounded-lg bg-surface shadow-menu ring ring-edge-muted"
+ >
+ <GearIcon class="size-4" />
+ </Dropdown.Trigger>
+ <Dropdown.Content
+ mount={props.dropdownMount}
+ depth={4}
+ class="w-56"
+ >
+ <Dropdown.Group>
+ <Dropdown.Sub>
+ <Dropdown.SubTrigger>
+ <span class="min-w-0 flex-1 truncate">Calendars</span>
+ <CaretRightIcon class="size-3 shrink-0 text-ink-muted" />
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent
+ mount={props.dropdownMount}
+ depth={4}
+ class="max-h-52 w-56 overflow-y-auto"
+ >
+ <Dropdown.Group>
+ <For each={sources()}>
+ {(source) => (
+ <Dropdown.CheckboxItem
+ checked={isSourceVisible(source.id)}
+ closeOnSelect={false}
+ onChange={(visible) =>
+ setSourceVisibility(source.id, visible)
+ }
+ >
+ <span
+ aria-hidden="true"
+ class="size-2.5 shrink-0 rounded-sm"
+ style={{ 'background-color': source.color }}
+ />
+ <span class="min-w-0 flex-1 truncate">
+ {source.name}
+ </span>
+ </Dropdown.CheckboxItem>
+ )}
+ </For>
+ </Dropdown.Group>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+
+ <Dropdown.Sub>
+ <Dropdown.SubTrigger>
+ <span class="min-w-0 flex-1 truncate">Time format</span>
+ <span class="text-xs text-ink-muted">
+ {timeFormat() === '12-hour' ? '12-hour' : '24-hour'}
+ </span>
+ <CaretRightIcon class="size-3 shrink-0 text-ink-muted" />
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent
+ mount={props.dropdownMount}
+ depth={4}
+ class="min-w-36"
+ >
+ <Dropdown.Group>
+ <Dropdown.RadioGroup
+ value={timeFormat()}
+ onChange={(value) =>
+ setTimeFormat(value as CalendarTimeFormat)
+ }
+ >
+ <For each={PREVIEW_TIME_FORMAT_OPTIONS}>
+ {(option) => (
+ <Dropdown.RadioItem
+ closeOnSelect
+ value={option.value}
+ >
+ <span class="flex-1">{option.label}</span>
+ <Dropdown.ItemIndicator>
+ <CheckIcon class="size-3.5 text-accent" />
+ </Dropdown.ItemIndicator>
+ </Dropdown.RadioItem>
+ )}
+ </For>
+ </Dropdown.RadioGroup>
+ </Dropdown.Group>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ </div>
+ </Layer>
+
+ <Show when={data.isLoading()}>
+ <div class="absolute inset-0 bg-surface">
+ <PreviewSkeleton />
+ </div>
+ </Show>
+ <Show when={data.occurrencesQuery.isError}>
+ <div class="absolute inset-x-3 bottom-3 rounded-lg border border-edge-muted bg-surface p-2 text-center text-xs text-ink-muted shadow-menu">
+ Calendar events couldn’t be loaded.
+ </div>
+ </Show>
+ </div>
+
+ <Show when={selectedEvent()}>
+ {(event) => (
+ <Layer depth={3}>
+ <EventSummary
+ event={event()}
+ onClose={() => setSelectedEventId(undefined)}
+ onViewInCalendar={() => void openEventInCalendar(event())}
+ />
+ </Layer>
+ )}
+ </Show>
+ </div>
+ );
+}
+
+/** Calendar preview shown while hovering the Calendar sidebar row. */
+export function CalendarSidebarPreview(
+ props: ParentProps<{ disabled?: boolean }>
+) {
+ const [open, setOpen] = createSignal(false);
+ const [contentElement, setContentElement] = createSignal<HTMLElement>();
+
+ return (
+ <HoverCard
+ trigger={props.children}
+ triggerAs="div"
+ triggerClass="w-full"
+ triggerTabIndex={-1}
+ content={
+ <Surface
+ depth={2}
+ hideBorder
+ class="h-[min(24rem,calc(100vh-2rem))] w-[min(20rem,calc(100vw-2rem))] overflow-hidden rounded-xl shadow-menu ring ring-edge"
+ >
+ <div
+ class="size-full"
+ onContextMenu={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ >
+ <Show when={open() && !props.disabled}>
+ <Suspense fallback={<PreviewSkeleton />}>
+ <PreviewContent dropdownMount={contentElement()} />
+ </Suspense>
+ </Show>
+ </div>
+ </Surface>
+ }
+ contentClass="max-w-[calc(100vw-1rem)] menu-open-animation"
+ contentRef={setContentElement}
+ openDelay={300}
+ closeDelay={200}
+ disabled={props.disabled}
+ onOpenChange={setOpen}
+ placement="right-start"
+ requirePointerMovement
+ />
+ );
+}
diff --git a/apps/web/src/components/app/app-sidebar/sidebar.tsx b/apps/web/src/components/app/app-sidebar/sidebar.tsx
index 719c71c0db..7f100579c4 100644
--- a/apps/web/src/components/app/app-sidebar/sidebar.tsx
+++ b/apps/web/src/components/app/app-sidebar/sidebar.tsx
@@ -120,6 +120,7 @@ import {
Suspense,
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { CalendarSidebarPreview } from './calendar-sidebar-preview';
interface SidebarItem {
id: ListView | (string & {});
@@ -1781,7 +1782,7 @@ const SidebarOpenInSplitMenu = (props: SidebarOpenInSplitMenuProps) => {
);
};
-const SidebarLink = (props: SidebarLinkProps) => {
+const SidebarLinkRow = (props: SidebarLinkProps) => {
const [isHovering, setIsHovering] = createSignal(false);
const analytics = useAnalytics();
@@ -1810,171 +1811,185 @@ const SidebarLink = (props: SidebarLinkProps) => {
};
return (
- <SidebarOpenInSplitMenu
- content={content}
- onOpenChange={props.onContextMenuOpenChange}
- onOpened={(split, action) => {
- if (action === 'fullscreen' && props.id === 'search')
- requestSearchFocus(split.id);
- }}
- >
- <NavRow
- draggable={false}
- data-sidebar-link={props.id}
- data-active={isActive() ? '' : undefined}
- active={isActive() && !props.suppressActiveStyle}
- class="h-7"
- fullWidth
- tooltipPlacement="right"
- onMouseEnter={() => setIsHovering(true)}
- label={`Go to ${props.label}`}
- hotkey={
- props.standaloneHotkey
- ? props.hotkeyToken
- : [TOKENS.sidebar.goToLeader, props.hotkeyToken]
- }
- tooltipDisabled={props.sidebarState !== 'slim'}
- onMouseLeave={() => setIsHovering(false)}
- onMouseDown={(e) => {
- if (e.button !== 0) return;
- analytics.track('sidebar_click', {
- view: props.id,
- });
+ <NavRow
+ draggable={false}
+ data-sidebar-link={props.id}
+ data-active={isActive() ? '' : undefined}
+ active={isActive() && !props.suppressActiveStyle}
+ class="h-7"
+ fullWidth
+ tooltipPlacement="right"
+ onMouseEnter={() => setIsHovering(true)}
+ label={`Go to ${props.label}`}
+ hotkey={
+ props.standaloneHotkey
+ ? props.hotkeyToken
+ : [TOKENS.sidebar.goToLeader, props.hotkeyToken]
+ }
+ tooltipDisabled={props.sidebarState !== 'slim' || props.id === 'calendar'}
+ onMouseLeave={() => setIsHovering(false)}
+ onMouseDown={(e) => {
+ if (e.button !== 0) return;
+ analytics.track('sidebar_click', {
+ view: props.id,
+ });
- e.preventDefault();
- let currentContentHandle = globalSplitManager()?.activeSplit();
-
- const currentContent = currentContentHandle?.content();
- const expectedContent = content();
- const isSameContent =
- currentContent?.type === expectedContent.type &&
- currentContent.id === expectedContent.id;
-
- if (!isSameContent || e.shiftKey) {
- currentContentHandle = navigateToSidebarView({
- viewId: props.id,
- params: props.params,
- shiftKey: e.shiftKey,
- activeSplit: currentContentHandle,
- openWithSplit: layout.openWithSplit,
- referredFrom: 'sidebar',
- });
- } else {
- props.onActiveClick?.();
- }
+ e.preventDefault();
+ let currentContentHandle = globalSplitManager()?.activeSplit();
+
+ const currentContent = currentContentHandle?.content();
+ const expectedContent = content();
+ const isSameContent =
+ currentContent?.type === expectedContent.type &&
+ currentContent.id === expectedContent.id;
+
+ if (!isSameContent || e.shiftKey) {
+ currentContentHandle = navigateToSidebarView({
+ viewId: props.id,
+ params: props.params,
+ shiftKey: e.shiftKey,
+ activeSplit: currentContentHandle,
+ openWithSplit: layout.openWithSplit,
+ referredFrom: 'sidebar',
+ });
+ } else {
+ props.onActiveClick?.();
+ }
- if (props.id === 'search' && currentContentHandle) {
- requestSearchFocus(currentContentHandle.id);
- }
+ if (props.id === 'search' && currentContentHandle) {
+ requestSearchFocus(currentContentHandle.id);
+ }
- globalSplitManager()?.returnFocus();
- }}
- >
- <Show when={props.icon}>
- <div class="size-5 shrink-0 flex items-center justify-center [&_svg]:size-3.5">
- <Show
- when={
- isHovering() && props.sidebarState !== 'slim'
- ? props.removeAction
- : undefined
- }
- fallback={
- <Dynamic
- component={props.icon}
- triggerAnimation={isHovering()}
- />
- }
- >
- {(removeAction) => (
- <Tooltip
- label={removeAction().tooltip}
- as="span"
- placement="top"
- >
- <span
- role="button"
- tabIndex={0}
- aria-label={removeAction().tooltip}
- class="flex items-center justify-center text-ink-muted
+ globalSplitManager()?.returnFocus();
+ }}
+ >
+ <Show when={props.icon}>
+ <div class="size-5 shrink-0 flex items-center justify-center [&_svg]:size-3.5">
+ <Show
+ when={
+ isHovering() && props.sidebarState !== 'slim'
+ ? props.removeAction
+ : undefined
+ }
+ fallback={
+ <Dynamic component={props.icon} triggerAnimation={isHovering()} />
+ }
+ >
+ {(removeAction) => (
+ <Tooltip label={removeAction().tooltip} as="span" placement="top">
+ <span
+ role="button"
+ tabIndex={0}
+ aria-label={removeAction().tooltip}
+ class="flex items-center justify-center text-ink-muted
rounded-md hover:bg-failure hover:text-surface p-1"
- onMouseDown={(e) => {
- // The row navigates on mousedown; the X must not.
- e.stopPropagation();
+ onMouseDown={(e) => {
+ // The row navigates on mousedown; the X must not.
+ e.stopPropagation();
+ e.preventDefault();
+ }}
+ onClick={(e) => {
+ e.stopPropagation();
+ removeAction().onRemove();
+ }}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
- }}
- onClick={(e) => {
e.stopPropagation();
removeAction().onRemove();
- }}
- onKeyDown={(e) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault();
- e.stopPropagation();
- removeAction().onRemove();
- }
- }}
- >
- <XIcon />
- </span>
- </Tooltip>
- )}
- </Show>
- </div>
- </Show>
+ }
+ }}
+ >
+ <XIcon />
+ </span>
+ </Tooltip>
+ )}
+ </Show>
+ </div>
+ </Show>
- <div class="flex items-center gap-1 group-data-[slim=true]/sidebar:hidden">
- <span class="whitespace-nowrap">{props.label}</span>
+ <div class="flex items-center gap-1 group-data-[slim=true]/sidebar:hidden">
+ <span class="whitespace-nowrap">{props.label}</span>
+ </div>
+
+ <Show
+ when={
+ isActive() &&
+ props.trailingWhenActive !== undefined &&
+ !props.hotkeyVisible
+ }
+ >
+ <div class="group-data-[slim=true]/sidebar:hidden ml-auto flex items-center text-ink-muted">
+ {props.trailingWhenActive}
</div>
+ </Show>
- <Show
- when={
- isActive() &&
- props.trailingWhenActive !== undefined &&
- !props.hotkeyVisible
- }
- >
- <div class="group-data-[slim=true]/sidebar:hidden ml-auto flex items-center text-ink-muted">
- {props.trailingWhenActive}
+ <Show
+ when={
+ isHovering() &&
+ !props.hotkeyVisible &&
+ !(isActive() && props.trailingWhenActive !== undefined)
+ }
+ >
+ <div class="group-data-[slim=true]/sidebar:hidden ml-auto">
+ <div class="flex gap-1 items-center text-ink-extra-muted font-normal text-xxs">
+ <Show when={!props.standaloneHotkey}>
+ <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">
+ <Hotkey token={TOKENS.sidebar.goToLeader} />
+ </div>
+ <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">
+ <Hotkey token={props.hotkeyToken} />
+ </div>
+ </Show>
+ <Show when={props.standaloneHotkey}>
+ <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">
+ <Hotkey token={props.hotkeyToken} />
+ </div>
+ </Show>
</div>
- </Show>
-
- <Show
- when={
- isHovering() &&
- !props.hotkeyVisible &&
- !(isActive() && props.trailingWhenActive !== undefined)
- }
+ </div>
+ </Show>
+ <Show when={props.hotkeyVisible}>
+ <div
+ class={cn(
+ 'text-xs size-4 rounded-xs flex items-center justify-center overflow-hidden bg-accent/10 border border-accent/30 text-accent',
+ props.sidebarState === 'slim' && 'absolute -bottom-1 -right-1',
+ props.sidebarState !== 'slim' && 'relative p-1 ml-auto'
+ )}
>
- <div class="group-data-[slim=true]/sidebar:hidden ml-auto">
- <div class="flex gap-1 items-center text-ink-extra-muted font-normal text-xxs">
- <Show when={!props.standaloneHotkey}>
- <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">
- <Hotkey token={TOKENS.sidebar.goToLeader} />
- </div>
- <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">
- <Hotkey token={props.hotkeyToken} />
- </div>
- </Show>
- <Show when={props.standaloneHotkey}>
- <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">
- <Hotkey token={props.hotkeyToken} />
- </div>
- </Show>
- </div>
- </div>
- </Show>
- <Show when={props.hotkeyVisible}>
- <div
- class={cn(
- 'text-xs size-4 rounded-xs flex items-center justify-center overflow-hidden bg-accent/10 border border-accent/30 text-accent',
- props.sidebarState === 'slim' && 'absolute -bottom-1 -right-1',
- props.sidebarState !== 'slim' && 'relative p-1 ml-auto'
- )}
- >
- <Hotkey token={props.hotkeyToken} />
- </div>
- </Show>
- </NavRow>
+ <Hotkey token={props.hotkeyToken} />
+ </div>
+ </Show>
+ </NavRow>
+ );
+};
+
+const SidebarLink = (props: SidebarLinkProps) => {
+ const [contextMenuOpen, setContextMenuOpen] = createSignal(false);
+ const content = () => sidebarContent(props.id, props.params);
+ const handleContextMenuOpenChange = (open: boolean) => {
+ setContextMenuOpen(open);
+ // Keep the collapsed sidebar overlay mounted while its portaled menu is open.
+ props.onContextMenuOpenChange?.(open);
+ };
+
+ return (
+ <SidebarOpenInSplitMenu
+ content={content}
+ onOpenChange={handleContextMenuOpenChange}
+ onOpened={(split, action) => {
+ if (action === 'fullscreen' && props.id === 'search')
+ requestSearchFocus(split.id);
+ }}
+ >
+ <Show
+ when={props.id === 'calendar'}
+ fallback={<SidebarLinkRow {...props} />}
+ >
+ <CalendarSidebarPreview disabled={contextMenuOpen()}>
+ <SidebarLinkRow {...props} />
+ </CalendarSidebarPreview>
+ </Show>
</SidebarOpenInSplitMenu>
);
};
diff --git a/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx b/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
index 6948dbf37f..d0900bda77 100644
--- a/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
+++ b/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
@@ -47,6 +47,23 @@ function targetRequestFromParams(
};
}
+function isSameTargetRequest(
+ current: CalendarBlockTargetRequest | undefined,
+ next: CalendarBlockTargetRequest | undefined
+): boolean {
+ if (!current || !next) return current === next;
+ if (current.eventId !== next.eventId) return false;
+ if (current.occurrenceKey !== undefined || next.occurrenceKey !== undefined) {
+ return current.occurrenceKey === next.occurrenceKey;
+ }
+ return (
+ current.range.start === next.range.start &&
+ current.range.end === next.range.end &&
+ current.range.startDate === next.range.startDate &&
+ current.range.endDate === next.range.endDate
+ );
+}
+
/**
* A target with an event id but no usable range — a copied `/app/calendar`
* link or a mention without preview data — resolves through the calendar
@@ -141,7 +158,12 @@ function CalendarBlockAdapter(props: CalendarBlockProps) {
// Preview resolution is async, so a stale answer must never clobber a
// target the user has since re-aimed or cleared.
const applyResolvedTarget = (request: CalendarBlockTargetRequest) => {
- if (request.requestId < latestRequestId) return;
+ if (
+ request.requestId < latestRequestId ||
+ isSameTargetRequest(targetRequest(), request)
+ ) {
+ return;
+ }
setTargetRequest(request);
};
@@ -150,7 +172,7 @@ function CalendarBlockAdapter(props: CalendarBlockProps) {
latestRequestId = requestId;
const direct = targetRequestFromParams(params, requestId);
if (direct) {
- setTargetRequest(direct);
+ applyResolvedTarget(direct);
return;
}
if (typeof params.eventId === 'string' && params.eventId.length > 0) {
@@ -159,7 +181,7 @@ function CalendarBlockAdapter(props: CalendarBlockProps) {
});
return;
}
- setTargetRequest(undefined);
+ if (targetRequest() !== undefined) setTargetRequest(undefined);
};
if (
diff --git a/apps/web/src/features/block-calendar/components/Page.tsx b/apps/web/src/features/block-calendar/components/Page.tsx
index d35bbe69da..c7e0a582ff 100644
--- a/apps/web/src/features/block-calendar/components/Page.tsx
+++ b/apps/web/src/features/block-calendar/components/Page.tsx
@@ -1,8 +1,6 @@
import {
CalendarGrid,
type CalendarGridHandle,
- type CalendarGridSelection,
- type CalendarGridSettings,
} from '@app/features/calendar/components/CalendarGrid';
import {
type CalendarPageId,
@@ -301,46 +299,27 @@ export function Page(props: {
);
};
- const gridSettings: CalendarGridSettings = {
- get initialView() {
- return calendarView.displaySettings.periodView;
- },
- get showWeekends() {
- return calendarView.displaySettings.showWeekends;
- },
- get weekStartsOn() {
- return calendarView.displaySettings.weekStartsOn;
- },
- get timeFormat() {
- return calendarView.displaySettings.timeFormat;
- },
- get useNarrowDayHeaders() {
- return useNarrowWeekdayHeaders();
- },
- get useNarrowEventContent() {
- return props.useNarrowDayHeaders;
- },
- };
- const gridSelection: CalendarGridSelection = {
- get color() {
- return effectiveSelectionColor();
- },
- get eventId() {
- return isActive() ? calendarView.selectedEvent()?.id : undefined;
- },
- onDateSelect: handleSelect,
- onEventSelect: (event, element) => {
- if (isActive()) calendarView.selectEvent(event, element);
- },
- };
-
return (
<CalendarGrid
initialDate={props.initialDate}
events={data.visibleEvents()}
eventsById={data.eventsById()}
- settings={gridSettings}
- selection={gridSelection}
+ settings={{
+ initialView: calendarView.displaySettings.periodView,
+ showWeekends: calendarView.displaySettings.showWeekends,
+ weekStartsOn: calendarView.displaySettings.weekStartsOn,
+ timeFormat: calendarView.displaySettings.timeFormat,
+ useNarrowDayHeaders: useNarrowWeekdayHeaders(),
+ useNarrowEventContent: props.useNarrowDayHeaders,
+ }}
+ selection={{
+ color: effectiveSelectionColor(),
+ eventId: isActive() ? calendarView.selectedEvent()?.id : undefined,
+ onDateSelect: isMobile() ? undefined : handleSelect,
+ onEventSelect: (event, element) => {
+ if (isActive()) calendarView.selectEvent(event, element);
+ },
+ }}
eventTimeChangePending={updateEventTime.isPending}
onDatesSet={handleDatesSet}
onEventTimeChange={handleEventTimeChange}
diff --git a/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx b/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
index f5f65691b7..cd930185bc 100644
--- a/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
+++ b/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
@@ -349,12 +349,15 @@ function EventDetailsPopover(props: EventDetailsPopoverProps) {
<Popover.Content
class="portal-scope 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.
+ // FullCalendar and external calendar target controls select on
+ // click (pointer release), so dismissing on pointer down would
+ // briefly close the popover before navigation finishes.
const target = event.detail.originalEvent.target;
if (
target instanceof Element &&
- target.closest('.fc-event') !== null
+ (target.closest('.fc-event') !== null ||
+ target.closest('[data-calendar-event-target-navigation]') !==
+ null)
) {
event.preventDefault();
}
diff --git a/apps/web/src/features/calendar/calendar.css b/apps/web/src/features/calendar/calendar.css
index 9883bbe90f..8471678588 100644
--- a/apps/web/src/features/calendar/calendar.css
+++ b/apps/web/src/features/calendar/calendar.css
@@ -17,6 +17,10 @@
--fc-now-indicator-color: var(--color-accent);
}
+.calendar-sidebar-preview .calendar-view {
+ --fc-border-color: var(--color-edge);
+}
+
.calendar-view-content {
box-sizing: border-box;
padding: 0.5rem;
@@ -504,6 +508,42 @@
transform: translateY(-50%);
}
+.calendar-embed
+ .calendar-view
+ .fc.fc-direction-ltr
+ .fc-timegrid-slot-lane,
+.calendar-embed
+ .calendar-view
+ .fc.fc-direction-ltr
+ .fc-timegrid-axis
+ + .fc-timegrid-col {
+ border-left-width: 0;
+}
+
+.calendar-embed
+ .calendar-view
+ .fc.fc-direction-rtl
+ .fc-timegrid-slot-lane,
+.calendar-embed
+ .calendar-view
+ .fc.fc-direction-rtl
+ .fc-timegrid-axis
+ + .fc-timegrid-col {
+ border-right-width: 0;
+}
+
+.calendar-embed
+ .calendar-view
+ .fc
+ .fc-timegrid-slot-label:not(.fc-timegrid-slot-minor) {
+ border-top: 1px solid var(--fc-border-color);
+}
+
+.calendar-embed .calendar-view .fc .fc-timegrid-slot-label-cushion {
+ padding-top: 0.25rem;
+ transform: none;
+}
+
.calendar-view
.fc
.fc-timegrid-slots
@@ -513,6 +553,26 @@
visibility: hidden;
}
+.calendar-embed
+ .calendar-view
+ .fc
+ .fc-timegrid-slots
+ tbody
+ tr:first-child
+ .fc-timegrid-slot {
+ box-shadow: inset 0 1px var(--fc-border-color);
+}
+
+.calendar-embed
+ .calendar-view
+ .fc
+ .fc-timegrid-slots
+ tbody
+ tr:first-child
+ .fc-timegrid-slot-label-cushion {
+ visibility: visible;
+}
+
.calendar-view .fc .fc-timegrid-now-indicator-line {
--calendar-now-arrow-bottom: 50%;
--calendar-now-arrow-top: 50%;
diff --git a/apps/web/src/features/calendar/components/CalendarEmbed.tsx b/apps/web/src/features/calendar/components/CalendarEmbed.tsx
new file mode 100644
index 0000000000..0e47b71d8a
--- /dev/null
+++ b/apps/web/src/features/calendar/components/CalendarEmbed.tsx
@@ -0,0 +1,101 @@
+import { createResizeObserver } from '@solid-primitives/resize-observer';
+import { createSignal, type JSX, onCleanup } from 'solid-js';
+import type { CalendarEvent } from '../types';
+import { multiDayTimedDisplayRange } from '../utils/calendar-date';
+import {
+ CalendarGrid,
+ type CalendarGridHandle,
+ type CalendarGridProps,
+ type CalendarGridSettings,
+} from './CalendarGrid';
+
+const NARROW_CALENDAR_WIDTH = 520;
+
+/** Display settings owned by an embedded calendar's consumer. */
+export type CalendarEmbedSettings = Omit<
+ CalendarGridSettings,
+ 'showAllDaySlot' | 'useNarrowDayHeaders' | 'useNarrowEventContent'
+> & {
+ collapseEmptyAllDaySlot?: boolean;
+};
+
+export type CalendarEmbedProps = Omit<CalendarGridProps, 'settings'> & {
+ settings: CalendarEmbedSettings;
+};
+
+function rendersInAllDaySlot(event: CalendarEvent) {
+ return (
+ event.allDay ||
+ multiDayTimedDisplayRange(new Date(event.start), new Date(event.end)) !==
+ undefined
+ );
+}
+
+function CalendarEmbedHost(props: {
+ handle: CalendarGridHandle;
+ onWidthChange: (width: number) => void;
+ children?: (handle: CalendarGridHandle) => JSX.Element;
+}) {
+ let resizeFrame: number | undefined;
+
+ createResizeObserver(props.handle.element, ({ width }) => {
+ if (resizeFrame !== undefined) cancelAnimationFrame(resizeFrame);
+
+ resizeFrame = requestAnimationFrame(() => {
+ resizeFrame = undefined;
+ props.onWidthChange(width);
+ props.handle.api()?.updateSize();
+ });
+ });
+
+ onCleanup(() => {
+ if (resizeFrame !== undefined) cancelAnimationFrame(resizeFrame);
+ });
+
+ return <>{props.children?.(props.handle)}</>;
+}
+
+/**
+ * Query-free calendar renderer for bounded containers. Its consumer owns data,
+ * controls, selection behavior, and loading or error presentation.
+ */
+export function CalendarEmbed(props: CalendarEmbedProps) {
+ const [isNarrow, setIsNarrow] = createSignal(false);
+
+ return (
+ <div class="calendar-embed size-full min-h-0 min-w-0 overflow-hidden">
+ <CalendarGrid
+ initialDate={props.initialDate}
+ events={props.events}
+ eventsById={props.eventsById}
+ settings={{
+ initialView: props.settings.initialView,
+ dayCount: props.settings.dayCount,
+ showDayHeaders: props.settings.showDayHeaders,
+ showAllDaySlot:
+ !props.settings.collapseEmptyAllDaySlot ||
+ props.events.some(rendersInAllDaySlot),
+ showWeekends: props.settings.showWeekends,
+ weekStartsOn: props.settings.weekStartsOn,
+ timeFormat: props.settings.timeFormat,
+ useNarrowDayHeaders: isNarrow(),
+ useNarrowEventContent: isNarrow(),
+ }}
+ selection={props.selection}
+ eventTimeChangePending={props.eventTimeChangePending}
+ onDatesSet={props.onDatesSet}
+ onEventTimeChange={props.onEventTimeChange}
+ >
+ {(handle) => (
+ <CalendarEmbedHost
+ handle={handle}
+ onWidthChange={(width) =>
+ setIsNarrow(width < NARROW_CALENDAR_WIDTH)
+ }
+ children={props.children}
+ />
+ )}
+ </CalendarGrid>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/calendar/components/CalendarGrid.tsx b/apps/web/src/features/calendar/components/CalendarGrid.tsx
index c9927c1971..43cb092a6f 100644
--- a/apps/web/src/features/calendar/components/CalendarGrid.tsx
+++ b/apps/web/src/features/calendar/components/CalendarGrid.tsx
@@ -3,7 +3,6 @@ import {
type FullCalendarContextValue,
useFullCalendar,
} from '@app/lib/fullcalendar-solid';
-import { isMobile } from '@core/mobile/isMobile';
import type {
DateSelectArg,
DatesSetArg,
@@ -90,6 +89,10 @@ export interface CalendarGridHandle extends FullCalendarContextValue {
export interface CalendarGridSettings {
initialView: CalendarPeriodView;
+ /** Consecutive visible days for time-grid embeds. */
+ dayCount?: number;
+ showDayHeaders?: boolean;
+ showAllDaySlot?: boolean;
showWeekends: boolean;
weekStartsOn: CalendarWeekStart;
timeFormat: CalendarTimeFormat;
@@ -197,6 +200,14 @@ export function CalendarGrid(props: CalendarGridProps) {
]}
initialView={props.settings.initialView}
initialDate={props.initialDate}
+ dayCount={props.settings.dayCount}
+ dateIncrement={
+ props.settings.dayCount === undefined
+ ? undefined
+ : { days: props.settings.dayCount }
+ }
+ dayHeaders={props.settings.showDayHeaders ?? true}
+ allDaySlot={props.settings.showAllDaySlot ?? true}
height="100%"
expandRows
fixedWeekCount={false}
@@ -232,16 +243,23 @@ export function CalendarGrid(props: CalendarGridProps) {
eventByRenderId(calendarEventRenderId(change.event))
)
}
- selectable={props.selection.onDateSelect !== undefined && !isMobile()}
+ selectable={props.selection.onDateSelect !== undefined}
unselectAuto={false}
selectMirror
selectMinDistance={5}
select={(selection) => props.selection.onDateSelect?.(selection)}
- eventClick={({ el, event, jsEvent }) => {
- jsEvent.preventDefault();
- const selectedEvent = eventByRenderId(calendarEventRenderId(event));
- if (selectedEvent) props.selection.onEventSelect?.(selectedEvent, el);
- }}
+ eventClick={
+ props.selection.onEventSelect
+ ? ({ el, event, jsEvent }) => {
+ jsEvent.preventDefault();
+ const selectedEvent = eventByRenderId(
+ calendarEventRenderId(event)
+ );
+ if (selectedEvent)
+ props.selection.onEventSelect?.(selectedEvent, el);
+ }
+ : undefined
+ }
eventDidMount={({ el, event, isMirror }) => {
const eventId = calendarEventRenderId(event);
const calendarEvent = eventByRenderId(eventId);
@@ -281,12 +299,14 @@ export function CalendarGrid(props: CalendarGridProps) {
<FullCalendar.DayHeaderContent>
{({ date, text, view }) => {
if (view.type === 'timeGridWeek' || view.type === 'timeGridDay') {
- const weekday =
- view.type === 'timeGridDay'
- ? formatWeekdayHeader.short(date)
- : formatWeekdayHeader[
- props.settings.useNarrowDayHeaders ? 'narrow' : 'short'
- ](date);
+ const isSingleDayView =
+ view.type === 'timeGridDay' &&
+ (props.settings.dayCount ?? 1) === 1;
+ const weekday = isSingleDayView
+ ? formatWeekdayHeader.short(date)
+ : formatWeekdayHeader[
+ props.settings.useNarrowDayHeaders ? 'narrow' : 'short'
+ ](date);
return (
<>
diff --git a/apps/web/src/features/calendar/components/CalendarGridSkeleton.tsx b/apps/web/src/features/calendar/components/CalendarGridSkeleton.tsx
new file mode 100644
index 0000000000..9720529fd0
--- /dev/null
+++ b/apps/web/src/features/calendar/components/CalendarGridSkeleton.tsx
@@ -0,0 +1,110 @@
+import { For, Show } from 'solid-js';
+
+const SKELETON_TIME_ROWS = Array.from({ length: 12 });
+
+/** Rendering-only placeholder for a loading time-grid calendar. */
+export function CalendarGridSkeleton(props: {
+ dayCount?: number;
+ showDayHeader?: boolean;
+ showAllDaySlot?: boolean;
+}) {
+ const days = () =>
+ Array.from({
+ length: Math.max(1, Math.floor(props.dayCount ?? 1)),
+ });
+ const dayColumns = () => `3rem repeat(${days().length}, minmax(0, 1fr))`;
+
+ return (
+ <div
+ role="status"
+ aria-label="Loading calendar"
+ aria-busy="true"
+ class="flex size-full min-w-0 min-h-0 animate-pulse flex-col overflow-hidden bg-surface"
+ >
+ <span class="sr-only">Loading calendar</span>
+
+ <Show when={props.showDayHeader !== false}>
+ <div
+ class="grid shrink-0 border-b border-edge-muted"
+ style={{ 'grid-template-columns': dayColumns() }}
+ >
+ <div />
+ <For each={days()}>
+ {() => (
+ <div class="flex h-14 items-center justify-center border-l border-edge-muted">
+ <div class="flex flex-col items-center gap-2">
+ <div class="h-2 w-10 rounded-full bg-skeleton" />
+ <div class="size-6 rounded-full bg-skeleton" />
+ </div>
+ </div>
+ )}
+ </For>
+ </div>
+ </Show>
+
+ <Show when={props.showAllDaySlot !== false}>
+ <div
+ class="grid shrink-0 border-b border-edge-muted"
+ style={{ 'grid-template-columns': dayColumns() }}
+ >
+ <div class="flex h-8 items-center justify-end pr-2">
+ <div class="h-2 w-7 rounded-full bg-skeleton" />
+ </div>
+ <For each={days()}>
+ {() => (
+ <div class="h-8 border-l border-edge-muted px-1 py-2">
+ <div class="h-full w-1/3 rounded bg-skeleton" />
+ </div>
+ )}
+ </For>
+ </div>
+ </Show>
+
+ <div class="flex min-h-0 flex-1 overflow-hidden">
+ <div class="flex w-12 shrink-0 flex-col">
+ <For each={SKELETON_TIME_ROWS}>
+ {(_, index) => (
+ <div class="relative min-h-8 flex-1 border-t border-edge-muted first:border-t-0">
+ <div
+ class="absolute top-0 right-2 h-1.5 rounded-full bg-skeleton"
+ classList={{
+ 'w-5': index() % 2 === 0,
+ 'w-7': index() % 2 !== 0,
+ }}
+ />
+ </div>
+ )}
+ </For>
+ </div>
+
+ <div
+ class="grid min-w-0 flex-1"
+ style={{
+ 'grid-template-columns': `repeat(${days().length}, minmax(0, 1fr))`,
+ }}
+ >
+ <For each={days()}>
+ {(_, dayIndex) => (
+ <div class="relative flex min-w-0 flex-col border-l border-edge-muted">
+ <For each={SKELETON_TIME_ROWS}>
+ {() => (
+ <div class="min-h-8 flex-1 border-t border-edge-muted first:border-t-0" />
+ )}
+ </For>
+
+ <div
+ class="absolute inset-x-1 top-[18%] h-[14%] rounded-md bg-skeleton"
+ classList={{ hidden: dayIndex() % 2 !== 0 }}
+ />
+ <div
+ class="absolute inset-x-1 top-[54%] h-[9%] rounded-md bg-skeleton"
+ classList={{ hidden: days().length > 1 || dayIndex() !== 0 }}
+ />
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/lib/core/component/HoverCard.tsx b/apps/web/src/lib/core/component/HoverCard.tsx
index c8ae5e77f9..362231ad92 100644
--- a/apps/web/src/lib/core/component/HoverCard.tsx
+++ b/apps/web/src/lib/core/component/HoverCard.tsx
@@ -42,6 +42,8 @@ type HoverCardComponentProps = {
gutter?: number;
/** Additional class for content */
contentClass?: string;
+ /** Receives the underlying Kobalte content element. */
+ contentRef?: (element: HTMLElement) => void;
/** Semantic z-index class for the portaled content. Defaults to `z-tool-tip`. */
contentZIndexClass?: string;
/**
@@ -222,6 +224,7 @@ export function HoverCard(props: HoverCardComponentProps) {
<KobalteHoverCard.Content
ref={(el) => {
contentEl = el;
+ props.contentRef?.(el);
}}
class={cn(
props.contentZIndexClass ?? 'z-tool-tip',