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[mobile]: what if mobile dock had so many buttons (#2243)

Peter Chinman65128f1a2f11
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index d373ae439b..134f49c7a5 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -1,32 +1,29 @@
import './MobileDock.css';
-import ChevronUpIcon from '@icon/regular/caret-up.svg?component-solid';
import { AnimatedInboxIcon } from '@macro-icons/wide/animating/inbox';
import { AnimatedSearchIcon } from '@macro-icons/wide/animating/search';
-import { AnimatedPlusIcon } from '@macro-icons/wide/animating/plus';
import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';
-import { AnimatedSlidersHorizontalIcon } from '@macro-icons/wide/animating/sliders-horizontal';
+import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';
+import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';
+import { AnimatedFileMdIcon } from '@macro-icons/wide/animating/fileMd';
+import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';
+import { AnimatedPlusIcon } from '@macro-icons/wide/animating/plus';
import { impactFeedback } from '@tauri-apps/plugin-haptics';
import {
- type Accessor,
type Component,
+ createMemo,
createSignal,
- For,
type JSX,
- type Setter,
+ Show,
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
-import { Popover } from '@kobalte/core/popover';
import { cn } from '@ui/utils/classname';
import { useSplitLayout } from '../split-layout/layout';
-import { SIDEBAR_LINKS } from '../app-sidebar/sidebar';
import { type ListView, isListViewID } from '@app/constants/list-views';
import { globalSplitManager } from '@app/signal/splitLayout';
import { SearchState } from './mobileSearchState';
-import { useSettingsState } from '@core/constant/SettingsState';
-import { setCreateMenuOpen } from '../Launcher';
+import { runCreateAction, setCreateMenuOpen } from '../Launcher';
import { useLocation } from '@solidjs/router';
import { useAnalytics } from '@app/component/analytics-context';
-import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';
const ICON_ANIMATION_DURATION_MS = 500;
@@ -34,7 +31,7 @@ type MobileDockButtonProps = {
icon: Component<
JSX.SvgSVGAttributes<SVGSVGElement> | { triggerAnimation?: boolean }
>;
- label: string;
+ label?: string;
onClick: () => void;
active?: boolean;
ref?: HTMLButtonElement | ((el: HTMLButtonElement) => void);
@@ -59,165 +56,112 @@ function MobileDockButton(props: MobileDockButtonProps) {
onTouchMove={props.onTouchMove}
onTouchEnd={props.onTouchEnd}
class={cn(
- 'flex flex-col items-center justify-center w-[20%] pt-3 bg-page border-t border-edge-muted',
+ 'flex flex-col items-center justify-center flex-1 pt-3 pb-2 bg-page border-t border-edge-muted',
props.active && 'text-accent'
)}
>
<div class={cn('w-6 h-6 [&_svg]:size-6', props.iconClass)}>
<Dynamic component={props.icon} triggerAnimation={animating()} />
</div>
- <span class="text-xs">{props.label}</span>
+ <Show when={props.label}>
+ <span class="text-xs">{props.label}</span>
+ </Show>
</button>
);
}
-const PRIMARY_IDS = ['inbox', 'channels', 'mail', 'search'] as const;
+type IconComponent = MobileDockButtonProps['icon'];
-const MORE_VIEWS = SIDEBAR_LINKS.filter(
- (l) => !(PRIMARY_IDS as readonly string[]).includes(l.id)
-).reverse();
+const VIEW_CREATE_ICONS: Partial<Record<ListView, IconComponent>> = {
+ agents: AnimatedStarIcon,
+ mail: AnimatedEmailIcon,
+ documents: AnimatedPlusIcon,
+ tasks: AnimatedTaskIcon,
+ channels: AnimatedChannelIcon,
+ inbox: AnimatedPlusIcon,
+};
-function MorePopover(props: {
- active: boolean;
- isActive: (id: ListView) => boolean;
- onNavigate: (id: ListView) => void;
- open: Accessor<boolean>;
- setOpen: Setter<boolean>;
+function FloatingCreateButton(props: {
+ activeView: () => ListView | undefined;
}) {
const analytics = useAnalytics();
- const { toggleSettings } = useSettingsState();
- const [anchorRef, setAnchorRef] = createSignal<HTMLElement>();
- const [hoveredId, setHoveredId] = createSignal<string | null>(null);
-
- const handleTouchMove = (e: TouchEvent) => {
- if (!props.open()) return;
- const touch = e.touches[0];
- const el = document.elementFromPoint(touch.clientX, touch.clientY);
- const button = el?.closest('[data-more-item]') as HTMLElement | null;
- const id = button?.dataset.moreItem ?? null;
- if (id !== hoveredId()) {
- setHoveredId(id);
- if (id) impactFeedback('light');
- }
- };
+ const [animating, setAnimating] = createSignal(false);
- const handleTouchEnd = () => {
- const id = hoveredId();
- setHoveredId(null);
- if (id === 'settings') {
- toggleSettings();
- props.setOpen(false);
- } else if (id === 'create') {
+ const VIEW_CREATE_ACTIONS: Partial<Record<ListView, () => void>> = {
+ agents: () => {
+ analytics.track('create_entity', {
+ entityType: 'chat',
+ source: 'mobile_dock',
+ });
+ runCreateAction('chat');
+ },
+ mail: () => {
+ analytics.track('create_entity', {
+ entityType: 'email',
+ source: 'mobile_dock',
+ });
+ runCreateAction('email');
+ },
+ documents: () => {
analytics.track('create_menu_open', { from: 'mobile_dock' });
setCreateMenuOpen(true);
- props.setOpen(false);
- } else if (isListViewID(id)) {
- props.onNavigate(id);
- props.setOpen(false);
- }
+ },
+ tasks: () => {
+ analytics.track('create_entity', {
+ entityType: 'task',
+ source: 'mobile_dock',
+ });
+ runCreateAction('task');
+ },
+ channels: () => {
+ analytics.track('create_entity', {
+ entityType: 'channel',
+ source: 'mobile_dock',
+ });
+ runCreateAction('channel');
+ },
};
+ const createAction = createMemo(() => {
+ const view = props.activeView();
+ if (!view || view === 'search') return undefined;
+ return (
+ VIEW_CREATE_ACTIONS[view] ??
+ (() => {
+ analytics.track('create_menu_open', { from: 'mobile_dock' });
+ setCreateMenuOpen(true);
+ })
+ );
+ });
+
+ const createIcon = createMemo<IconComponent>(() => {
+ const view = props.activeView();
+ return (view && VIEW_CREATE_ICONS[view]) ?? AnimatedPlusIcon;
+ });
+
return (
- <>
- <MobileDockButton
- icon={ChevronUpIcon}
- label="More"
- active={props.active}
- onClick={() => props.setOpen((prev) => !prev)}
- ref={setAnchorRef}
- onTouchMove={handleTouchMove}
- onTouchEnd={handleTouchEnd}
- iconClass={cn(
- 'transition-transform duration-200 [perspective:200px]',
- props.open() && '[transform:rotateX(180deg)]'
- )}
- />
- <Popover
- open={props.open()}
- onOpenChange={(isOpen) => {
- props.setOpen(isOpen);
- if (!isOpen) setHoveredId(null);
+ <Show when={createAction()}>
+ <button
+ type="button"
+ class="absolute bottom-full right-4 mb-3 w-11 h-11 rounded-full bg-page text-accent flex items-center justify-center shadow-lg"
+ onPointerDown={() => {
+ impactFeedback('light');
+ setAnimating(true);
+ setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
+ createAction()?.();
}}
- placement="top"
- overflowPadding={10}
- anchorRef={anchorRef}
>
- <Popover.Content class="more-popover-content -z-2 bg-page border-t border-l border-r border-edge-muted rounded-t-sm flex flex-col gap-1 w-[calc(100vw-20px)] shadow-lg">
- <button
- type="button"
- data-more-item="settings"
- class={cn(
- 'flex items-center gap-2 px-3 h-11 text-sm text-ink',
- hoveredId() === 'settings' ? 'bg-hover' : 'hover:bg-hover'
- )}
- onClick={() => {
- impactFeedback('light');
- toggleSettings();
- props.setOpen(false);
- }}
- >
- <div class="w-4 h-4 shrink-0 [&_svg]:size-4">
- <AnimatedSlidersHorizontalIcon
- triggerAnimation={hoveredId() === 'settings'}
- />
- </div>
- <span>Settings</span>
- </button>
- <button
- type="button"
- data-more-item="create"
- class={cn(
- 'flex items-center gap-2 px-3 h-11 text-sm text-ink border-b border-edge-muted',
- hoveredId() === 'create' ? 'bg-hover' : 'hover:bg-hover'
- )}
- onClick={() => {
- impactFeedback('light');
- analytics.track('create_menu_open', { from: 'mobile_dock' });
- setCreateMenuOpen(true);
- props.setOpen(false);
- }}
- >
- <div class="w-4 h-4 shrink-0 [&_svg]:size-4">
- <AnimatedPlusIcon triggerAnimation={hoveredId() === 'create'} />
- </div>
- <span>Create</span>
- </button>
- <For each={MORE_VIEWS}>
- {(item) => (
- <button
- type="button"
- data-more-item={item.id}
- class={cn(
- 'flex items-center gap-2 px-3 h-11 text-sm',
- props.isActive(item.id) ? 'text-accent' : 'text-ink',
- hoveredId() === item.id ? 'bg-hover' : 'hover:bg-hover'
- )}
- onClick={() => {
- impactFeedback('light');
- props.onNavigate(item.id);
- props.setOpen(false);
- }}
- >
- <div class="w-4 h-4 shrink-0 [&_svg]:size-4">
- <Dynamic
- component={item.icon}
- triggerAnimation={hoveredId() === item.id}
- />
- </div>
- <span>{item.label}</span>
- </button>
- )}
- </For>
- </Popover.Content>
- </Popover>
- </>
+ <div class="w-5 h-5 [&_svg]:size-5">
+ <Dynamic component={createIcon()} triggerAnimation={animating()} />
+ </div>
+ </button>
+ </Show>
);
}
export function MobileDock() {
const { openWithSplit } = useSplitLayout();
const location = useLocation();
- const [moreOpen, setMoreOpen] = createSignal(false);
const isActive = (id: ListView) => {
const activeContent = globalSplitManager()?.activeSplit()?.content();
@@ -228,7 +172,15 @@ export function MobileDock() {
return activeContent.id === id;
};
- const isMoreActive = () => MORE_VIEWS.some((v) => isActive(v.id));
+ const activeView = createMemo<ListView | undefined>(() => {
+ const activeContent = globalSplitManager()?.activeSplit()?.content();
+ if (activeContent?.type === 'component' && isListViewID(activeContent.id)) {
+ return activeContent.id;
+ }
+ const segments = location.pathname.split('/').filter(Boolean);
+ const last = segments[segments.length - 1];
+ return isListViewID(last) ? last : undefined;
+ });
const navigate = (id: ListView) => {
openWithSplit({ type: 'component', id }, { mergeHistory: true });
@@ -237,45 +189,45 @@ export function MobileDock() {
return (
<div class="relative z-mobile-nav-bar flex flex-row justify-between">
<div class="-z-1 absolute left-0 top-0 right-0 w-screen h-40 bg-page" />
+ <FloatingCreateButton activeView={activeView} />
<MobileDockButton
icon={AnimatedInboxIcon}
- label="Inbox"
active={isActive('inbox')}
onClick={() => {
- setMoreOpen(false);
navigate('inbox');
}}
/>
+ <MobileDockButton
+ icon={AnimatedEmailIcon}
+ active={isActive('mail')}
+ onClick={() => navigate('mail')}
+ />
<MobileDockButton
icon={AnimatedChannelIcon}
- label="Channels"
active={isActive('channels')}
onClick={() => {
- setMoreOpen(false);
navigate('channels');
}}
/>
<MobileDockButton
- icon={AnimatedEmailIcon}
- label="Email"
- active={isActive('mail')}
- onClick={() => {
- setMoreOpen(false);
- navigate('mail');
- }}
+ icon={AnimatedTaskIcon}
+ active={isActive('tasks')}
+ onClick={() => navigate('tasks')}
/>
- <MorePopover
- active={isMoreActive()}
- isActive={isActive}
- onNavigate={navigate}
- open={moreOpen}
- setOpen={setMoreOpen}
+ <MobileDockButton
+ icon={AnimatedFileMdIcon}
+ active={isActive('documents')}
+ onClick={() => navigate('documents')}
+ />
+ <MobileDockButton
+ icon={AnimatedStarIcon}
+ active={isActive('agents')}
+ onClick={() => navigate('agents')}
/>
<MobileDockButton
icon={AnimatedSearchIcon}
- label="Search"
+ active={isActive('search')}
onClick={() => {
- setMoreOpen(false);
SearchState.maybeResetState();
SearchState.open();
}}
diff --git a/js/app/packages/app/component/mobile/MobileSearch.tsx b/js/app/packages/app/component/mobile/MobileSearch.tsx
index 3e0d932646..3216736cb5 100644
--- a/js/app/packages/app/component/mobile/MobileSearch.tsx
+++ b/js/app/packages/app/component/mobile/MobileSearch.tsx
@@ -167,17 +167,16 @@ export function MobileSearchInner() {
{/* Search Input */}
<div class="flex items-center gap-2 bg-page px-2 border-t border-edge-muted">
<button
- class="text-ink-muted flex flex-col items-center justify-center pl-2 pt-3"
+ class="text-ink-muted flex flex-col items-center justify-center pl-2 pt-3 pb-2"
onClick={handleBack}
title="Back (Esc)"
>
<ArrowLeft class="size-6" />
- <div class="text-xs text-transparent">Back</div>
</button>
<input
ref={(el) => setTimeout(() => el.focus(), 50)} // setTimeout needed: iOS only allows focus() within the user gesture window
type="text"
- class="flex-1 bg-transparent border-0 outline-none focus:outline-none ring-0 focus:ring-0 text-ink-muted placeholder:text-ink-placeholder/50"
+ class="pt-3 pb-2 flex-1 bg-transparent border-0 outline-none focus:outline-none ring-0 focus:ring-0 text-ink-muted placeholder:text-ink-placeholder/50"
placeholder={'Search...'}
value={SearchState.query()}
onInput={(e) => SearchState.setQuery(e.currentTarget.value)}
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 4f34b841c9..205a577aef 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -89,6 +89,7 @@ import {
useApplyPreset,
} from '@app/component/next-soup/soup-view/soup-view-tabs';
import { SoupViewCreateButton } from '@app/component/next-soup/soup-view/soup-view-create-button';
+import { SettingsButton } from '@app/component/settings/SettingsButton';
import { isListViewID, type ListView } from '@app/constants/list-views';
import {
SplitHeaderLeft,
@@ -258,6 +259,9 @@ export const SoupView = (props: SoupViewProps) => {
</div>
</SplitHeaderLeft>
<SplitHeaderRight>
+ <Show when={isMobile()}>
+ <SettingsButton />
+ </Show>
<Show when={!isComponentListView('search')}>
<CollapsibleHeaderItem
id="search"