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]: soup view tabs as slidable bottom bar (#2257)

Peter Chinmanfee58ef8df54
diff --git a/js/app/packages/app/component/mobile/MobileDock.css b/js/app/packages/app/component/mobile/MobileDock.css
deleted file mode 100644
index 0b707ba374..0000000000
--- a/js/app/packages/app/component/mobile/MobileDock.css
+++ /dev/null
@@ -1,22 +0,0 @@
-@keyframes morePopoverShow {
- from {
- transform: translateY(100%);
- }
- to {
- transform: translateY(0);
- }
-}
-@keyframes morePopoverHide {
- from {
- transform: translateY(0);
- }
- to {
- transform: translateY(100%);
- }
-}
-.more-popover-content {
- animation: morePopoverHide 100ms ease-in forwards;
-}
-.more-popover-content[data-expanded] {
- animation: morePopoverShow 100ms ease-out;
-}
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index 134f49c7a5..f69fd5c64a 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -1,4 +1,3 @@
-import './MobileDock.css';
import { AnimatedInboxIcon } from '@macro-icons/wide/animating/inbox';
import { AnimatedSearchIcon } from '@macro-icons/wide/animating/search';
import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';
@@ -143,7 +142,7 @@ function FloatingCreateButton(props: {
<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"
+ class="absolute bottom-full right-4 mb-14 w-11 h-11 rounded-full bg-page text-accent flex items-center justify-center shadow-lg"
onPointerDown={() => {
impactFeedback('light');
setAnimating(true);
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
index 2c24564517..ef2a9da606 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
@@ -24,6 +24,15 @@ import { useContacts } from '@queries/contacts/contacts';
import { useUserId } from '@core/context/user';
import { NO_ASSIGNEE } from '@app/component/next-soup/soup-view/task-sub-filter-matcher';
import { UserIcon } from '@core/component/UserIcon';
+import {
+ DEFAULT_SORT_OPTIONS,
+ TASK_SORT_OPTIONS,
+ DOCUMENT_SORT_OPTIONS,
+ EMAIL_SORT_OPTIONS,
+ CHANNEL_SORT_OPTIONS,
+ type SystemSortOption,
+ type SortOption,
+} from '@app/component/next-soup/soup-view/sort-options';
export const MobileFilterDrawer = () => {
const {
@@ -56,7 +65,29 @@ export const MobileFilterDrawer = () => {
const isTasksView = () => currentView() === 'tasks';
- const hasFiltersOrCategories = () => categories().length > 0 || isTasksView();
+ const VIEW_SORT_OPTIONS: Partial<Record<ListView, SortOption[]>> = {
+ inbox: DEFAULT_SORT_OPTIONS,
+ agents: DEFAULT_SORT_OPTIONS,
+ mail: EMAIL_SORT_OPTIONS,
+ documents: DOCUMENT_SORT_OPTIONS,
+ tasks: TASK_SORT_OPTIONS,
+ channels: CHANNEL_SORT_OPTIONS,
+ folders: DEFAULT_SORT_OPTIONS,
+ };
+
+ const sortOptions = createMemo(() => {
+ const view = currentView();
+ if (!view) return [];
+ return VIEW_SORT_OPTIONS[view] ?? [];
+ });
+
+ const activeSort = createMemo(
+ () => (soup.sort.active()[0]?.id as SystemSortOption) ?? 'updated_at'
+ );
+ const setSort = (value: SystemSortOption) => soup.sort.setAll([value]);
+
+ const hasFiltersOrCategories = () =>
+ categories().length > 0 || isTasksView() || sortOptions().length > 0;
const toggleFilter = (optionId: FilterOption['id']) => {
soup.filters.toggle({ or: [optionId] });
@@ -110,14 +141,14 @@ export const MobileFilterDrawer = () => {
>
<Drawer.Trigger
as={Button}
- variant="secondary"
+ aria-label="Open filters"
+ variant="ghost"
size="sm"
- class="rounded-xs [&_svg]:size-4 relative"
+ class="rounded-xs [&_svg]:size-6 relative"
>
<SlidersHorizontalIcon />
- <span class="font-medium">Filter</span>
<Show when={activeCount() > 0}>
- <span class="absolute -top-1 -right-1 size-4 flex items-center justify-center rounded-full bg-accent text-page text-[10px] font-medium leading-none">
+ <span class="absolute -top-0.5 right-0 translate-x-1/2 size-4 flex items-center justify-center rounded-full bg-accent text-page text-[10px] font-medium leading-none">
{activeCount()}
</span>
</Show>
@@ -161,11 +192,69 @@ export const MobileFilterDrawer = () => {
ref={setScrollRef}
class="overflow-y-auto scrollbar-hidden h-full pb-1"
>
+ {/* Sort section */}
+ <Show when={sortOptions().length > 0}>
+ <div class="px-4 pb-2 border-b border-edge-muted/30">
+ <span
+ id="sort-section-label"
+ class="text-xs font-medium text-ink-muted uppercase tracking-wide"
+ >
+ Sort
+ </span>
+ </div>
+ <div role="radiogroup" aria-labelledby="sort-section-label">
+ <For each={sortOptions()}>
+ {(option) => {
+ const active = () => activeSort() === option.value;
+ return (
+ <button
+ type="button"
+ role="radio"
+ aria-checked={active()}
+ class="w-full flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-hover transition-colors text-left"
+ onClick={() => setSort(option.value)}
+ >
+ <Show when={option.icon}>
+ {(icon) => (
+ <span class="size-4 flex items-center justify-center shrink-0 text-ink-muted">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+ <span
+ class={cn(
+ 'flex-1 truncate',
+ active()
+ ? 'text-ink font-medium'
+ : 'text-ink-muted'
+ )}
+ >
+ {option.label}
+ </span>
+ <Show when={active()}>
+ <CheckIcon class="size-3.5 text-accent shrink-0" />
+ </Show>
+ </button>
+ );
+ }}
+ </For>
+ </div>
+ </Show>
+
<Accordion
multiple
collapsible
defaultValue={[categories()[0]?.id ?? 'assignee']}
>
+ {/* Filter section */}
+ <Show when={categories().length > 0 || isTasksView()}>
+ <div class="px-4 pt-4 pb-2 border-b border-edge-muted/30">
+ <span class="text-xs font-medium text-ink-muted uppercase tracking-wide">
+ Filters
+ </span>
+ </div>
+ </Show>
+
<For each={categories()}>
{(category) => {
const activeCount = createMemo(
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
index 93f931386f..3f33b12e32 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
@@ -6,7 +6,6 @@ import type { ListView } from '@app/constants/list-views';
import { createMemo, createSignal, Match, Show, Switch } from 'solid-js';
import { UnifiedFilterDropdown } from '@app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown';
import { ActiveFilterChips } from '@app/component/next-soup/soup-view/filters-bar/active-filter-chips';
-import { MobileFilterDrawer } from '@app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer';
import { isMobile } from '@core/mobile/isMobile';
import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
import { Button } from './button';
@@ -76,41 +75,34 @@ export const SoupFiltersBar = () => {
</div>
</Match>
<Match when={true}>
- <div class="flex items-start gap-2 px-2 py-1.5 border-b border-edge-muted/50 w-full">
- <Show
- when={isMobile()}
- fallback={
- <>
- <UnifiedFilterDropdown />
- <ActiveFilterChips
- filters={activeFiltersList()}
- onRemove={removeFilter}
- onReplace={replaceFilter}
- onClearAll={resetToTabDefaults}
- isOptionActive={isOptionActive}
- />
- </>
- }
- >
- <MobileFilterDrawer />
- </Show>
- <div class="flex-1" />
- <Tooltip
- tooltip={<LabelAndHotKey label="Preview" shortcut="space" />}
- >
- <Button
- variant={soup.previewEntity() ? 'primary' : 'ghost'}
- size="sm"
- class="rounded-xs [&_svg]:size-4 px-1 border border-transparent"
- onClick={togglePreview}
- onMouseEnter={() => setPreviewBtnHovering(true)}
- onMouseLeave={() => setPreviewBtnHovering(false)}
+ <Show when={!isMobile()}>
+ <div class="flex items-start gap-2 px-2 py-1.5 border-b border-edge-muted/50 w-full">
+ <UnifiedFilterDropdown />
+ <ActiveFilterChips
+ filters={activeFiltersList()}
+ onRemove={removeFilter}
+ onReplace={replaceFilter}
+ onClearAll={resetToTabDefaults}
+ isOptionActive={isOptionActive}
+ />
+ <div class="flex-1" />
+ <Tooltip
+ tooltip={<LabelAndHotKey label="Preview" shortcut="space" />}
>
- <AnimatedPreviewIcon triggerAnimation={previewBtnHovering()} />
- </Button>
- </Tooltip>
- <SoupViewContextSort />
- </div>
+ <Button
+ variant={soup.previewEntity() ? 'primary' : 'ghost'}
+ size="sm"
+ class="rounded-xs [&_svg]:size-4 px-1 border border-transparent"
+ onClick={togglePreview}
+ onMouseEnter={() => setPreviewBtnHovering(true)}
+ onMouseLeave={() => setPreviewBtnHovering(false)}
+ >
+ <AnimatedPreviewIcon triggerAnimation={previewBtnHovering()} />
+ </Button>
+ </Tooltip>
+ <SoupViewContextSort />
+ </div>
+ </Show>
</Match>
</Switch>
);
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
index 51f9bc8922..581b43c032 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
@@ -129,7 +129,7 @@ export const SoupSearchbar = (props: SoupSearchbarProps) => {
<Show when={searchText() || props.onDismiss}>
<button
type="button"
- class="ml-auto size-4 shrink-0 hover:opacity-60"
+ class="ml-auto size-4 mobile:size-6 shrink-0 hover:opacity-60"
onMouseDown={(e) => {
e.preventDefault();
e.stopPropagation();
@@ -137,7 +137,7 @@ export const SoupSearchbar = (props: SoupSearchbarProps) => {
props.onDismiss?.();
}}
>
- <XIcon class="size-4" />
+ <XIcon class="size-4 mobile:size-6" />
</button>
</Show>
</div>
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
index 7af6f2ddee..e035cc8205 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
@@ -11,9 +11,13 @@ import { isListViewID, type ListView } from '@app/constants/list-views';
import { useUserContext } from '@core/context/user';
import {
batch,
+ createEffect,
createMemo,
+ createSignal,
For,
Match,
+ on,
+ onMount,
type ParentComponent,
Switch,
} from 'solid-js';
@@ -23,7 +27,8 @@ import {
} from '@kobalte/core/segmented-control';
import { DropdownMenu } from '@kobalte/core/dropdown-menu';
import ChevronDownIcon from '@icon/regular/caret-down.svg';
-
+import { impactFeedback } from '@tauri-apps/plugin-haptics';
+import { cn } from '@ui/utils/classname';
type TabItem = { value: string; label: string };
/** Views that have tab definitions. Shared between VIEW_TAB_LISTS and VIEW_TAB_PRESETS. */
@@ -203,6 +208,137 @@ export const CollapsedSoupViewTabs = () => {
);
};
+export const MobileSoupViewTabs = () => {
+ const listView = useCurrentListView();
+
+ return (
+ <Switch>
+ <For
+ each={Object.keys(VIEW_TAB_LISTS) as (keyof typeof VIEW_TAB_LISTS)[]}
+ >
+ {(v) => (
+ <Match when={listView() === v}>
+ <MobileViewTabs view={v} />
+ </Match>
+ )}
+ </For>
+ </Switch>
+ );
+};
+
+const MobileViewTabs = (props: { view: TabbedListView }) => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ let scrollRef!: HTMLDivElement;
+ let spacerRef!: HTMLDivElement;
+ const itemRefs: HTMLDivElement[] = [];
+ const textRefs: HTMLSpanElement[] = [];
+
+ const tabs = () => VIEW_TAB_LISTS[props.view];
+
+ const [scrollActiveId, setScrollActiveId] = createSignal<string>();
+ const [activeWidth, setActiveWidth] = createSignal(0);
+
+ createEffect(
+ on(scrollActiveId, (id) => {
+ const idx = tabs().findIndex((t) => t.value === id);
+ const el = textRefs[idx];
+ if (el) setActiveWidth(el.offsetWidth);
+ })
+ );
+
+ const updateActiveFromScroll = () => {
+ const scrollLeft = scrollRef.scrollLeft;
+ let closest: HTMLDivElement | null = null;
+ let closestDist = Infinity;
+ for (const el of itemRefs) {
+ const dist = Math.abs(el.offsetLeft - scrollLeft);
+ if (dist < closestDist) {
+ closestDist = dist;
+ closest = el;
+ }
+ }
+ const id = closest?.dataset.tabId;
+ if (id && scrollActiveId() !== id) {
+ impactFeedback('light');
+ setScrollActiveId(id);
+ }
+ };
+
+ const updateSpacer = () => {
+ const last = itemRefs[itemRefs.length - 1];
+ if (last) {
+ spacerRef.style.width = `${scrollRef.clientWidth - last.offsetWidth}px`;
+ }
+ };
+
+ onMount(() => {
+ updateSpacer();
+ const tab = activeTab();
+ const idx = tabs().findIndex((t) => t.value === tab);
+ const startIdx = idx >= 0 ? idx : 0;
+ scrollRef.scrollLeft = itemRefs[startIdx]?.offsetLeft ?? 0;
+ setScrollActiveId(tabs()[startIdx]?.value);
+ });
+
+ const handleTouchEnd = () => {
+ const id = scrollActiveId();
+ if (id) {
+ applyTabPreset(props.view, id);
+ }
+ };
+
+ const handleItemClick = (tabValue: string, idx: number) => {
+ const el = itemRefs[idx];
+ if (el) scrollRef.scrollTo({ left: el.offsetLeft, behavior: 'smooth' });
+ impactFeedback('light');
+ applyTabPreset(props.view, tabValue);
+ };
+
+ return (
+ <div class="relative bg-panel border-t border-edge-muted [--tab-padding-l:1rem]">
+ <div
+ ref={scrollRef}
+ class="flex flex-row overflow-x-scroll scrollbar-hidden"
+ style="scroll-snap-type: x mandatory;"
+ onScroll={updateActiveFromScroll}
+ onTouchEnd={handleTouchEnd}
+ >
+ <For each={tabs()}>
+ {(tab, i) => (
+ <div
+ ref={(el) => {
+ itemRefs[i()] = el;
+ }}
+ data-tab-id={tab.value}
+ class={cn(
+ 'flex-shrink-0 flex items-center pl-(--tab-padding-l) pt-3 pb-3 min-h-11 text-sm cursor-pointer',
+ scrollActiveId() === tab.value ? 'text-ink' : 'text-ink/60'
+ )}
+ style="scroll-snap-align: start;"
+ onClick={() => handleItemClick(tab.value, i())}
+ >
+ <span
+ ref={(el) => {
+ textRefs[i()] = el;
+ }}
+ >
+ {tab.label}
+ </span>
+ </div>
+ )}
+ </For>
+ <div ref={spacerRef} class="flex-shrink-0" />
+ </div>
+ <div
+ class="absolute top-0 left-(--tab-padding-l) h-[3px] bg-accent transition-[width] duration-150 pointer-events-none"
+ style={{ width: `${activeWidth()}px` }}
+ />
+ </div>
+ );
+};
+
export const SegmentedControl: ParentComponent<
{
list: { value: string; label: string }[];
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 519583bd22..5c690a672c 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
@@ -86,9 +86,11 @@ import type { FilterID } from '@app/component/next-soup/filters';
import {
SoupViewTabs,
CollapsedSoupViewTabs,
+ MobileSoupViewTabs,
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 { MobileFilterDrawer } from '@app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer';
import { SettingsButton } from '@app/component/settings/SettingsButton';
import { isListViewID, type ListView } from '@app/constants/list-views';
import {
@@ -238,17 +240,20 @@ export const SoupView = (props: SoupViewProps) => {
</h1>
</Show>
<Show when={!narrowSearchExpanded()}>
- <CollapsibleHeaderItem
- id="tabs"
- priority={1}
- expanded={
- <div classList={{ 'pr-1': isMobile() }}>
- <SoupViewTabs />
- </div>
- }
- collapsed={<CollapsedSoupViewTabs />}
- />
- <SoupViewCreateButton />
+ <Show when={!isMobile()}>
+ <CollapsibleHeaderItem
+ id="tabs"
+ priority={1}
+ expanded={<SoupViewTabs />}
+ collapsed={<CollapsedSoupViewTabs />}
+ />
+ </Show>
+ <Show when={!isMobile()}>
+ <SoupViewCreateButton />
+ </Show>
+ <Show when={isMobile()}>
+ <MobileFilterDrawer />
+ </Show>
</Show>
<Show when={narrowSearchExpanded()}>
<div class="flex-1 min-w-0">
@@ -262,7 +267,7 @@ export const SoupView = (props: SoupViewProps) => {
</div>
</SplitHeaderLeft>
<SplitHeaderRight>
- <Show when={isMobile()}>
+ <Show when={isMobile() && !narrowSearchExpanded()}>
<SettingsButton />
</Show>
<Show when={!isComponentListView('search')}>
@@ -289,7 +294,7 @@ export const SoupView = (props: SoupViewProps) => {
class="p-1 rounded-xs"
onClick={() => setNarrowSearchExpanded(true)}
>
- <SearchIcon class="size-4" />
+ <SearchIcon class="size-4 touch:size-6" />
</Button>
</Tooltip>
</Show>
@@ -316,6 +321,9 @@ export const SoupView = (props: SoupViewProps) => {
</SoupViewFileDropzone>
</Suspense>
</div>
+ <Show when={isMobile()}>
+ <MobileSoupViewTabs />
+ </Show>
</div>
<Suspense>
<Show when={ENABLE_UNIFIED_LIST_AI_INPUT && !isMobile()}>
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index 8c1e182755..8c9201c707 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -200,8 +200,10 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
<div class="mobile:hidden">
<SplitCloseButton />
</div>
- <SplitBackButton />
- <SplitForwardButton />
+ <Show when={!(isMobile() && isListViewID(panel.handle.content().id))}>
+ <SplitBackButton />
+ <SplitForwardButton />
+ </Show>
</div>
<div
class="relative min-w-0 h-full grow shrink pl-2 flex items-center gap-0.5"