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): make soup pretty (#3372)

Peter Chinmanb969e9670934
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index 9ddbf23f55..f3d7772b59 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -16,7 +16,7 @@ import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import { updateCookie } from '@core/util/cookies';
import { makePersisted } from '@solid-primitives/storage';
import { type RouteSectionProps, useLocation } from '@solidjs/router';
-import { cn } from '@ui';
+import { cn, Layer } from '@ui';
import { attachGlobalDOMScope } from 'core/hotkey/hotkeys';
import {
createEffect,
@@ -85,6 +85,12 @@ function LayoutInner(props: RouteSectionProps) {
const isAuthenticated = useIsAuthenticated();
const { paywallOpen, showPaywall } = usePaywallState();
const location = useLocation();
+ const shouldUsePanelSafeAreaBackground = createMemo(
+ () =>
+ isMobile() &&
+ isAuthenticated() === true &&
+ !AUTH_URLS.includes(location.pathname)
+ );
useAppSquishHandlers();
@@ -124,6 +130,11 @@ function LayoutInner(props: RouteSectionProps) {
}
)}
>
+ <Show when={shouldUsePanelSafeAreaBackground()}>
+ <Layer depth={1}>
+ <div class="pointer-events-none absolute inset-x-0 top-0 h-(--safe-top) bg-surface" />
+ </Layer>
+ </Show>
<BundleUpdateProgressBar />
<Suspense>
<Show when={isAuthenticated()}>
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index 1db65143bc..48b3bda212 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -1,12 +1,11 @@
import type { ListView } from '@app/constants/list-views';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { focusInput } from '@core/directive/focusInput';
import { hapticImpact } from '@core/mobile/haptics';
+import { AnimatedCallIcon } from '@icon/wide-call';
import { AnimatedChannelIcon } from '@icon/wide-channel';
import { AnimatedEmailIcon } from '@icon/wide-email';
import { AnimatedFileMdIcon } from '@icon/wide-fileMd';
import { AnimatedInboxIcon } from '@icon/wide-inbox';
-import { AnimatedSearchIcon } from '@icon/wide-search';
import { AnimatedStarIcon } from '@icon/wide-star';
import { AnimatedTaskIcon } from '@icon/wide-task';
import { useLocation } from '@solidjs/router';
@@ -14,9 +13,6 @@ import { cn, Layer } from '@ui';
import { type Component, createSignal, type JSX, Show } from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { useSplitLayout } from '../split-layout/layout';
-import { SearchState } from './mobileSearchState';
-
-false && focusInput;
const ICON_ANIMATION_DURATION_MS = 500;
@@ -63,37 +59,6 @@ function MobileDockButton(props: MobileDockButtonProps) {
);
}
-function SearchDockButton(props: { active: boolean; onClick: () => void }) {
- const [animating, setAnimating] = createSignal(false);
-
- return (
- <button
- type="button"
- use:focusInput={{
- getTarget: () => document.getElementById('mobile-search-input'),
- }}
- // This needs to be onClick, rather than pointerDown like the other buttons, so that we can use onClick behavior of focusInput before the dialog overlay appears.
- onClick={() => {
- hapticImpact('light');
- setAnimating(true);
- setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
- props.onClick();
- }}
- class={cn(
- 'flex flex-col items-center justify-center flex-1 pt-3 pb-2 bg-surface border-t border-edge-muted',
- props.active && 'text-accent'
- )}
- >
- <div class="size-6 [&_svg]:size-6">
- <Dynamic
- component={AnimatedSearchIcon}
- triggerAnimation={animating()}
- />
- </div>
- </button>
- );
-}
-
export function MobileDock() {
const { openWithSplit } = useSplitLayout();
const location = useLocation();
@@ -155,12 +120,10 @@ export function MobileDock() {
active={isActive('agents')}
onClick={() => navigate('agents')}
/>
- <SearchDockButton
- active={isActive('search')}
- onClick={() => {
- SearchState.maybeResetState();
- SearchState.open();
- }}
+ <MobileDockButton
+ icon={AnimatedCallIcon}
+ active={isActive('calls')}
+ onClick={() => navigate('calls')}
/>
</div>
</Layer>
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 967d323978..752023ad9e 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
@@ -205,7 +205,7 @@ export const MobileFilterDrawer = () => {
aria-label="Open filters"
variant="ghost"
size="sm"
- class="rounded-xs [&_svg]:size-6 relative"
+ class="rounded-xs [&_svg]:size-6 relative h-full"
>
<SlidersHorizontalIcon />
<Show when={activeCount() > 0}>
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx
index 3e4a39603b..826fe4f301 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx
@@ -6,16 +6,21 @@ import { AnimatedEmailIcon } from '@icon/wide-email';
import { AnimatedPlusIcon } from '@icon/wide-plus';
import { AnimatedStarIcon } from '@icon/wide-star';
import { AnimatedTaskIcon } from '@icon/wide-task';
-import { Layer } from '@ui';
+import { cn, Layer } from '@ui';
import {
+ type Accessor,
type Component,
createMemo,
createSignal,
type JSX,
- Show,
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { runCreateAction, setCreateMenuOpen } from '../../Launcher';
+import {
+ MOBILE_FLOATING_BUTTON_OFFSCREEN_RIGHT,
+ MOBILE_FLOATING_BUTTON_TRANSITION,
+ MOBILE_FLOATING_BUTTON_VISIBLE,
+} from './soup-view-mobile-floating-motion';
const ICON_ANIMATION_DURATION_MS = 500;
@@ -34,6 +39,7 @@ const VIEW_CREATE_ICONS: Partial<Record<ListView, IconComponent>> = {
export function SoupViewMobileCreateButton(props: {
activeView: () => ListView | undefined;
+ visible?: Accessor<boolean>;
}) {
const analytics = useAnalytics();
const [animating, setAnimating] = createSignal(false);
@@ -90,26 +96,35 @@ export function SoupViewMobileCreateButton(props: {
return (view && VIEW_CREATE_ICONS[view]) ?? AnimatedPlusIcon;
});
+ const isVisible = () => (props.visible?.() ?? true) && !!createAction();
+
return (
- <Show when={createAction()}>
- <Layer depth={1}>
- <button
- type="button"
- class="absolute bottom-4 right-4 z-10 pl-3 pr-4 py-2 rounded-full bg-surface ring text-accent flex items-center justify-center gap-2 shadow-md ring-accent/20"
- onClick={() => {
- hapticImpact('light');
- setAnimating(true);
- setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
- // Defer to next frame to avoid focus race with Dialog
- requestAnimationFrame(() => createAction()?.());
- }}
- >
- <div class="size-5 [&_svg]:size-5">
- <Dynamic component={createIcon()} triggerAnimation={animating()} />
- </div>
- <div>Create</div>
- </button>
- </Layer>
- </Show>
+ <Layer depth={4}>
+ <button
+ type="button"
+ class={cn(
+ 'absolute bottom-4 right-4 z-10 h-11 pl-3.5 pr-4.5 rounded-full',
+ 'bg-surface text-accent flex items-center justify-center gap-2 shadow-md ring ring-edge',
+ MOBILE_FLOATING_BUTTON_TRANSITION,
+ isVisible()
+ ? MOBILE_FLOATING_BUTTON_VISIBLE
+ : MOBILE_FLOATING_BUTTON_OFFSCREEN_RIGHT
+ )}
+ disabled={!isVisible()}
+ aria-hidden={!isVisible()}
+ onClick={() => {
+ hapticImpact('light');
+ setAnimating(true);
+ setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
+ // Defer to next frame to avoid focus race with Dialog
+ requestAnimationFrame(() => createAction()?.());
+ }}
+ >
+ <div class="size-5 [&_svg]:size-5">
+ <Dynamic component={createIcon()} triggerAnimation={animating()} />
+ </div>
+ <div>Create</div>
+ </button>
+ </Layer>
);
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-floating-motion.ts b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-floating-motion.ts
new file mode 100644
index 0000000000..8708093197
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-floating-motion.ts
@@ -0,0 +1,8 @@
+export const MOBILE_FLOATING_BUTTON_TRANSITION =
+ 'origin-center transition-all duration-300 ease-out';
+
+export const MOBILE_FLOATING_BUTTON_VISIBLE =
+ 'opacity-100 translate-x-0 scale-100';
+
+export const MOBILE_FLOATING_BUTTON_OFFSCREEN_RIGHT =
+ 'pointer-events-none translate-x-[calc(100%+var(--floating-button-offscreen-gap,2rem))]';
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-search.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-search.tsx
new file mode 100644
index 0000000000..9fc1358920
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-search.tsx
@@ -0,0 +1,103 @@
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { focusInput } from '@core/directive/focusInput';
+import { hapticImpact } from '@core/mobile/haptics';
+import SearchIcon from '@icon/macro-magnifying-glass.svg';
+import XIcon from '@phosphor/x.svg';
+import { cn, Layer } from '@ui';
+import { type Accessor, createEffect, Show } from 'solid-js';
+import {
+ MOBILE_FLOATING_BUTTON_TRANSITION,
+ MOBILE_FLOATING_BUTTON_VISIBLE,
+} from './soup-view-mobile-floating-motion';
+
+false && focusInput;
+
+export function SoupViewMobileSearchButton(props: {
+ open: Accessor<boolean>;
+ visible?: Accessor<boolean>;
+ onOpen: () => void;
+}) {
+ const isVisible = () => !props.open();
+ const isExpanded = () => props.visible?.() ?? true;
+
+ return (
+ <Layer depth={4}>
+ <button
+ type="button"
+ use:focusInput={{
+ getTarget: () => document.getElementById('soup-mobile-search-input'),
+ }}
+ class={cn(
+ 'absolute bottom-4 right-4 z-10 size-11 rounded-full',
+ 'bg-surface flex items-center justify-center shadow-md ring ring-edge',
+ MOBILE_FLOATING_BUTTON_TRANSITION,
+ !isVisible()
+ ? 'pointer-events-none translate-y-2'
+ : isExpanded()
+ ? 'opacity-100 -translate-x-[calc(100%+5.25rem)] scale-100'
+ : MOBILE_FLOATING_BUTTON_VISIBLE
+ )}
+ disabled={!isVisible()}
+ aria-hidden={!isVisible()}
+ aria-label="Search"
+ onClick={() => {
+ hapticImpact('light');
+ props.onOpen();
+ }}
+ >
+ <SearchIcon class="size-5" />
+ </button>
+ </Layer>
+ );
+}
+
+export function SoupViewMobileSearchBar(props: {
+ open: Accessor<boolean>;
+ onClose: () => void;
+}) {
+ const { searchText, setSearchText, setSearchPaused } = useSoupView();
+ let inputRef: HTMLInputElement | undefined;
+
+ createEffect(() => {
+ if (!props.open()) return;
+ setSearchPaused(false);
+ setTimeout(() => inputRef?.focus());
+ });
+
+ return (
+ <Show when={props.open()}>
+ <Layer depth={4}>
+ <div
+ class="absolute inset-x-0 bottom-0 z-20 flex items-center gap-2 bg-surface px-2 border-t border-edge-muted"
+ data-no-focus-restore
+ >
+ <button
+ type="button"
+ class="text-ink-muted flex flex-col items-center justify-center pl-2 pt-3 pb-2"
+ onClick={() => {
+ setSearchText('');
+ props.onClose();
+ }}
+ title="Close Search"
+ >
+ <XIcon class="size-6" />
+ </button>
+ <input
+ ref={inputRef}
+ id="soup-mobile-search-input"
+ type="text"
+ class="pt-3 pb-2 flex-1 min-w-0 bg-transparent border-0 outline-none focus:outline-none ring-0 focus:ring-0 text-ink-muted placeholder:text-ink-placeholder"
+ placeholder="Search..."
+ value={searchText()}
+ onInput={(e) => setSearchText(e.currentTarget.value)}
+ onKeyDown={(e) => {
+ if (e.key !== 'Escape') return;
+ e.currentTarget.blur();
+ props.onClose();
+ }}
+ />
+ </div>
+ </Layer>
+ </Show>
+ );
+}
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-settings-button.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-settings-button.tsx
new file mode 100644
index 0000000000..9d09e5d706
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-settings-button.tsx
@@ -0,0 +1,49 @@
+import { useSettingsState } from '@core/constant/SettingsState';
+import { hapticImpact } from '@core/mobile/haptics';
+import IconGear from '@icon/macro-gear.svg';
+import { cn, Layer } from '@ui';
+import type { Accessor } from 'solid-js';
+import { Show } from 'solid-js';
+import { useSplitLayout } from '../../split-layout/layout';
+import {
+ MOBILE_FLOATING_BUTTON_OFFSCREEN_RIGHT,
+ MOBILE_FLOATING_BUTTON_TRANSITION,
+ MOBILE_FLOATING_BUTTON_VISIBLE,
+} from './soup-view-mobile-floating-motion';
+
+export function SoupViewMobileSettingsButton(props: {
+ visible: Accessor<boolean>;
+}) {
+ const { settingsOpen, toggleSettings } = useSettingsState();
+ const { getSplitCount } = useSplitLayout();
+
+ const isSingleSplit = () => getSplitCount() <= 1;
+
+ return (
+ <Show when={isSingleSplit()}>
+ <Layer depth={4}>
+ <button
+ type="button"
+ class={cn(
+ 'absolute bottom-[4.5rem] right-4 z-10 size-11 rounded-full',
+ 'bg-surface text-ink flex items-center justify-center shadow-md',
+ MOBILE_FLOATING_BUTTON_TRANSITION,
+ 'ring ring-edge hover:text-accent hover:bg-hover',
+ settingsOpen() && 'bg-accent/20 text-accent ring-accent/20',
+ props.visible()
+ ? MOBILE_FLOATING_BUTTON_VISIBLE
+ : MOBILE_FLOATING_BUTTON_OFFSCREEN_RIGHT
+ )}
+ aria-label={settingsOpen() ? 'Close Settings' : 'Open Settings'}
+ aria-hidden={!props.visible()}
+ onClick={() => {
+ hapticImpact('light');
+ toggleSettings();
+ }}
+ >
+ <IconGear class="size-5" />
+ </button>
+ </Layer>
+ </Show>
+ );
+}
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 50aa9e2680..08d12b35a6 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
@@ -4,6 +4,7 @@ import {
VIEW_TAB_PRESETS,
} from '@app/component/app-sidebar/soup-filter-presets';
import { useSoup } from '@app/component/next-soup/soup-context';
+import { MobileFilterDrawer } from '@app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { isListViewID, type ListView } from '@app/constants/list-views';
@@ -11,7 +12,7 @@ import { type TabItem, Tabs } from '@core/component/Tabs';
import { TabsInset } from '@core/component/TabsInset';
import { TabsInsetDropdown } from '@core/component/TabsInsetDropdown';
import { useUserContext } from '@core/context/user';
-import { batch, createMemo, For, Match, Switch } from 'solid-js';
+import { batch, createEffect, createMemo, For, Match, Switch } from 'solid-js';
/** Views that have tab definitions. Shared between VIEW_TAB_LISTS and VIEW_TAB_PRESETS. */
export type TabbedListView = Extract<
@@ -181,18 +182,23 @@ export const MobileSoupViewTabs = () => {
const listView = useCurrentListView();
return (
- <div class="bg-surface border-t border-edge-muted h-11 px-1">
- <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>
+ <div class="bg-surface border-t border-edge-muted h-11 px-1 flex gap-1">
+ <MobileFilterDrawer />
+ <div class="flex-1 min-w-0 h-full">
+ <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>
+ </div>
</div>
);
};
@@ -202,14 +208,42 @@ const MobileViewTabs = (props: { view: TabbedListView }) => {
const { activeTab } = useSoupView();
const list = () => VIEW_TAB_LISTS[props.view];
+ let wrapperRef: HTMLDivElement | undefined;
+
+ createEffect(() => {
+ activeTab();
+ list();
+ if (!wrapperRef) return;
+ queueMicrotask(() => {
+ const scrollEl = wrapperRef?.firstElementChild as HTMLElement | null;
+ const active = scrollEl?.querySelector(
+ '[data-checked]'
+ ) as HTMLElement | null;
+ if (!scrollEl || !active) return;
+ const itemLeft = active.offsetLeft;
+ const itemRight = itemLeft + active.offsetWidth;
+ const viewRight = scrollEl.scrollLeft + scrollEl.clientWidth;
+ if (itemLeft < scrollEl.scrollLeft) {
+ scrollEl.scrollTo({ left: itemLeft, behavior: 'smooth' });
+ } else if (itemRight > viewRight) {
+ scrollEl.scrollTo({
+ left: itemRight - scrollEl.clientWidth,
+ behavior: 'smooth',
+ });
+ }
+ });
+ });
+
return (
- <Tabs
- list={list()}
- value={activeTab()}
- defaultValue={VIEW_TAB_PRESETS[props.view].default}
- onChange={(value) => applyTabPreset(props.view, value)}
- indicatorPosition="top"
- class="**:data-indicator:h-0.75"
- />
+ <div ref={wrapperRef} class="h-full">
+ <Tabs
+ list={list()}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS[props.view].default}
+ onChange={(value) => applyTabPreset(props.view, value)}
+ indicatorPosition="top"
+ class="**:data-indicator:h-0.75 overflow-x-auto scrollbar-hidden [&>div]:w-max"
+ />
+ </div>
);
};
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 3a4fe17c28..62a3bddaae 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
@@ -17,7 +17,6 @@ import type { QueryState } from '@app/component/next-soup/filters/filter-store';
import type { SetPredicatesInput } from '@app/component/next-soup/filters/filter-store/predicates-store';
import { useSoup } from '@app/component/next-soup/soup-context';
import { EmptyState } from '@app/component/next-soup/soup-view/empty-states';
-import { MobileFilterDrawer } from '@app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer';
import { SoupFiltersBar } from '@app/component/next-soup/soup-view/filters-bar/soup-filters-bar';
import { SoupSearchbar } from '@app/component/next-soup/soup-view/filters-bar/soup-view-search-bar';
import { useFilterRefinements } from '@app/component/next-soup/soup-view/filters-bar/use-filter-refinements';
@@ -35,6 +34,11 @@ import {
import { SoupViewCreateButton } from '@app/component/next-soup/soup-view/soup-view-create-button';
import { SoupViewFileDropzone } from '@app/component/next-soup/soup-view/soup-view-file-dropzone';
import { SoupViewMobileCreateButton } from '@app/component/next-soup/soup-view/soup-view-mobile-create-button';
+import {
+ SoupViewMobileSearchBar,
+ SoupViewMobileSearchButton,
+} from '@app/component/next-soup/soup-view/soup-view-mobile-search';
+import { SoupViewMobileSettingsButton } from '@app/component/next-soup/soup-view/soup-view-mobile-settings-button';
import {
CollapsedSoupViewTabs,
MobileSoupViewTabs,
@@ -52,7 +56,6 @@ import {
useMaybePreviewPanel,
} from '@app/component/PreviewPanel';
import { SoupChatInput } from '@app/component/SoupChatInput';
-import { SettingsButton } from '@app/component/settings/SettingsButton';
import { CollapsibleHeaderItem } from '@app/component/split-layout/components/CollapsibleHeaderItem';
import {
SplitHeaderLeft,
@@ -371,7 +374,37 @@ export const SoupView = (props: SoupViewProps) => {
});
const [narrowSearchExpanded, setNarrowSearchExpanded] = createSignal(false);
+ const [mobileSearchOpen, setMobileSearchOpen] = createSignal(false);
const [searchIsCollapsed, setSearchIsCollapsed] = createSignal(false);
+ const [floatingButtonsVisible, setFloatingButtonsVisible] =
+ createSignal(true);
+ let lastSoupScrollOffset = 0;
+ let upwardSoupScrollDistance = 0;
+
+ const resetFloatingButtonScrollTracking = (offset = 0) => {
+ lastSoupScrollOffset = Math.max(0, offset);
+ upwardSoupScrollDistance = 0;
+ setFloatingButtonsVisible(true);
+ };
+
+ const handleSoupScrollOffsetChange = (offset: number) => {
+ const nextOffset = Math.max(0, offset);
+ const delta = nextOffset - lastSoupScrollOffset;
+ lastSoupScrollOffset = nextOffset;
+
+ if (delta > 0) {
+ upwardSoupScrollDistance = 0;
+ setFloatingButtonsVisible(false);
+ return;
+ }
+
+ if (delta < 0) {
+ upwardSoupScrollDistance += Math.abs(delta);
+ if (upwardSoupScrollDistance > FLOATING_BUTTON_SCROLL_UP_THRESHOLD) {
+ setFloatingButtonsVisible(true);
+ }
+ }
+ };
registerHotkey({
hotkey: 'cmd+f',
@@ -380,6 +413,11 @@ export const SoupView = (props: SoupViewProps) => {
registrationType: 'add',
description: 'Search',
keyDownHandler: () => {
+ if (isMobile()) {
+ if (mobileSearchOpen()) return false;
+ setMobileSearchOpen(true);
+ return true;
+ }
if (narrowSearchExpanded() || !searchIsCollapsed()) return false;
setNarrowSearchExpanded(true);
return true;
@@ -447,69 +485,65 @@ export const SoupView = (props: SoupViewProps) => {
<Show when={!isMobile()}>
<SoupViewCreateButton />
</Show>
- <Show when={isMobile()}>
- <MobileFilterDrawer />
- </Show>
</Show>
</div>
</SplitHeaderLeft>
- <SplitHeaderRight>
- <Show when={isMobile() && !narrowSearchExpanded()}>
- <SettingsButton />
- </Show>
- <Show when={narrowSearchExpanded()}>
- <div class="flex-1 min-w-0">
- <SoupSearchbar
- variant="secondary"
- autoFocus
- initialValue={props.initialSearchText}
- onDismiss={() => setNarrowSearchExpanded(false)}
- />
- </div>
- </Show>
- <Show
- when={!isComponentListView('search')}
- fallback={
- <div class="grow ml-2">
+ <Show when={!isMobile()}>
+ <SplitHeaderRight>
+ <Show when={narrowSearchExpanded()}>
+ <div class="flex-1 min-w-0">
<SoupSearchbar
variant="secondary"
- placeholder="Search, @mention contacts"
+ autoFocus
initialValue={props.initialSearchText}
+ onDismiss={() => setNarrowSearchExpanded(false)}
/>
</div>
- }
- >
- <CollapsibleHeaderItem
- id="search"
- priority={0}
- onCollapsedChange={(isCollapsed) => {
- setSearchIsCollapsed(isCollapsed);
- if (!isCollapsed) setNarrowSearchExpanded(false);
- }}
- expanded={() => (
- <div class="w-60">
+ </Show>
+ <Show
+ when={!isComponentListView('search')}
+ fallback={
+ <div class="grow ml-2">
<SoupSearchbar
variant="secondary"
+ placeholder="Search, @mention contacts"
initialValue={props.initialSearchText}
/>
</div>
- )}
- collapsed={() => (
- <Show when={!narrowSearchExpanded()}>
- <Tooltip label="Search" hotkey={TOKENS.soup.openSearch}>
- <Button
- variant="ghost"
- class="p-1 rounded-xs"
- onClick={() => setNarrowSearchExpanded(true)}
- >
- <SearchIcon class="size-4 touch:size-6" />
- </Button>
- </Tooltip>
- </Show>
- )}
- />
- </Show>
- </SplitHeaderRight>
+ }
+ >
+ <CollapsibleHeaderItem
+ id="search"
+ priority={0}
+ onCollapsedChange={(isCollapsed) => {
+ setSearchIsCollapsed(isCollapsed);
+ if (!isCollapsed) setNarrowSearchExpanded(false);
+ }}
+ expanded={() => (
+ <div class="w-60">
+ <SoupSearchbar
+ variant="secondary"
+ initialValue={props.initialSearchText}
+ />
+ </div>
+ )}
+ collapsed={() => (
+ <Show when={!narrowSearchExpanded()}>
+ <Tooltip label="Search" hotkey={TOKENS.soup.openSearch}>
+ <Button
+ variant="ghost"
+ class="p-1 rounded-xs"
+ onClick={() => setNarrowSearchExpanded(true)}
+ >
+ <SearchIcon class="size-4 touch:size-6" />
+ </Button>
+ </Tooltip>
+ </Show>
+ )}
+ />
+ </Show>
+ </SplitHeaderRight>
+ </Show>
<SoupFiltersBar />
</div>
<Show when={hasLinkError()}>
@@ -527,11 +561,26 @@ export const SoupView = (props: SoupViewProps) => {
initialClientFilters={props.initialClientFilters}
initialGroupBy={props.initialGroupBy}
skipPersistedState={props.skipPersistedState}
+ onScrollOffsetBaseline={resetFloatingButtonScrollTracking}
+ onScrollOffsetChange={handleSoupScrollOffsetChange}
/>
</SoupViewFileDropzone>
</Suspense>
<Show when={isMobile()}>
- <SoupViewMobileCreateButton activeView={activeListView} />
+ <SoupViewMobileSettingsButton visible={floatingButtonsVisible} />
+ <SoupViewMobileSearchButton
+ open={mobileSearchOpen}
+ visible={floatingButtonsVisible}
+ onOpen={() => setMobileSearchOpen(true)}
+ />
+ <SoupViewMobileCreateButton
+ activeView={activeListView}
+ visible={floatingButtonsVisible}
+ />
+ <SoupViewMobileSearchBar
+ open={mobileSearchOpen}
+ onClose={() => setMobileSearchOpen(false)}
+ />
</Show>
</div>
<Show when={isMobile()}>
@@ -554,6 +603,8 @@ interface SoupViewListProps {
initialClientFilters?: SetPredicatesInput<string>;
initialGroupBy?: string;
skipPersistedState?: boolean;
+ onScrollOffsetBaseline?: (offset: number) => void;
+ onScrollOffsetChange?: (offset: number) => void;
}
export const SoupViewList = (props: SoupViewListProps) => {
@@ -816,6 +867,10 @@ export const SoupViewList = (props: SoupViewListProps) => {
HTMLDivElement | undefined
>();
+ createEffect(() => {
+ if (rows().length === 0) props.onScrollOffsetBaseline?.(0);
+ });
+
const entityById = createMemo(
() => {
const list = rows() ?? [];
@@ -970,10 +1025,12 @@ export const SoupViewList = (props: SoupViewListProps) => {
setSearchText(cached.searchText);
soup.focus.set(cached.focus);
virtualizerHandle()?.scrollTo(cached.scrollOffset ?? 0);
+ props.onScrollOffsetBaseline?.(cached.scrollOffset ?? 0);
registerFocusEffects(false);
return;
}
+ props.onScrollOffsetBaseline?.(0);
registerFocusEffects();
};
@@ -1093,6 +1150,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
)}
class="overflow-hidden flex min-w-0"
virtualizerRef={registerVirtualizerHandler}
+ onScrollOffsetChange={props.onScrollOffsetChange}
onScrollBottom={debouncedFetchMore}
scrollBottomOffset={300}
rows={rows()}
@@ -1358,6 +1416,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
const DEFAULT_ITEM_SIZE = 10;
const DEFAULT_OVERSCAN = 5;
+const FLOATING_BUTTON_SCROLL_UP_THRESHOLD = 5;
interface SoupListProps {
ref?: (el: HTMLElement) => void;
@@ -1367,6 +1426,7 @@ interface SoupListProps {
itemSize?: number;
overscan?: number;
children: (row: SoupRow, index: Accessor<number>) => JSX.Element;
+ onScrollOffsetChange?: (offset: number) => void;
onScrollBottom?: VoidFunction;
scrollBottomOffset?: number;
rows: SoupRow[];
@@ -1391,6 +1451,8 @@ const SoupList = (props: SoupListProps) => {
if (!handle) return;
+ props.onScrollOffsetChange?.(offset);
+
if (
handle.scrollSize - handle.viewportSize - offset <=
(props.scrollBottomOffset ?? 100)
@@ -1404,9 +1466,7 @@ const SoupList = (props: SoupListProps) => {
) => {
setVirtualizerHandle(handle);
- if (handle) {
- props.virtualizerRef?.(handle);
- }
+ if (handle) props.virtualizerRef?.(handle);
};
return (
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 f81ff438fd..d23c08741a 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -161,7 +161,10 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
return (
<div
- class="isolate relative w-full h-full overflow-clip text-ink"
+ class={cn(
+ 'isolate relative w-full h-full overflow-clip text-ink shrink-0 border-b border-edge-muted',
+ isMobile() && isListViewID(panel.handle.content().id) && 'hidden'
+ )}
data-split-header
ref={props.ref}
>
diff --git a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx
index 88eba45371..7e841dcda8 100644
--- a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx
@@ -121,6 +121,10 @@ export function SplitPanel(props: SplitPanelProps) {
return Boolean(splits && splits.length > 1);
}
+ const shouldHideSplitHeader = createMemo(
+ () => isMobile() && isListViewID(props.handle.content().id)
+ );
+
return (
<SoupContextProvider soup={nextSoup}>
<SplitPanelContext.Provider
@@ -170,10 +174,15 @@ export function SplitPanel(props: SplitPanelProps) {
multipleSplits() &&
!props.handle.isSpotLight()
}
- class="rounded-xl"
+ class="rounded-xl mobile:rounded-none mobile:after:hidden mobile:!border-0"
depth={1}
>
- <Panel.Header class="block min-h-10.25 touch:min-h-11.25 p-0 overflow-visible">
+ <Panel.Header
+ class={cn(
+ 'block min-h-10.25 touch:min-h-11.25 p-0 overflow-visible',
+ shouldHideSplitHeader() && 'hidden'
+ )}
+ >
<SplitHeader ref={setHeaderRef} />
</Panel.Header>