Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
/**
* The floating bar at the bottom of the canvas: undo and redo with the
* save state when editing, and the zoom menu with the view toggles.
* Presentational.
*/
import ArrowUUpLeft from '@icon/system/regular/arrow-u-up-left.svg';
import ArrowUUpRight from '@icon/system/regular/arrow-u-up-right.svg';
import CaretDown from '@icon/system/regular/caret-down.svg';
import CloudArrowUp from '@icon/system/regular/cloud-arrow-up.svg';
import CloudCheck from '@icon/system/regular/cloud-check.svg';
import WarningCircle from '@icon/system/regular/warning-circle.svg';
import { Button } from '@ui/components/Button';
import { createSignal, For, onCleanup, Show } from 'solid-js';
import { match } from 'ts-pattern';
import type { SaveState } from '../core/save-state';
export interface MenuItem {
label: string;
shortcut?: string;
checked?: boolean;
onSelect: () => void;
testId?: string;
}
/** A menu's items, with dividers between groups. */
export function MenuItems(props: {
items: (MenuItem | 'divider')[];
onDone: () => void;
}) {
return (
<For each={props.items}>
{(item) =>
item === 'divider' ? (
<div class="my-1 h-px bg-edge-muted" />
) : (
<button
type="button"
role={item.checked === undefined ? 'menuitem' : 'menuitemcheckbox'}
aria-checked={item.checked}
data-testid={item.testId}
class="flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-ink hover:bg-hover"
onClick={() => {
item.onSelect();
props.onDone();
}}
>
<span class="w-3 text-accent">{item.checked ? '✓' : ''}</span>
<span class="flex-1">{item.label}</span>
<Show when={item.shortcut}>
<span class="text-ink-muted">{item.shortcut}</span>
</Show>
</button>
)
}
</For>
);
}
export function StatusBar(props: {
editable: boolean;
saveState: SaveState;
canUndo: boolean;
canRedo: boolean;
onUndo: () => void;
onRedo: () => void;
zoomLabel: string;
zoomItems: (MenuItem | 'divider')[];
mac: boolean;
}) {
const [open, setOpen] = createSignal(false);
let menu!: HTMLDivElement;
const onDocumentDown = (e: PointerEvent) => {
if (!menu.contains(e.target as Node)) setOpen(false);
};
document.addEventListener('pointerdown', onDocumentDown);
onCleanup(() => document.removeEventListener('pointerdown', onDocumentDown));
const mod = () => (props.mac ? '⌘' : 'Ctrl+');
return (
<div
class="menu-surface -translate-x-1/2 absolute bottom-3 left-1/2 z-10 flex items-center gap-0.5 p-1"
data-testid="ai-status-bar"
onPointerDown={(e) => e.stopPropagation()}
>
<Show when={props.editable}>
<Button
aria-label="Undo"
variant="ghost"
size="icon-md"
tooltip={`Undo · ${mod()}Z`}
disabled={!props.canUndo}
data-testid="ai-undo"
onClick={() => props.onUndo()}
>
<ArrowUUpLeft class="size-4 touch:size-6 shrink-0 pointer-events-none" />
</Button>
<Button
aria-label="Redo"
variant="ghost"
size="icon-md"
tooltip={`Redo · ${props.mac ? '⇧⌘Z' : 'Ctrl+Shift+Z'}`}
disabled={!props.canRedo}
data-testid="ai-redo"
onClick={() => props.onRedo()}
>
<ArrowUUpRight class="size-4 touch:size-6 shrink-0 pointer-events-none" />
</Button>
<span
class="flex size-8 items-center justify-center text-ink-muted"
data-testid="ai-save-state"
data-state={props.saveState}
title={match(props.saveState)
.with('saved', () => 'All changes saved')
.with('unsaved', () => 'Unsaved changes')
.with('saving', () => 'Saving…')
.with('error', () => 'Save failed')
.exhaustive()}
>
{match(props.saveState)
.with('saved', () => <CloudCheck class="size-4" />)
.with('error', () => <WarningCircle class="size-4 text-failure" />)
.otherwise(() => (
<CloudArrowUp class="size-4 animate-pulse" />
))}
</span>
<div aria-hidden="true" class="mx-1 h-5 w-px bg-edge-muted" />
</Show>
<div
ref={menu}
class="relative"
onKeyDown={(e) => {
if (e.key === 'Escape' && open()) {
e.stopPropagation();
setOpen(false);
}
}}
>
<Button
variant="ghost"
size="sm"
class="min-w-16 gap-0.5 tabular-nums"
aria-haspopup="menu"
aria-expanded={open()}
data-testid="ai-zoom-menu"
onClick={() => setOpen((o) => !o)}
>
{props.zoomLabel}
<CaretDown class="size-3" />
</Button>
<Show when={open()}>
<div
role="menu"
class="menu-surface absolute right-0 bottom-full z-50 mb-2 w-60 p-1 text-xs"
>
<MenuItems items={props.zoomItems} onDone={() => setOpen(false)} />
</div>
</Show>
</div>
</div>
);
}