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.

fix(calendar): use dropdown for month picker on desktop (#8405)

Jacob Beckerman307bad431d3e
diff --git a/apps/web/src/features/calendar/components/MonthDrawer.tsx b/apps/web/src/features/calendar/components/MonthDrawer.tsx
index 73e8447fd0..74c851ac20 100644
--- a/apps/web/src/features/calendar/components/MonthDrawer.tsx
+++ b/apps/web/src/features/calendar/components/MonthDrawer.tsx
@@ -1,14 +1,15 @@
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import CaretDownIcon from '@phosphor/caret-down.svg';
-import { Button, CalendarMonthMenu, formatCalendarMonth } from '@ui';
-import { createSignal } from 'solid-js';
+import { Button, CalendarMonthMenu, Dropdown, formatCalendarMonth } from '@ui';
+import { createSignal, Match, Switch } from 'solid-js';
import { useCalendarPager } from './CalendarPagerContext';
type MonthDrawerProps = {
month: Date;
};
-/** Drawer presentation for navigating the calendar to a month. */
+/** Month selector that uses a dropdown on desktop and a drawer on touch. */
export function MonthDrawer(props: MonthDrawerProps) {
const calendarPager = useCalendarPager();
const [open, setOpen] = createSignal(false);
@@ -23,37 +24,65 @@ export function MonthDrawer(props: MonthDrawerProps) {
calendarPager.navigateToToday();
};
+ const triggerContent = () => (
+ <>
+ <span class="min-w-0 truncate">{formatCalendarMonth(props.month)}</span>
+ <CaretDownIcon class="size-3 shrink-0 text-ink-muted" />
+ </>
+ );
+
return (
- <MobileDrawer
- side="bottom"
- open={open()}
- onOpenChange={setOpen}
- preventScroll={false}
- preventScrollbarShift={false}
- >
- <MobileDrawer.Trigger
- as={Button}
- aria-label="Choose month"
- class="max-w-full min-w-0 shrink justify-start gap-1 rounded-full border-none bg-transparent px-1 text-base font-semibold text-ink not-touch:hover:bg-hover"
- >
- <span class="min-w-0 truncate">{formatCalendarMonth(props.month)}</span>
- <CaretDownIcon class="size-3 shrink-0 text-ink-muted" />
- </MobileDrawer.Trigger>
-
- <MobileDrawer.Portal>
- <MobileDrawer.Overlay />
- <MobileDrawer.Content aria-label="Choose month">
- <MobileDrawer.Handle />
- <MobileDrawer.Section class="mb-3 overflow-visible">
+ <Switch>
+ <Match when={isTouchDevice()}>
+ <MobileDrawer
+ side="bottom"
+ open={open()}
+ onOpenChange={setOpen}
+ preventScroll={false}
+ preventScrollbarShift={false}
+ >
+ <MobileDrawer.Trigger
+ as={Button}
+ aria-label="Choose month"
+ class="max-w-full min-w-0 shrink justify-start gap-1 rounded-full border-none bg-transparent px-1 text-base font-semibold text-ink not-touch:hover:bg-hover"
+ >
+ {triggerContent()}
+ </MobileDrawer.Trigger>
+
+ <MobileDrawer.Portal>
+ <MobileDrawer.Overlay />
+ <MobileDrawer.Content aria-label="Choose month">
+ <MobileDrawer.Handle />
+ <MobileDrawer.Section class="mb-3 overflow-visible">
+ <CalendarMonthMenu
+ month={props.month}
+ presentation="radio-group"
+ onChange={selectMonth}
+ onToday={goToToday}
+ />
+ </MobileDrawer.Section>
+ </MobileDrawer.Content>
+ </MobileDrawer.Portal>
+ </MobileDrawer>
+ </Match>
+
+ <Match when={!isTouchDevice()}>
+ <Dropdown open={open()} onOpenChange={setOpen} placement="bottom-start">
+ <Dropdown.Trigger
+ aria-label="Choose month"
+ class="max-w-full min-w-0 shrink justify-start gap-1 rounded-full border-none bg-transparent px-1 text-base font-semibold text-ink hover:bg-hover"
+ >
+ {triggerContent()}
+ </Dropdown.Trigger>
+ <Dropdown.Content class="min-w-40 p-1">
<CalendarMonthMenu
month={props.month}
- presentation="radio-group"
onChange={selectMonth}
onToday={goToToday}
/>
- </MobileDrawer.Section>
- </MobileDrawer.Content>
- </MobileDrawer.Portal>
- </MobileDrawer>
+ </Dropdown.Content>
+ </Dropdown>
+ </Match>
+ </Switch>
);
}