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): streamline the responsive toolbar (#7262)

dev-rbf80c46d96c40
diff --git a/apps/web/src/features/calendar-view/components/CalendarSearch.tsx b/apps/web/src/features/calendar-view/components/CalendarSearch.tsx
index 7783090fbc..308546c7fd 100644
--- a/apps/web/src/features/calendar-view/components/CalendarSearch.tsx
+++ b/apps/web/src/features/calendar-view/components/CalendarSearch.tsx
@@ -310,6 +310,7 @@ export function CalendarSearch(
inline?: boolean;
compact?: boolean;
expanded?: boolean;
+ popupReady?: boolean;
onExpand?: () => void;
onDismiss?: () => void;
onOpenChange?: (open: boolean) => void;
@@ -322,6 +323,7 @@ export function CalendarSearch(
inline={props.inline}
compact={props.compact}
expanded={props.expanded}
+ popupReady={props.popupReady}
onExpand={props.onExpand}
onDismiss={props.onDismiss}
onOpenChange={props.onOpenChange}
@@ -334,6 +336,7 @@ function CalendarSearchControl(props: {
inline?: boolean;
compact?: boolean;
expanded?: boolean;
+ popupReady?: boolean;
onExpand?: () => void;
onDismiss?: () => void;
onOpenChange?: (open: boolean) => void;
@@ -345,10 +348,21 @@ function CalendarSearchControl(props: {
const setOpen = (next: boolean) => {
setOpenInternal(next);
props.onOpenChange?.(next);
+ if (!next) {
+ setActiveRow(0);
+ setPreviewTarget(null);
+ props.onDismiss?.();
+ }
};
const [rawQuery, setRawQuery] = createSignal('');
const [filters, setFilters] = createSignal(DEFAULT_CALENDAR_SEARCH_FILTERS);
let inputRef: HTMLInputElement | undefined;
+ let searchButton: HTMLButtonElement | undefined;
+ const dismissSearch = () => {
+ inputRef?.blur();
+ setOpen(false);
+ if (props.onDismiss) queueMicrotask(() => searchButton?.focus());
+ };
let listRef: HTMLDivElement | undefined;
const [activeRow, setActiveRow] = createSignal(0);
// Set to the chosen result when it falls outside the navigable range: the
@@ -357,6 +371,8 @@ function CalendarSearchControl(props: {
createSignal<CalendarSearchResult | null>(null);
const query = createMemo(() => rawQuery().trim());
+ const popupVisible = () =>
+ props.popupReady !== false && (!props.inline || query().length > 0);
const debouncedQuery = debouncedDependent(query, 250);
const searchQuery = useSearchSoupQuery(
@@ -646,13 +662,7 @@ function CalendarSearchControl(props: {
return (
<Popover
open={open()}
- onOpenChange={(next) => {
- setOpen(next);
- if (!next) {
- setActiveRow(0);
- setPreviewTarget(null);
- }
- }}
+ onOpenChange={setOpen}
placement={props.inline ? 'bottom-start' : 'bottom-end'}
gutter={6}
flip
@@ -671,32 +681,48 @@ function CalendarSearchControl(props: {
</Popover.Trigger>
}
>
- <div class="min-w-0 max-w-md flex-1">
- <Popover.Anchor as="div" class="w-full">
- <SearchBar
- ref={(element) => (inputRef = element)}
- label="Search events"
- onClose={
- props.onDismiss
- ? () => {
- inputRef?.blur();
- props.onDismiss?.();
- }
- : undefined
- }
- value={rawQuery()}
- onValueChange={changeQuery}
- actions={filterActions()}
- onClick={() => setOpen(true)}
- onFocus={() => setOpen(true)}
- onKeyDown={handleSearchKeyDown}
- onEscape={() => {
- setOpen(false);
- props.onDismiss?.();
+ <div class="relative h-10 min-w-0 w-full flex-1">
+ <Popover.Anchor as="div" class="h-10 w-full">
+ <Show when={props.expanded === false}>
+ <Button
+ ref={searchButton}
+ type="button"
+ variant="ghost"
+ size="icon-lg"
+ label="Search events"
+ hotkey={TOKENS.calendar.search}
+ aria-expanded="false"
+ aria-haspopup="dialog"
+ onClick={props.onExpand}
+ >
+ <SearchIcon class="size-5" />
+ </Button>
+ </Show>
+ {/* Keep the input mounted while its width animates; inert removes collapsed controls from keyboard navigation. */}
+ <div
+ aria-hidden={props.expanded === false}
+ inert={props.expanded === false}
+ class="absolute inset-x-0 top-0 overflow-hidden rounded-full transition-opacity duration-150 motion-reduce:transition-none"
+ classList={{
+ 'pointer-events-none opacity-0': props.expanded === false,
}}
- hotkey="cmd+f"
- placeholder="Search events"
- />
+ >
+ <SearchBar
+ ref={(element) => (inputRef = element)}
+ label="Search events"
+ class="has-[input:focus-visible]:ring-inset"
+ onClose={props.onDismiss ? dismissSearch : undefined}
+ value={rawQuery()}
+ onValueChange={changeQuery}
+ actions={filterActions()}
+ onClick={() => setOpen(true)}
+ onFocus={() => setOpen(true)}
+ onKeyDown={handleSearchKeyDown}
+ onEscape={dismissSearch}
+ hotkey="cmd+f"
+ placeholder="Search events"
+ />
+ </div>
</Popover.Anchor>
</div>
</Show>
@@ -704,7 +730,12 @@ function CalendarSearchControl(props: {
<Popover.Portal>
<Layer depth={3}>
<Popover.Content
- class="portal-scope z-modal outline-none"
+ class="portal-scope z-modal outline-none transition-opacity duration-200 ease-out motion-reduce:transition-none"
+ classList={{
+ 'pointer-events-none opacity-0': !popupVisible(),
+ }}
+ aria-hidden={!popupVisible() ? true : undefined}
+ inert={!popupVisible()}
onOpenAutoFocus={(event) => {
event.preventDefault();
if (!props.inline) inputRef?.focus();
@@ -712,6 +743,11 @@ function CalendarSearchControl(props: {
onCloseAutoFocus={(event) => {
if (props.inline) event.preventDefault();
}}
+ onEscapeKeyDown={(event) => {
+ if (!props.inline) return;
+ event.preventDefault();
+ dismissSearch();
+ }}
onKeyDown={handleContentKeyDown}
onInteractOutside={(event) => {
const target = event.detail.originalEvent.target;
@@ -721,6 +757,16 @@ function CalendarSearchControl(props: {
) {
event.preventDefault();
}
+ // The header dismisses after a period control's click. Collapsing
+ // on pointerdown can move that control before mouseup and lose the click.
+ if (
+ props.inline &&
+ target instanceof Element &&
+ target.closest('[data-calendar-period-controls]') &&
+ inputRef?.closest('[data-view-shell-top-bar]')?.contains(target)
+ ) {
+ event.preventDefault();
+ }
if (
props.inline &&
target instanceof Node &&
@@ -732,9 +778,12 @@ function CalendarSearchControl(props: {
>
<div
class={cn(
- 'max-w-[calc(100vw-2rem)] overflow-hidden rounded-xl glass bg-menu-glass text-ink',
+ 'max-w-[calc(100vw-2rem)] overflow-hidden rounded-xl glass bg-menu-glass text-ink transition-[translate] duration-200 ease-out motion-reduce:transition-none',
props.inline ? 'w-[var(--kb-popper-anchor-width)]' : 'w-80'
)}
+ classList={{
+ '-translate-y-1': !popupVisible(),
+ }}
>
<Show
when={previewTarget()}
diff --git a/apps/web/src/features/calendar-view/components/Header.tsx b/apps/web/src/features/calendar-view/components/Header.tsx
index 340651675e..72a588d105 100644
--- a/apps/web/src/features/calendar-view/components/Header.tsx
+++ b/apps/web/src/features/calendar-view/components/Header.tsx
@@ -87,18 +87,60 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
const calendarView = useCalendarView();
const initialDate = new Date();
const [headerElement, setHeaderElement] = createSignal<HTMLElement>();
- const headerSize = createElementSize(headerElement);
- // The shell width includes the sidebar; use the header's own main-pane width.
- const breakpoints = createSizeBreakpoints(() => headerSize.width ?? 0, {
- fullHeader: { min: 520 },
- periodControls: { min: 460 },
- navigationArrows: { min: 260 },
- });
+ const paneSize = createElementSize(() =>
+ headerElement()?.closest<HTMLElement>('[data-view-shell-main]')
+ );
+ // Measure the parent pane so toolbar content cannot affect its own breakpoint.
+ // A docked sidebar owns New and hides the navigation toggle, so its toolbar
+ // fits sooner. Avoid wrapping just before the sidebar collapses and unwraps it.
+ const hasDockedSidebar = () =>
+ !!shell && !shell.aside.isCollapsed() && !shell.aside.isOverlay();
+ const breakpoints = createSizeBreakpoints(
+ () => paneSize.width ?? 0,
+ () => ({
+ fullHeader: { min: hasDockedSidebar() ? 480 : 600 },
+ inlineSearch: { min: 1040 },
+ labeledNew: { min: 360 },
+ labeledToday: { min: 304 },
+ })
+ );
const isCompactHeader = () => !breakpoints.fullHeader();
- const showPeriodControls = breakpoints.periodControls;
- const showNavigationArrows = breakpoints.navigationArrows;
+ const searchOverlaysTitle = () => !breakpoints.inlineSearch();
const today = createLocalToday();
- const [narrowSearchOpen, setNarrowSearchOpen] = createSignal(false);
+ const [searchExpanded, setSearchExpandedInternal] = createSignal(false);
+ const [searchPopupReady, setSearchPopupReady] = createSignal(false);
+ let searchExpansionTimer: number | undefined;
+ const clearSearchExpansionTimer = () => {
+ if (searchExpansionTimer !== undefined) {
+ clearTimeout(searchExpansionTimer);
+ searchExpansionTimer = undefined;
+ }
+ };
+ const finishSearchExpansion = () => {
+ clearSearchExpansionTimer();
+ setSearchPopupReady(searchExpanded());
+ };
+ const setSearchExpanded = (expanded: boolean) => {
+ clearSearchExpansionTimer();
+ setSearchPopupReady(false);
+ setSearchExpandedInternal(expanded);
+ if (!expanded) return;
+ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
+ finishSearchExpansion();
+ return;
+ }
+ // Let the popup fade in as the 200ms width transition settles.
+ searchExpansionTimer = window.setTimeout(finishSearchExpansion, 140);
+ };
+ const handleSearchTransitionEnd = (event: TransitionEvent) => {
+ if (
+ event.target === event.currentTarget &&
+ event.propertyName === 'width'
+ ) {
+ finishSearchExpansion();
+ }
+ };
+ onCleanup(clearSearchExpansionTimer);
useCalendarHotkeys({
scopeId: panel.splitHotkeyScope,
changeView: calendarPager.changeView,
@@ -118,10 +160,6 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
const showHeaderCreate = () =>
isCompactHeader() ||
(shell?.aside.isCollapsed() && !shell?.aside.isOverlay());
- const showDesktopNavigation = () => {
- if (!showNavigationArrows()) return false;
- return !isCompactHeader() || !narrowSearchOpen();
- };
const usesSplitHeader = () =>
props.presentation === 'preview' || isTouchDevice();
const createItems = () => (
@@ -133,13 +171,20 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
);
const headerCreateMenu = () => (
<CalendarCreateMenu
- size="md"
- class="h-(--sidebar-row-height) gap-(--sidebar-label-gap) rounded-full px-(--sidebar-item-inset) touch:h-11"
+ size={breakpoints.labeledNew() ? 'md' : 'icon-md'}
+ label="New"
+ class={cn(
+ 'shrink-0 rounded-full touch:h-11',
+ breakpoints.labeledNew() &&
+ 'h-(--sidebar-row-height) gap-(--sidebar-label-gap) px-(--sidebar-item-inset)'
+ )}
trigger={
<>
<PlusIcon class="size-3.5" />
- <span>New</span>
- <CaretDownIcon class="size-3.5 shrink-0" />
+ <Show when={breakpoints.labeledNew()}>
+ <span>New</span>
+ <CaretDownIcon class="size-3.5 shrink-0" />
+ </Show>
</>
}
>
@@ -240,7 +285,9 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
<Show when={isMobile() && props.presentation === 'workspace'}>
<CopyAvailabilityButton size="icon-lg" />
</Show>
- <CalendarSearch />
+ <Show when={!isMobile()}>
+ <CalendarSearch />
+ </Show>
<Show when={props.presentation === 'preview' || isMobile()}>
<CalendarSettingsDropdown isNarrow={isNarrow()} />
</Show>
@@ -249,37 +296,82 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
</SplitHeaderRight>
</Match>
<Match when={!usesSplitHeader()}>
- <ViewShell.TopBar class="py-2">
- <h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink">
- {dateTitle()}
- </h1>
- <Show when={showHeaderCreate()}>
- <div class="ml-auto flex shrink-0 items-center gap-1">
- {headerCreateMenu()}
- </div>
- </Show>
- </ViewShell.TopBar>
- <ViewShell.Header ref={setHeaderElement}>
- <div class="flex h-10 min-w-0 items-center gap-2">
- <div class="min-w-0 max-w-md flex-1">
- <CalendarSearch
- inline
- compact={isCompactHeader()}
- onOpenChange={setNarrowSearchOpen}
- />
+ <ViewShell.TopBar
+ ref={setHeaderElement}
+ class="@container/calendar-toolbar h-auto min-h-12 flex-wrap gap-x-2 gap-y-2 py-2"
+ >
+ <div class="relative flex min-w-0 flex-1 items-center gap-2">
+ <h1
+ class="min-w-0 truncate text-[clamp(1rem,calc(0.75rem+1cqw),1.5rem)] font-semibold leading-tight tracking-[-0.03em] text-ink transition-opacity duration-150 motion-reduce:transition-none"
+ classList={{
+ 'opacity-0': searchOverlaysTitle() && searchExpanded(),
+ }}
+ >
+ {dateTitle()}
+ </h1>
+ <div
+ onTransitionEnd={handleSearchTransitionEnd}
+ class={cn(
+ 'ml-auto h-10 shrink-0',
+ searchOverlaysTitle()
+ ? 'w-10'
+ : 'transition-[width] duration-200 ease-out motion-reduce:transition-none'
+ )}
+ style={
+ searchOverlaysTitle()
+ ? undefined
+ : {
+ width: searchExpanded()
+ ? 'clamp(22rem, 40cqw, 28rem)'
+ : '2.5rem',
+ }
+ }
+ >
+ <div
+ onTransitionEnd={handleSearchTransitionEnd}
+ class={cn(
+ 'h-10',
+ searchOverlaysTitle() &&
+ 'absolute right-0 top-0 transition-[width] duration-200 ease-out motion-reduce:transition-none'
+ )}
+ style={
+ searchOverlaysTitle()
+ ? {
+ width: searchExpanded() ? 'min(100%, 28rem)' : '2.5rem',
+ }
+ : undefined
+ }
+ >
+ <CalendarSearch
+ inline
+ compact={searchOverlaysTitle()}
+ expanded={searchExpanded()}
+ popupReady={searchPopupReady()}
+ onExpand={() => setSearchExpanded(true)}
+ onDismiss={() => setSearchExpanded(false)}
+ />
+ </div>
</div>
- <Show when={showDesktopNavigation()}>
- <div class="ml-auto flex shrink-0 items-center gap-1">
- <Show when={showPeriodControls()}>
- {todayButton(false)}
- <PeriodSelector isNarrow={isNarrow()} />
- </Show>
- {previous()}
- {next()}
+ </div>
+ <div
+ class={cn(
+ 'flex shrink-0 items-center justify-end gap-1',
+ isCompactHeader() ? 'basis-full' : 'ml-4'
+ )}
+ data-calendar-period-controls=""
+ onClick={() => setSearchExpanded(false)}
+ >
+ <Show when={showHeaderCreate()}>
+ <div classList={{ 'mr-auto': isCompactHeader() }}>
+ {headerCreateMenu()}
</div>
</Show>
+ {todayButton(!breakpoints.labeledToday())}
+ <PeriodSelector isNarrow={isNarrow()} />
+ {previous()}
+ {next()}
</div>
- </ViewShell.Header>
+ </ViewShell.TopBar>
</Match>
</Switch>
);
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index ffa7ac5287..270f5bc403 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -922,22 +922,30 @@ Reminder. Inline Calendar previews retain their host's chrome without adding
another sidebar; their left header island has a compact New menu because the
bottom New action follows the foreground host view.
-The in-view desktop Calendar header follows Drive's two-level layout: the slim
-top bar shows the viewed month and year and, when the sidebar is closed, a
-compact `New` menu. At wide widths, the row beneath puts `Search events` on
-the left and a labeled `Today` button followed by the rounded period selector
-and previous/next arrows on the right. The idle search field places its hotkey
-beside the placeholder. A query reveals the icon-only Exact-match toggle at
-wide widths; in narrow splits, Exact and Filters appear after focusing search.
-The filter button stays before Clear. The filter menu opens below the button,
-aligned to its right edge: Search in is single-select, while Status, Organizer,
-and Attendee allow multiple values. Organizer and Attendee virtualize their
-contact lists; selected contacts stay in place, while custom email addresses
-appear first. Adding a valid email clears the contact search. Filter selections
-apply immediately, and only these filters mark the filter button, not Exact
-mode. Clicking search opens a calendar-search hint until at least three
-characters are entered; searches show skeleton rows while loading. Empty
-results show an illustrated empty state. Result titles show a calendar-color
+The in-view desktop Calendar header uses one responsive top bar. The viewed
+month and year stay on the left in a heading that scales from 16px in narrow
+splits to a maximum of 24px, with a compact `New` menu when the sidebar is closed.
+An icon-only ghost `Search events` button sits on the right, before a slightly
+larger gap and the `Today`, period selector, and previous/next controls.
+Click Search or press Cmd/Ctrl+F to expand and focus the wider inline search field.
+The field slides out with a short width transition and focuses immediately.
+The results popup stays hidden until the field contains non-whitespace text,
+then fades and slides in once expansion is nearly complete. Clearing the field
+hides the popup without collapsing search. Reduced-motion preferences skip
+both transitions.
+Close search, Escape, selecting a result, or clicking outside collapses it back
+to the icon without clearing the query. Activating a period control also
+collapses search after the action runs. Escape and Close restore focus to the
+Search button. The expanded field exposes Filters and, after typing, the
+icon-only Exact-match toggle. The filter button stays before Close. The filter
+menu opens below the button, aligned to its right edge: Search in is
+single-select, while Status, Organizer, and Attendee allow multiple values.
+Organizer and Attendee virtualize their contact lists; selected contacts stay
+in place, while custom email addresses appear first. Adding a valid email clears
+the contact search. Filter selections apply immediately, and only these filters
+mark the filter button, not Exact mode. Search opens a calendar-search hint
+until at least three characters are entered; searches show skeleton rows while
+loading. Empty results show an illustrated empty state. Result titles show a calendar-color
swatch when the event is loaded in the visible range, falling back to the
default calendar color otherwise. A result shows its location after the
date/time when available. Each result offers at most one rounded Join action:
@@ -951,14 +959,19 @@ occurrence details before showing Join. Selecting a result preserves the search
text. Availability lives in the desktop sidebar's Upcoming events section and
in the mobile header.
-Resizing the split keeps the same search field mounted in the fixed-height
-header row. At narrow widths the row hides `Today` and the period selector,
-then the navigation arrows when space becomes scarce; focusing search also
-hides the remaining controls to give the field room. Its clear button remains
-available when a query is present. The `New` menu stays in the desktop top
-bar. Touch devices keep the month selector and header controls without separate
-create or call buttons in the right island. The desktop sidebar's mini
-calendar remains navigable by date and month.
+The period controls move into a separate row below 600px of calendar-pane width,
+with `New` on the left and navigation on the right. With a docked sidebar, the
+header needs fewer controls and stays inline down to 480px. This avoids wrapping
+and immediately unwrapping when the sidebar hides. Expanded search does not
+force early wrapping; its results popup stays directly below the search field.
+Below 1040px, search slides over the month title without moving any controls or
+changing the header height. `New` stays outside the search overlay. Resizing the
+pane keeps the search field mounted and preserves its query and focus. Today
+and New retain their text labels until the controls row runs out of room, then
+become icon buttons.
+Touch devices keep the month selector and header controls without separate
+create or call buttons in the right island. Mobile header islands omit Search.
+The desktop sidebar's mini calendar remains navigable by date and month.
Active Quick Calls you created, participated in, or were invited to appear above your
next five events (including ones in progress), whether or not they have call links.