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 dock (#761)

Peter Chinmand552ed8fe18d
diff --git a/js/app/packages/app/component/HelpDrawer.tsx b/js/app/packages/app/component/HelpDrawer.tsx
index b678293cb9..8abb24c27b 100644
--- a/js/app/packages/app/component/HelpDrawer.tsx
+++ b/js/app/packages/app/component/HelpDrawer.tsx
@@ -316,7 +316,7 @@ export function HelpDrawerInner(props: HelpDrawerInnerProps) {
</Show>
</div>
<Show
- when={props.hotkeyExamples && !(isTouchDevice && isMobileWidth())}
+ when={props.hotkeyExamples && !(isTouchDevice() && isMobileWidth())}
>
<div class="hotkey-examples-container px-4 py-8 h-full basis-1/2">
<div class="grid grid-cols-[min-content_1fr] gap-x-8 gap-y-4">
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index 4628ff73f4..d4bda2f908 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -15,7 +15,6 @@ import { updateCookie } from '../util/updateCookie';
import Banner from './banner/Banner';
import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';
import { KommandMenu } from './command/Konsole';
-import { Dock } from './dock/Dock';
import GlobalShortcuts from './GlobalHotkeys';
import { ItemDndProvider } from './ItemDragAndDrop';
import { createMenuOpen, Launcher, setCreateMenuOpen } from './Launcher';
@@ -146,7 +145,7 @@ export function Layout(props: RouteSectionProps) {
<Show when={paywallOpen()}>
<Paywall />
</Show>
- <div class="p-[var(--gutter-size)] grow-1">
+ <div class="p-[var(--gutter-size)] ios:p-0 grow-1">
<Resize.Zone
gutter={8}
direction="horizontal"
@@ -166,7 +165,6 @@ export function Layout(props: RouteSectionProps) {
<Show
when={isAuthenticated() && !AUTH_URLS.includes(location.pathname)}
>
- <Dock />
<Launcher open={createMenuOpen()} onOpenChange={setCreateMenuOpen} />
</Show>
</Suspense>
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsx
index d522803465..b24900e313 100644
--- a/js/app/packages/app/component/Soup.tsx
+++ b/js/app/packages/app/component/Soup.tsx
@@ -14,6 +14,7 @@ import { fileTypeToResolvedBlockName } from '@core/constant/allBlocks';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { TOKENS } from '@core/hotkey/tokens';
import type { RegisterHotkeyReturn } from '@core/hotkey/types';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import type { BlockOrchestrator } from '@core/orchestrator';
import {
DEFAULT_VIEWS,
@@ -462,7 +463,12 @@ export function Soup() {
/>
</Show>
</div>
- <Show when={showHelpDrawer().has(selectedView() as DefaultView)}>
+ <Show
+ when={
+ showHelpDrawer().has(selectedView() as DefaultView) &&
+ !isNativeMobilePlatform()
+ }
+ >
<HelpDrawer viewId={view().id} />
</Show>
</div>
diff --git a/js/app/packages/app/component/UnifiedListEmptyState.tsx b/js/app/packages/app/component/UnifiedListEmptyState.tsx
index 2e85a0cd3e..a0242a8e99 100644
--- a/js/app/packages/app/component/UnifiedListEmptyState.tsx
+++ b/js/app/packages/app/component/UnifiedListEmptyState.tsx
@@ -168,7 +168,9 @@ export function EmptyStateInner(props: EmptyStateInnerProps) {
</div>
)}
</Show>
- <Show when={props.showDropZone && !(isTouchDevice && isMobileWidth())}>
+ <Show
+ when={props.showDropZone && !(isTouchDevice() && isMobileWidth())}
+ >
<div class="drop-zone flex flex-col items-center justify-center w-full py-8 border border-dashed border-edge-muted bg-hover">
<p class="text-ink-muted">Drag & drop files and folders here</p>
<p class="text-ink-muted">
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsx
index c953454580..ecc58ba200 100644
--- a/js/app/packages/app/component/UnifiedListView.tsx
+++ b/js/app/packages/app/component/UnifiedListView.tsx
@@ -267,7 +267,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
return;
}
- if (isTouchDevice) return;
+ if (isTouchDevice()) return;
if (!firstEntity) return;
setSelectedEntity(firstEntity);
@@ -1664,7 +1664,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
<Show when={contextAndModalState.selectedEntity}>
{(selectedEntity) => (
<ContextMenuContent mobileFullScreen>
- <Show when={isTouchDevice && isMobileWidth()}>
+ <Show when={isTouchDevice() && isMobileWidth()}>
<Entity
entity={selectedEntity()}
timestamp={
diff --git a/js/app/packages/app/component/auth/LoginOptions.tsx b/js/app/packages/app/component/auth/LoginOptions.tsx
index 3aa99d37a7..9a341e49ab 100644
--- a/js/app/packages/app/component/auth/LoginOptions.tsx
+++ b/js/app/packages/app/component/auth/LoginOptions.tsx
@@ -1,6 +1,7 @@
import { SERVER_HOSTS } from '@core/constant/servers';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import type { RedirectLocation } from '@core/util/authRedirect';
+import { getNativeMobilePlatform } from '@core/util/platform';
import IconApple from '@macro-icons/macro-apple.svg';
import IconGoogle from '@macro-icons/macro-google.svg';
import IconMail from '@macro-icons/macro-mail.svg';
@@ -30,7 +31,7 @@ export function LoginOptions(props: { setStage: Setter<Stage> }) {
return (
<div class="grid select-none">
- <Show when={isNativeMobilePlatform() === 'ios'}>
+ <Show when={getNativeMobilePlatform() === 'ios'}>
<div class="grid items-center justify-center p-5 border border-dashed border-ink border-t-0 [transition:color_var(--transition)] hover:text-accent hover:transition-none cursor-pointer">
<a class="grid grid-cols-[min-content_180px] gap-2.5 items-center justify-center" />
<IconApple />
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
new file mode 100644
index 0000000000..c65ee1fee2
--- /dev/null
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -0,0 +1,95 @@
+import WideChannel from '@macro-icons/wide/channel.svg';
+import WideEmail from '@macro-icons/wide/email.svg';
+import WideCode from '@macro-icons/wide/file-code.svg';
+import WidePlus from '@macro-icons/wide/plus.svg';
+import WideTask from '@macro-icons/wide/task.svg';
+import type { Component, JSX } from 'solid-js';
+import { setCreateMenuOpen } from '../Launcher';
+import { useSplitPanelOrThrow } from '../split-layout/layoutUtils';
+import { VIEWCONFIG_DEFAULTS_IDS_ENUM } from '../ViewConfig';
+
+type MobileDockButtonProps = {
+ icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>>;
+ label: string;
+ onClick: () => void;
+ active?: boolean;
+};
+
+function MobileDockButton(props: MobileDockButtonProps) {
+ return (
+ <button
+ onClick={props.onClick}
+ class="flex flex-col items-center justify-center w-[20%] py-4"
+ classList={{
+ 'text-ink-muted': !props.active,
+ 'text-ink bg-panel': props.active,
+ }}
+ >
+ <props.icon class="w-6 h-6" />
+ <span class="text-xs">{props.label}</span>
+ </button>
+ );
+}
+
+export function MobileDock() {
+ const splitContext = useSplitPanelOrThrow();
+ const { selectedView, setSelectedView } = splitContext.unifiedListContext;
+
+ const focusSearchInput = (viewId: string) => {
+ setTimeout(() => {
+ const el = document.getElementById(
+ `search-input-${splitContext.handle.id}-${viewId}`
+ );
+ if (el instanceof HTMLInputElement) {
+ el.focus();
+ } else {
+ (el as HTMLElement | null)?.focus?.();
+ }
+ }, 0);
+ };
+
+ return (
+ <div class="flex flex-row justify-between bg-linear-to-t from-page to-panel border-t border-edge-muted">
+ <MobileDockButton
+ icon={WideCode}
+ label="Search"
+ active={selectedView() === VIEWCONFIG_DEFAULTS_IDS_ENUM.all}
+ onClick={() => {
+ setSelectedView(VIEWCONFIG_DEFAULTS_IDS_ENUM.all);
+ focusSearchInput(VIEWCONFIG_DEFAULTS_IDS_ENUM.all);
+ }}
+ />
+ <MobileDockButton
+ icon={WideEmail}
+ label="Inbox"
+ active={selectedView() === VIEWCONFIG_DEFAULTS_IDS_ENUM.signal}
+ onClick={() => {
+ setSelectedView(VIEWCONFIG_DEFAULTS_IDS_ENUM.signal);
+ }}
+ />
+ <MobileDockButton
+ icon={WideChannel}
+ label="People"
+ active={selectedView() === VIEWCONFIG_DEFAULTS_IDS_ENUM.people}
+ onClick={() => {
+ setSelectedView(VIEWCONFIG_DEFAULTS_IDS_ENUM.people);
+ }}
+ />
+ <MobileDockButton
+ icon={WideTask}
+ label="Tasks"
+ active={selectedView() === VIEWCONFIG_DEFAULTS_IDS_ENUM.tasks}
+ onClick={() => {
+ setSelectedView(VIEWCONFIG_DEFAULTS_IDS_ENUM.tasks);
+ }}
+ />
+ <MobileDockButton
+ icon={WidePlus}
+ label="Create"
+ onClick={() => {
+ setCreateMenuOpen(true);
+ }}
+ />
+ </div>
+ );
+}
diff --git a/js/app/packages/app/component/settings/Appearance.tsx b/js/app/packages/app/component/settings/Appearance.tsx
index 7ef509d809..65b8ed4297 100644
--- a/js/app/packages/app/component/settings/Appearance.tsx
+++ b/js/app/packages/app/component/settings/Appearance.tsx
@@ -38,10 +38,10 @@ export function Appearance() {
"
class="appearance-container"
>
- <div style="grid-area: tools;"><ThemeTools /></div>
- <div style="grid-area: basic;"><ThemeEditorBasic /></div>
+ <div class="ios:hidden" style="grid-area: tools;"><ThemeTools /></div>
+ <div class="ios:hidden" style="grid-area: basic;"><ThemeEditorBasic /></div>
<div style="grid-area: list; overflow: hidden;"><ThemeList/></div>
- <div style="grid-area: advanced; overflow: hidden;"><ThemeEditorAdvanced /></div>
+ <div class="ios:hidden" style="grid-area: advanced; overflow: hidden;"><ThemeEditorAdvanced /></div>
{/*<Show when={ENABLE_CUSTOM_CURSOR}>
<div
diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsx
index 669ba47449..0b5fe3547a 100644
--- a/js/app/packages/app/component/settings/Settings.tsx
+++ b/js/app/packages/app/component/settings/Settings.tsx
@@ -21,7 +21,11 @@ const SCROLL_THRESHOLD = 10;
const { track, TrackingEvents } = withAnalytics();
-export function SettingsPanel() {
+type SettingsPanelProps = {
+ hide?: boolean;
+};
+
+export function SettingsPanel(props: SettingsPanelProps) {
const { settingsOpen, closeSettings, activeTabId, setActiveTabId } = useSettingsState();
const permissions = usePermissions();
const orgName = useOrganizationName();
@@ -121,9 +125,9 @@ export function SettingsPanel() {
return (
<div
- class="size-full invisible"
+ class="size-full"
classList={{
- visible: settingsOpen() || spotlight(),
+ invisible: props.hide,
}}
>
<SplitlikeContainer
@@ -145,13 +149,15 @@ export function SettingsPanel() {
{/* Header with tabs */}
<div class="relative isolate shrink-0 border-b border-edge-muted">
<div class="flex items-center px-2 h-[2.5rem]">
- <IconButton
- icon={CloseIcon}
- onClick={closeSettings}
- tooltip={{ label: 'Close Settings' }}
- theme="clear"
- size="sm"
- />
+ <Show when={!isNativeMobilePlatform()}>
+ <IconButton
+ icon={CloseIcon}
+ onClick={closeSettings}
+ tooltip={{ label: 'Close Settings' }}
+ theme="clear"
+ size="sm"
+ />
+ </Show>
{/* Left clip boundary indicator */}
<div
@@ -224,15 +230,17 @@ export function SettingsPanel() {
<div class="flex-1" />
- <IconButton
- icon={spotlight() ? ContractIcon : ExpandIcon}
- onClick={() => setSpotlight(!spotlight())}
- tooltip={{
- label: spotlight() ? 'Exit Spotlight' : 'Enter Spotlight Mode'
- }}
- theme="clear"
- size="sm"
- />
+ <Show when={!isNativeMobilePlatform()}>
+ <IconButton
+ icon={spotlight() ? ContractIcon : ExpandIcon}
+ onClick={() => setSpotlight(!spotlight())}
+ tooltip={{
+ label: spotlight() ? 'Exit Spotlight' : 'Enter Spotlight Mode'
+ }}
+ theme="clear"
+ size="sm"
+ />
+ </Show>
</div>
</div>
diff --git a/js/app/packages/app/component/settings/SettingsWrapper.tsx b/js/app/packages/app/component/settings/SettingsWrapper.tsx
index f735248f72..60d78f605d 100644
--- a/js/app/packages/app/component/settings/SettingsWrapper.tsx
+++ b/js/app/packages/app/component/settings/SettingsWrapper.tsx
@@ -16,7 +16,7 @@ export const SettingsWrapper = () => {
hidden={() => !isSettingsPanelOpen()}
persistent={true}
>
- <SettingsPanel />
+ <SettingsPanel hide={!isSettingsPanelOpen()} />
</Resize.Panel>
</Show>
);
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index 182954d42a..c9d384ff64 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -6,6 +6,7 @@ import type { ViewId } from '@core/types/view';
import { type JSXElement, lazy } from 'solid-js';
import { EmailCompose } from '../../../block-email/component/Compose';
import { Soup } from '../Soup';
+import { SettingsPanel } from '../settings/Settings';
export type ComponentFactory = (params?: Record<string, any>) => JSXElement;
@@ -58,6 +59,7 @@ registerComponent('loading', () => <LoadingBlock />);
registerComponent('channel-compose', () => <ChannelCompose />);
registerComponent('email-compose', () => <EmailCompose />);
registerComponent('task-compose', () => <ComposeTask />);
+registerComponent('settings', () => <SettingsPanel />);
if (LOCAL_ONLY) {
registerComponent(
diff --git a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx b/js/app/packages/app/component/split-layout/components/SplitContainer.tsx
index ba87a9ccd2..1f66f28311 100644
--- a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitContainer.tsx
@@ -1,6 +1,8 @@
import MacroJump from '@app/component/MacroJump';
+import { MobileDock } from '@app/component/mobile/MobileDock';
import { globalSplitManager } from '@app/signal/splitLayout';
import { ClippedPanel } from '@core/component/ClippedPanel';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { isRightPanelOpen, isSettingsPanelOpen } from '@core/signal/layout';
import { createElementSize } from '@solid-primitives/resize-observer';
import {
@@ -114,6 +116,9 @@ export function SplitContainer(
<Show when={panel.handle.isSpotLight()}>
<MacroJump tabbableParent={ref} />
</Show>
+ <Show when={isNativeMobilePlatform()}>
+ <MobileDock />
+ </Show>
</div>
</ClippedPanel>
</div>
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 7eca2aced0..e92daa3c16 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -8,6 +8,7 @@ import CaretLeft from '@icon/regular/caret-left.svg';
import CaretRight from '@icon/regular/caret-right.svg';
import SplitIcon from '@icon/regular/square-split-horizontal.svg';
import CloseIcon from '@icon/regular/x.svg';
+import IconGear from '@macro-icons/macro-gear.svg';
import {
createEffect,
createMemo,
@@ -19,6 +20,11 @@ import {
} from 'solid-js';
import { Portal } from 'solid-js/web';
import { SplitLayoutContext, SplitPanelContext } from '../context';
+import { useSplitLayout } from '../layout';
+import {
+ createActiveSplitMemo,
+ createIsActiveSplitContentMemo,
+} from '../layoutUtils';
import { canSpotlight } from '../utils/canSpotlight';
function SplitBackButton() {
@@ -130,6 +136,31 @@ function SplitControlButtons() {
);
}
+function SplitSettingsButton() {
+ const { replaceSplit } = useSplitLayout();
+ const activeSplit = createActiveSplitMemo();
+ const isSettingsSplitOpen = createIsActiveSplitContentMemo(
+ activeSplit,
+ 'component',
+ 'settings'
+ );
+
+ return (
+ <IconButton
+ theme={isSettingsSplitOpen() ? 'accent' : 'clear'}
+ onClick={() => {
+ if (isSettingsSplitOpen()) {
+ activeSplit()?.goBack();
+ return;
+ }
+ replaceSplit({ type: 'component', id: 'settings' });
+ }}
+ icon={IconGear}
+ size="lg"
+ />
+ );
+}
+
export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
const ctx = useContext(SplitPanelContext);
if (!ctx)
@@ -164,6 +195,9 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
<SplitPreviewToggle />
<SplitSpotlightButton />
</div>
+ <div class="z-2 relative items-center bg-panel pr-2 h-full hidden ios:flex">
+ <SplitSettingsButton />
+ </div>
</div>
</div>
);
diff --git a/js/app/packages/app/component/split-layout/layoutUtils.ts b/js/app/packages/app/component/split-layout/layoutUtils.ts
index a136eb411b..9cb9f1b568 100644
--- a/js/app/packages/app/component/split-layout/layoutUtils.ts
+++ b/js/app/packages/app/component/split-layout/layoutUtils.ts
@@ -3,9 +3,14 @@ import type { BlockAlias, BlockName } from '@core/block';
import { isBlockAlias, resolveBlockAlias } from '@core/constant/allBlocks';
import type { ViewId } from '@core/types/view';
import { createCallback } from '@solid-primitives/rootless';
-import { useContext } from 'solid-js';
+import { type Accessor, createMemo, useContext } from 'solid-js';
import { SplitLayoutContext, SplitPanelContext } from './context';
-import type { SplitContent, SplitManager } from './layoutManager';
+import type {
+ SplitContent,
+ SplitContentType,
+ SplitHandle,
+ SplitManager,
+} from './layoutManager';
export function decodePairs(segments: string[]): SplitContent[] {
const pairs: SplitContent[] = [];
@@ -126,9 +131,47 @@ export function focusAdjacentSplit(direction: 'left' | 'right') {
}
/**
- * Check if there's a unified-list split with a particular view open.
+ * Check if there's a unified-list split with a particular view open. Note: not necessarily the active split.
*/
-export function isViewOpen(manager: SplitManager, viewId: ViewId): boolean {
+export function isViewOpen(manager: SplitManager | undefined, viewId: ViewId) {
+ if (!manager) return false;
const split = manager.getSplitByContent('component', 'unified-list');
return split?.meta()?.viewId === viewId;
}
+
+/**
+ * Reactive accessor indicating whether there's a unified-list split with a particular view open. Note: not necessarily the active split.
+ */
+export function createIsViewOpenMemo(
+ manager: SplitManager | undefined,
+ viewId: ViewId
+) {
+ return createMemo(() => isViewOpen(manager, viewId));
+}
+
+/**
+ * Reactive accessor for the currently active split (via the global split manager).
+ */
+export function createActiveSplitMemo(manager?: SplitManager) {
+ return createMemo<SplitHandle | undefined>(() => {
+ const resolvedManager = manager ?? globalSplitManager();
+ if (!resolvedManager) return;
+ const activeSplitId = resolvedManager.activeSplitId();
+ return activeSplitId ? resolvedManager.getSplit(activeSplitId) : undefined;
+ });
+}
+
+/**
+ * Reactive boolean accessor indicating whether the active split is currently
+ * showing a specific component content id.
+ */
+export function createIsActiveSplitContentMemo(
+ activeSplit: Accessor<SplitHandle | undefined>,
+ contentType: SplitContentType,
+ id: string
+) {
+ return createMemo(() => {
+ const content = activeSplit()?.content();
+ return content?.type === contentType && content.id === id;
+ });
+}
diff --git a/js/app/packages/block-canvas/component/nodes/DSSFile.tsx b/js/app/packages/block-canvas/component/nodes/DSSFile.tsx
index 7e3744e07d..45b746916c 100644
--- a/js/app/packages/block-canvas/component/nodes/DSSFile.tsx
+++ b/js/app/packages/block-canvas/component/nodes/DSSFile.tsx
@@ -151,23 +151,27 @@ export function File(props: { node: FileNode; mode: RenderMode }) {
<div
class="document-mention internal-link"
onMouseEnter={() => {
- if (!isTouchDevice && !mouseIsDown() && selectedTool() !== Tools.Line) {
+ if (
+ !isTouchDevice() &&
+ !mouseIsDown() &&
+ selectedTool() !== Tools.Line
+ ) {
debouncedSetPreviewOpen(true);
}
}}
onMouseLeave={() => {
- if (!isTouchDevice) {
+ if (!isTouchDevice()) {
debouncedSetPreviewOpen.clear();
debouncedSetPreviewOpen(false);
}
}}
ontouchstart={(e) => {
- if (isTouchDevice) {
+ if (isTouchDevice()) {
e.preventDefault();
}
}}
ontouchend={(e) => {
- if (isTouchDevice) {
+ if (isTouchDevice()) {
e.preventDefault();
if (matches(item(), (i) => !i.loading && i.access === 'access')) {
replaceOrInsertSplit({
diff --git a/js/app/packages/block-channel/component/AttachMenu.tsx b/js/app/packages/block-channel/component/AttachMenu.tsx
index 9a44bcf39e..cfca9fc747 100644
--- a/js/app/packages/block-channel/component/AttachMenu.tsx
+++ b/js/app/packages/block-channel/component/AttachMenu.tsx
@@ -193,11 +193,11 @@ export function AttachMenu(props: AttachMenuProps) {
>
<OldMenuItem
text={
- isTouchDevice
+ isTouchDevice()
? 'Upload from your device'
: 'Upload from your computer'
}
- icon={isTouchDevice ? DeviceMobileIcon : LaptopIcon}
+ icon={isTouchDevice() ? DeviceMobileIcon : LaptopIcon}
/>
</div>
</OldMenu>
diff --git a/js/app/packages/block-channel/component/BaseInput.tsx b/js/app/packages/block-channel/component/BaseInput.tsx
index 515b0ea419..ecbfca7348 100644
--- a/js/app/packages/block-channel/component/BaseInput.tsx
+++ b/js/app/packages/block-channel/component/BaseInput.tsx
@@ -210,7 +210,7 @@ export function BaseInput(props: BaseInputProps) {
onMount(() => {
attachFn(containerRef);
- if (!isTouchDevice && !isMobileWidth()) {
+ if (!isTouchDevice() && !isMobileWidth()) {
setTimeout(() => {
if (
props.autoFocusOnMount === true ||
diff --git a/js/app/packages/block-channel/component/Message/MessageContainer.tsx b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
index c38272cdd5..bc7c5e97f1 100644
--- a/js/app/packages/block-channel/component/Message/MessageContainer.tsx
+++ b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
@@ -477,7 +477,7 @@ export function MessageContainer(props: MessageProps) {
return (
<div
- class={`shrink-0 flex justify-center w-full ${isTouchDevice ? 'no-select-children' : ''}
+ class={`shrink-0 flex justify-center w-full ${isTouchDevice() ? 'no-select-children' : ''}
[--thread-shift:23px] @sm:[--thread-shift:46px] [--user-icon-width:30px] @sm:[--user-icon-width:40px] [--left-of-connector:20px] @sm:[--left-of-connector:28px] [--left-of-user-icon:calc(var(--left-of-connector)-var(--user-icon-width)/2)]`}
ref={(el) => {
props.setMessageContainerRef?.(el);
@@ -676,12 +676,12 @@ export function MessageContainer(props: MessageProps) {
handleClose={() => {
setReactionSearchOpen(false);
}}
- fullWidth={isTouchDevice && isMobileWidth()}
+ fullWidth={isTouchDevice() && isMobileWidth()}
insideMenu={true}
/>
</Match>
</Switch>
- <Show when={isTouchDevice && isMobileWidth()}>
+ <Show when={isTouchDevice() && isMobileWidth()}>
<ContextMenu.Item class="mt-4 shrink-1 overflow-y-scroll overflow-x-hidden">
<MessageComponent
focused={props.isFocused}
diff --git a/js/app/packages/block-email/component/AttachMenu.tsx b/js/app/packages/block-email/component/AttachMenu.tsx
index 21cf3dcdd1..caf07ee5f7 100644
--- a/js/app/packages/block-email/component/AttachMenu.tsx
+++ b/js/app/packages/block-email/component/AttachMenu.tsx
@@ -229,11 +229,11 @@ export function AttachMenu(props: AttachMenuProps) {
>
<OldMenuItem
text={
- isTouchDevice
+ isTouchDevice()
? 'Upload from your device'
: 'Upload from your computer'
}
- icon={isTouchDevice ? DeviceMobileIcon : LaptopIcon}
+ icon={isTouchDevice() ? DeviceMobileIcon : LaptopIcon}
/>
</div>
</OldMenu>
diff --git a/js/app/packages/block-md/component/MarkdownPopup.tsx b/js/app/packages/block-md/component/MarkdownPopup.tsx
index 80b354b076..0760033da7 100644
--- a/js/app/packages/block-md/component/MarkdownPopup.tsx
+++ b/js/app/packages/block-md/component/MarkdownPopup.tsx
@@ -402,7 +402,9 @@ export function MarkdownPopup(props: {
</Show>
<Show
when={
- !isMobileWidth() && !isTouchDevice && (canEdit() || canComment())
+ !isMobileWidth() &&
+ !isTouchDevice() &&
+ (canEdit() || canComment())
}
>
<FormatTools withinPopup />
diff --git a/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx b/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx
index dd209a930c..add6fe1bd2 100644
--- a/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx
+++ b/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx
@@ -349,11 +349,11 @@ export function ChatAttachMenu(props: ChatAttachMenuProps) {
>
<OldMenuItem
text={
- isTouchDevice
+ isTouchDevice()
? 'Upload from your device'
: 'Upload from your computer'
}
- icon={isTouchDevice ? DeviceMobileIcon : LaptopIcon}
+ icon={isTouchDevice() ? DeviceMobileIcon : LaptopIcon}
spacerTop
/>
</div>
diff --git a/js/app/packages/core/component/ClippedPanel.tsx b/js/app/packages/core/component/ClippedPanel.tsx
index 0f80f36f8b..0d62f0d8b4 100644
--- a/js/app/packages/core/component/ClippedPanel.tsx
+++ b/js/app/packages/core/component/ClippedPanel.tsx
@@ -1,5 +1,6 @@
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { cornerClip } from '@core/util/clipPath';
-import type { JSXElement, Ref } from 'solid-js';
+import { type JSXElement, type Ref, Show } from 'solid-js';
import { beveledCorners } from '../../block-theme/signals/themeSignals';
interface PanelProps {
@@ -14,52 +15,57 @@ interface PanelProps {
export function ClippedPanel(props: PanelProps) {
return (
- <div
- style={{
- 'background-image': `linear-gradient(${props.active ? 'var(--color-accent), var(--color-edge-muted) 80%' : 'var(--color-edge-muted)'} )`,
- 'clip-path': !beveledCorners()
- ? cornerClip(
- props.tl ? '0.5rem' : 0,
- props.tr ? '0.5rem' : 0,
- props.br ? '0.5rem' : 0,
- props.bl ? '0.5rem' : 0
- )
- : '',
- 'border-radius': beveledCorners()
- ? `
- ${props.tl ? '16px' : '4px'}
- ${props.tr ? '16px' : '4px'}
- ${props.br ? '16px' : '4px'}
- ${props.bl ? '16px' : '4px'}
- `
- : '0',
- }}
- class="p-px h-full w-full box-border"
+ <Show
+ when={!isNativeMobilePlatform()}
+ fallback={<div class="size-full">{props.children}</div>}
>
<div
style={{
+ 'background-image': `linear-gradient(${props.active ? 'var(--color-accent), var(--color-edge-muted) 80%' : 'var(--color-edge-muted)'} )`,
'clip-path': !beveledCorners()
? cornerClip(
- props.tl ? 'calc(0.5rem - 0.5px)' : 0,
- props.tr ? 'calc(0.5rem - 0.5px)' : 0,
- props.br ? 'calc(0.5rem - 0.5px)' : 0,
- props.bl ? 'calc(0.5rem - 0.5px)' : 0
+ props.tl ? '0.5rem' : 0,
+ props.tr ? '0.5rem' : 0,
+ props.br ? '0.5rem' : 0,
+ props.bl ? '0.5rem' : 0
)
: '',
'border-radius': beveledCorners()
? `
- ${props.tl ? '15.5px' : '3.3px'}
- ${props.tr ? '15.5px' : '3.3px'}
- ${props.br ? '15.5px' : '3.3px'}
- ${props.bl ? '15.5px' : '3.3px'}
+ ${props.tl ? '16px' : '4px'}
+ ${props.tr ? '16px' : '4px'}
+ ${props.br ? '16px' : '4px'}
+ ${props.bl ? '16px' : '4px'}
`
: '0',
}}
- class="h-full w-full box-border overflow-hidden bg-panel"
- ref={props.ref}
+ class="p-px h-full w-full box-border"
>
- {props.children}
+ <div
+ style={{
+ 'clip-path': !beveledCorners()
+ ? cornerClip(
+ props.tl ? 'calc(0.5rem - 0.5px)' : 0,
+ props.tr ? 'calc(0.5rem - 0.5px)' : 0,
+ props.br ? 'calc(0.5rem - 0.5px)' : 0,
+ props.bl ? 'calc(0.5rem - 0.5px)' : 0
+ )
+ : '',
+ 'border-radius': beveledCorners()
+ ? `
+ ${props.tl ? '15.5px' : '3.3px'}
+ ${props.tr ? '15.5px' : '3.3px'}
+ ${props.br ? '15.5px' : '3.3px'}
+ ${props.bl ? '15.5px' : '3.3px'}
+ `
+ : '0',
+ }}
+ class="h-full w-full box-border overflow-hidden bg-panel"
+ ref={props.ref}
+ >
+ {props.children}
+ </div>
</div>
- </div>
+ </Show>
);
}
diff --git a/js/app/packages/core/component/ImageGalleryPreview.tsx b/js/app/packages/core/component/ImageGalleryPreview.tsx
index 2f4f32cd5e..5ed2e31c67 100644
--- a/js/app/packages/core/component/ImageGalleryPreview.tsx
+++ b/js/app/packages/core/component/ImageGalleryPreview.tsx
@@ -97,13 +97,13 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
};
const handleTouchStart = (e: TouchEvent) => {
- if (!isMobileWidth() || !isTouchDevice) return;
+ if (!isMobileWidth() || !isTouchDevice()) return;
setTouchStartX(e.touches[0].clientX);
setIsSwiping(false);
};
const handleTouchMove = (e: TouchEvent) => {
- if (!isMobileWidth() || !isTouchDevice) return;
+ if (!isMobileWidth() || !isTouchDevice()) return;
setTouchEndX(e.touches[0].clientX);
const diffX = Math.abs(touchStartX() - e.touches[0].clientX);
@@ -113,7 +113,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
};
const handleTouchEnd = () => {
- if (!isMobileWidth() || !isTouchDevice || !isSwiping()) return;
+ if (!isMobileWidth() || !isTouchDevice() || !isSwiping()) return;
const swipeThreshold = 50;
const diff = touchStartX() - touchEndX();
@@ -172,7 +172,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
};
const handleMouseMove = () => {
- if (isMobileWidth() || isTouchDevice) return;
+ if (isMobileWidth() || isTouchDevice()) return;
setIsToolbarVisible(true);
@@ -188,7 +188,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
const copyToClipboard = async () => {
const imageUrl = currentImageUrl();
if (!imageUrl) return;
- if (isTouchDevice) {
+ if (isTouchDevice()) {
try {
const blob = await platformFetch(imageUrl).then((res) => res.blob());
const file = new File([blob], 'image.png', { type: blob.type });
@@ -253,7 +253,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
};
const copyToClipboardById = async (id: string) => {
- if (isTouchDevice) {
+ if (isTouchDevice()) {
try {
const blob = await platformFetch(getImageUrl(id)).then((res) =>
res.blob()
@@ -358,7 +358,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
window.addEventListener('keydown', handleKeyDown);
- if (!isMobileWidth() && !isTouchDevice) {
+ if (!isMobileWidth() && !isTouchDevice()) {
setTimeout(() => {
window.addEventListener('mousemove', handleMouseMove);
}, 500);
@@ -388,7 +388,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
}
};
- if (isMobileWidth() && isTouchDevice) {
+ if (isMobileWidth() && isTouchDevice()) {
image.addEventListener('touchstart', handleTouchStartWrapper, {
passive: true,
});
@@ -411,7 +411,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
clearTimeout(hideToolbarTimeout);
}
- if (isMobileWidth() && isTouchDevice) {
+ if (isMobileWidth() && isTouchDevice()) {
image.removeEventListener('touchstart', handleTouchStartWrapper);
image.removeEventListener('touchmove', handleTouchMoveWrapper);
image.removeEventListener('touchend', handleTouchEndWrapper);
@@ -506,7 +506,7 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
'-ms-user-select': 'none',
'user-select': 'none',
}}
- draggable={!isTouchDevice}
+ draggable={!isTouchDevice()}
/>
</Dialog.Trigger>
</div>
@@ -523,9 +523,9 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
class="absolute top-4 right-4 bg-dialog backdrop-blur-sm rounded-lg border border-edge p-1 flex flex-row items-center gap-1 shadow-md transition-opacity duration-300"
classList={{
'opacity-100':
- isMobileWidth() || isTouchDevice || isToolbarVisible(),
+ isMobileWidth() || isTouchDevice() || isToolbarVisible(),
'opacity-0 pointer-events-none':
- !isMobileWidth() && !isTouchDevice && !isToolbarVisible(),
+ !isMobileWidth() && !isTouchDevice() && !isToolbarVisible(),
}}
style={{ 'z-index': stackingContext.zModal + 1 }}
>
@@ -552,16 +552,18 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
</div>
{/* Navigation arrows */}
- <Show when={!isMobileWidth() || !isTouchDevice}>
+ <Show when={!isMobileWidth() || !isTouchDevice()}>
<Show when={props.images.length > 1}>
<button
class="absolute left-4 top-1/2 -translate-y-1/2 bg-dialog backdrop-blur-sm rounded-lg border border-edge p-2 shadow-md hover:bg-button transition-opacity duration-300"
classList={{
hidden: !hasPrevious(),
'opacity-100':
- isMobileWidth() || isTouchDevice || isToolbarVisible(),
+ isMobileWidth() || isTouchDevice() || isToolbarVisible(),
'opacity-0 pointer-events-none':
- !isMobileWidth() && !isTouchDevice && !isToolbarVisible(),
+ !isMobileWidth() &&
+ !isTouchDevice() &&
+ !isToolbarVisible(),
}}
style={{ 'z-index': stackingContext.zModal + 1 }}
onClick={navigatePrevious}
@@ -577,9 +579,11 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
classList={{
hidden: !hasNext(),
'opacity-100':
- isMobileWidth() || isTouchDevice || isToolbarVisible(),
+ isMobileWidth() || isTouchDevice() || isToolbarVisible(),
'opacity-0 pointer-events-none':
- !isMobileWidth() && !isTouchDevice && !isToolbarVisible(),
+ !isMobileWidth() &&
+ !isTouchDevice() &&
+ !isToolbarVisible(),
}}
style={{ 'z-index': stackingContext.zModal + 1 }}
onClick={navigateNext}
@@ -596,9 +600,9 @@ export const ImageGalleryPreview: Component<ImageGalleryPreviewProps> = (
class="absolute top-4 left-4 bg-dialog backdrop-blur-sm rounded-lg border border-edge px-3 py-1.5 shadow-md transition-opacity duration-300"
classList={{
'opacity-100':
- isMobileWidth() || isTouchDevice || isToolbarVisible(),
+ isMobileWidth() || isTouchDevice() || isToolbarVisible(),
'opacity-0 pointer-events-none':
- !isMobileWidth() && !isTouchDevice && !isToolbarVisible(),
+ !isMobileWidth() && !isTouchDevice() && !isToolbarVisible(),
}}
style={{ 'z-index': stackingContext.zModal + 1 }}
>
diff --git a/js/app/packages/core/component/ImagePreview.tsx b/js/app/packages/core/component/ImagePreview.tsx
index 09ad6f1107..36a99f2b7b 100644
--- a/js/app/packages/core/component/ImagePreview.tsx
+++ b/js/app/packages/core/component/ImagePreview.tsx
@@ -139,7 +139,7 @@ export function ImagePreview(props: ImagePreviewProps) {
};
const handleMouseMove = () => {
- if (isMobileWidth() || isTouchDevice) return;
+ if (isMobileWidth() || isTouchDevice()) return;
setIsToolbarVisible(true);
@@ -191,7 +191,7 @@ export function ImagePreview(props: ImagePreviewProps) {
const blob = await getBlob();
if (!blob) throw new Error('No blob');
- if (isTouchDevice && navigator.share) {
+ if (isTouchDevice() && navigator.share) {
const file = new File([blob], 'image.png', { type: blob.type });
await navigator.share({
files: [file],
@@ -241,7 +241,7 @@ export function ImagePreview(props: ImagePreviewProps) {
image.addEventListener('panzoomchange', updateCursor);
image.addEventListener('wheel', panzoom.zoomWithWheel);
- if (!isMobileWidth() && !isTouchDevice) {
+ if (!isMobileWidth() && !isTouchDevice()) {
setTimeout(() => {
window.addEventListener('mousemove', handleMouseMove);
}, 500);
@@ -319,7 +319,7 @@ export function ImagePreview(props: ImagePreviewProps) {
'-ms-user-select': 'none',
'user-select': 'none',
}}
- draggable={!isTouchDevice}
+ draggable={!isTouchDevice()}
/>
</Show>
</Dialog.Trigger>
@@ -332,9 +332,9 @@ export function ImagePreview(props: ImagePreviewProps) {
class="absolute top-4 right-4 bg-dialog rounded-lg border border-edge p-1 flex flex-row items-center gap-1 shadow-md transition-opacity duration-300"
classList={{
'opacity-100':
- isMobileWidth() || isTouchDevice || isToolbarVisible(),
+ isMobileWidth() || isTouchDevice() || isToolbarVisible(),
'opacity-0 pointer-events-none':
- !isMobileWidth() && !isTouchDevice && !isToolbarVisible(),
+ !isMobileWidth() && !isTouchDevice() && !isToolbarVisible(),
}}
style={{ 'z-index': stackingContext.zModal + 1 }}
>
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx
index 3dbf47c8a4..c73e6c5803 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx
@@ -336,23 +336,23 @@ export function DocumentMention(props: DocumentMentionDecoratorProps) {
}}
ref={inlinePreviewRef}
onMouseEnter={() => {
- if (!isTouchDevice) {
+ if (!isTouchDevice()) {
debouncedSetPreviewOpen(true);
}
}}
onMouseLeave={() => {
- if (!isTouchDevice) {
+ if (!isTouchDevice()) {
debouncedSetPreviewOpen.clear();
debouncedSetPreviewOpen(false);
}
}}
ontouchstart={(e) => {
- if (isTouchDevice) {
+ if (isTouchDevice()) {
e.preventDefault();
}
}}
ontouchend={(e) => {
- if (isTouchDevice) {
+ if (isTouchDevice()) {
e.preventDefault();
if (matches(item(), (i) => !i.loading && i.access === 'access')) {
open(null);
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/MediaButtons.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/MediaButtons.tsx
index 0ef520e03b..27244e01ea 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/MediaButtons.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/MediaButtons.tsx
@@ -62,7 +62,7 @@ export function MediaButtons(props: MediaButtonsProps) {
/>
</Dialog.Trigger>
</Show>
- <Show when={props.newTab && !isMobileWidth() && !isTouchDevice}>
+ <Show when={props.newTab && !isMobileWidth() && !isTouchDevice()}>
<IconButton
class="m-0"
icon={() => <NewTab class="size-5" />}
@@ -127,7 +127,9 @@ export function MediaButtons(props: MediaButtonsProps) {
}}
/>
</Show>
- <Show when={props.newTab && !isMobileWidth() && !isTouchDevice}>
+ <Show
+ when={props.newTab && !isMobileWidth() && !isTouchDevice()}
+ >
<MenuItem
text="Open in new tab"
icon={NewTab}
diff --git a/js/app/packages/core/component/LexicalMarkdown/directive/floatWithSelection.ts b/js/app/packages/core/component/LexicalMarkdown/directive/floatWithSelection.ts
index 5b8ae9d046..4b9ea193ef 100644
--- a/js/app/packages/core/component/LexicalMarkdown/directive/floatWithSelection.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/directive/floatWithSelection.ts
@@ -79,9 +79,9 @@ export function floatWithSelection(
if (anchor) {
setCurrentAnchor(anchor);
const { placement } = await computePosition(anchor, floatingEl, {
- placement: isTouchDevice ? 'top-start' : 'bottom-start',
+ placement: isTouchDevice() ? 'top-start' : 'bottom-start',
middleware: [
- isTouchDevice
+ isTouchDevice()
? null
: flip({
fallbackStrategy: 'initialPlacement',
diff --git a/js/app/packages/core/component/Menu.tsx b/js/app/packages/core/component/Menu.tsx
index e0f09a242b..62df1a078f 100644
--- a/js/app/packages/core/component/Menu.tsx
+++ b/js/app/packages/core/component/Menu.tsx
@@ -129,7 +129,7 @@ export type MenuItemProps =
| CheckboxMenuItemProps
| RadioMenuItemProps;
-export const MENU_ITEM_CLASS = `flex flex-row w-full gap-1.5 tracking-tight ${isMobileWidth() && isTouchDevice ? 'py-2 px-1 text-base' : 'py-1 pl-2 pr-2 text-sm'} font-medium justify-between items-center focus-bracket`;
+export const MENU_ITEM_CLASS = `flex flex-row w-full gap-1.5 tracking-tight ${isMobileWidth() && isTouchDevice() ? 'py-2 px-1 text-base' : 'py-1 pl-2 pr-2 text-sm'} font-medium justify-between items-center focus-bracket`;
/**
* A menu item component that can be used interchangeably within either a ContextMenu or DropdownMenu.
@@ -187,7 +187,7 @@ export function MenuItem(props: MenuItemProps) {
>
<Show when={props.selectorType === 'checkbox'}>
<div
- class={`${isMobileWidth() && isTouchDevice ? 'w-5 h-5' : 'w-4 h-4'} shrink-0 flex items-center justify-center`}
+ class={`${isMobileWidth() && isTouchDevice() ? 'w-5 h-5' : 'w-4 h-4'} shrink-0 flex items-center justify-center`}
>
<CheckIcon
class={`w-[14px] h-[14px] shrink-0 rounded-sm p-[2px] ${
@@ -200,7 +200,7 @@ export function MenuItem(props: MenuItemProps) {
</Show>
<Show when={props.selectorType === 'radio'}>
<div
- class={`flex items-center justify-center shrink-0 ${isMobileWidth() && isTouchDevice ? 'w-5 h-5' : 'w-4 h-4'}`}
+ class={`flex items-center justify-center shrink-0 ${isMobileWidth() && isTouchDevice() ? 'w-5 h-5' : 'w-4 h-4'}`}
>
<div
class={`w-[14px] h-[14px] shrink-0 rounded-full ${
@@ -218,7 +218,7 @@ export function MenuItem(props: MenuItemProps) {
component={
props.icon as Component<JSX.SvgSVGAttributes<SVGSVGElement>>
}
- class={`${isMobileWidth() && isTouchDevice ? 'w-5 h-5' : 'w-4 h-4'} shrink-0 ${props.iconClass ?? ''}`}
+ class={`${isMobileWidth() && isTouchDevice() ? 'w-5 h-5' : 'w-4 h-4'} shrink-0 ${props.iconClass ?? ''}`}
/>
</Show>
<Show when={typeof props.icon === 'object'}>
@@ -256,7 +256,7 @@ export function SubTrigger(props: {
component={
props.icon as Component<JSX.SvgSVGAttributes<SVGSVGElement>>
}
- class={`${isMobileWidth() && isTouchDevice ? 'w-5 h-5' : 'w-4 h-4'} shrink-0 ${props.iconClass ?? ''}`}
+ class={`${isMobileWidth() && isTouchDevice() ? 'w-5 h-5' : 'w-4 h-4'} shrink-0 ${props.iconClass ?? ''}`}
/>
</Show>
<Show when={typeof props.icon === 'object'}>
@@ -317,7 +317,7 @@ function MobileConditionalOverlay(
) {
return (
<Show
- when={props.mobileFullScreen && isTouchDevice && isMobileWidth()}
+ when={props.mobileFullScreen && isTouchDevice() && isMobileWidth()}
fallback={props.children}
>
<div class="z-modal fixed inset-0 flex justify-center items-center bg-modal-overlay backdrop-blur-sm">
@@ -395,7 +395,7 @@ export function ContextMenuContent(props: ParentProps<MenuContentProps>) {
const positioner = contentRef?.closest('[data-popper-positioner]');
if (!positioner || !(positioner instanceof HTMLElement)) return;
- if (!isTouchDevice || !isMobileWidth()) {
+ if (!isTouchDevice() || !isMobileWidth()) {
return;
}
@@ -435,7 +435,7 @@ export function ContextMenuContent(props: ParentProps<MenuContentProps>) {
${props.class} ${props.width ? menuWidths[props.width] : ''}
${
props.mobileFullScreen
- ? isTouchDevice && isMobileWidth()
+ ? isTouchDevice() && isMobileWidth()
? 'flex flex-col justify-center px-4 max-h-[80vh] shrink w-[calc(100vw-1rem)]'
: ''
: ''
diff --git a/js/app/packages/core/component/Message.tsx b/js/app/packages/core/component/Message.tsx
index 4a396a772f..44e96d0fd4 100644
--- a/js/app/packages/core/component/Message.tsx
+++ b/js/app/packages/core/component/Message.tsx
@@ -327,7 +327,7 @@ const Root: Component<MessageRootProps> = (props) => {
</div>
</div>
</BozzyBracket>
- <Show when={props.hoverActions && !isTouchDevice}>
+ <Show when={props.hoverActions && !isTouchDevice()}>
<div
class="absolute right-2 -top-2 border border-edge bg-panel"
classList={{
diff --git a/js/app/packages/core/component/OldMenu.tsx b/js/app/packages/core/component/OldMenu.tsx
index 64312e9dcb..3d4c2030fa 100644
--- a/js/app/packages/core/component/OldMenu.tsx
+++ b/js/app/packages/core/component/OldMenu.tsx
@@ -96,7 +96,7 @@ export function OldMenuItem(props: OldMenuItemProps) {
return (
<OldBaseItem spacerTop={props.spacerTop} spacerBottom={props.spacerBottom}>
<div
- class={`group ${isTouchDevice ? '' : 'relative'}`}
+ class={`group ${isTouchDevice() ? '' : 'relative'}`}
on:touchstart={props.onTouchStart}
on:touchend={props.onTouchEnd}
onmouseenter={() => setShowSubmenu(true)}
@@ -125,7 +125,7 @@ export function OldMenuItem(props: OldMenuItemProps) {
ref={setMenuItemRef}
>
<div
- class={`flex flex-row w-full ${isMobileWidth() && isTouchDevice ? 'py-2 px-1' : 'p-1'} justify-between items-center rounded ${
+ class={`flex flex-row w-full ${isMobileWidth() && isTouchDevice() ? 'py-2 px-1' : 'p-1'} justify-between items-center rounded ${
props.disabled
? 'opacity-50 cursor-not-allowed text-ink'
: (selected())
@@ -139,13 +139,13 @@ export function OldMenuItem(props: OldMenuItemProps) {
}}
>
<div
- class={`flex flex-row w-full gap-1.5 justify-start items-center ${props.textSize === 'base' ? 'text-base' : isMobileWidth() && isTouchDevice ? 'text-base' : 'text-sm'} font-medium ${
+ class={`flex flex-row w-full gap-1.5 justify-start items-center ${props.textSize === 'base' ? 'text-base' : isMobileWidth() && isTouchDevice() ? 'text-base' : 'text-sm'} font-medium ${
props.secondaryActionHandler ? `max-w-[calc(100%-18px)]` : ''
}`}
>
{props.icon && (
<div
- class={`flex ${isMobileWidth() && isTouchDevice ? 'w-5 h-5' : 'w-4 h-4'} justify-center items-center shrink-0 ${
+ class={`flex ${isMobileWidth() && isTouchDevice() ? 'w-5 h-5' : 'w-4 h-4'} justify-center items-center shrink-0 ${
selected() ? 'text-accent-ink' : ''
} ${props.iconClass ?? ''}`}
>
@@ -201,9 +201,9 @@ export function OldMenuItem(props: OldMenuItemProps) {
setShowSubmenu(false);
}}
style={{
- left: `${isTouchDevice ? '0' : submenuPosition().x}px`,
- top: `${isTouchDevice ? '0' : submenuPosition().y}px`,
- transform: `translateX(${isTouchDevice ? '100%' : '0'})`,
+ left: `${isTouchDevice() ? '0' : submenuPosition().x}px`,
+ top: `${isTouchDevice() ? '0' : submenuPosition().y}px`,
+ transform: `translateX(${isTouchDevice() ? '100%' : '0'})`,
}}
>
{props.submenu}
@@ -229,7 +229,7 @@ interface OldMenuProps {
export function OldMenu(props: ParentProps<OldMenuProps>) {
return (
<div
- class={`flex flex-col ${props.width ? (oldMenuWidths[props.width] ?? props.width) : ''} ${isTouchDevice ? 'relative' : ''} ${props.hide ? 'hidden' : ''} py-1 justify-start items-start bg-menu shadow-lg rounded-md ring-1 ring-edge cursor-default select-none ${props.class}`}
+ class={`flex flex-col ${props.width ? (oldMenuWidths[props.width] ?? props.width) : ''} ${isTouchDevice() ? 'relative' : ''} ${props.hide ? 'hidden' : ''} py-1 justify-start items-start bg-menu shadow-lg rounded-md ring-1 ring-edge cursor-default select-none ${props.class}`}
>
{props.children}
</div>
diff --git a/js/app/packages/core/hotkey/hotkeys.ts b/js/app/packages/core/hotkey/hotkeys.ts
index d5286e8553..3cc3c9be15 100644
--- a/js/app/packages/core/hotkey/hotkeys.ts
+++ b/js/app/packages/core/hotkey/hotkeys.ts
@@ -424,7 +424,7 @@ export function attachGlobalDOMScope(el: Element) {
* @returns A function to subscribe to keypress events with full context information.
*/
export function useHotKeyRoot() {
- if (isNativeMobilePlatform() || (isMobileWidth() && isTouchDevice)) {
+ if (isNativeMobilePlatform() || (isMobileWidth() && isTouchDevice())) {
return;
}
diff --git a/js/app/packages/core/mobile/isNativeMobilePlatform.ts b/js/app/packages/core/mobile/isNativeMobilePlatform.ts
index c976f58aca..23be4a1709 100644
--- a/js/app/packages/core/mobile/isNativeMobilePlatform.ts
+++ b/js/app/packages/core/mobile/isNativeMobilePlatform.ts
@@ -1,8 +1,5 @@
-import {
- getNativeMobilePlatform,
- type NativeMobilePlatform,
-} from '@core/util/platform';
+import { getNativeMobilePlatform } from '@core/util/platform';
-export function isNativeMobilePlatform(): NativeMobilePlatform | undefined {
- return getNativeMobilePlatform();
+export function isNativeMobilePlatform() {
+ return !!getNativeMobilePlatform();
}
diff --git a/js/app/packages/core/mobile/isTouchDevice.ts b/js/app/packages/core/mobile/isTouchDevice.ts
index 26f9acd5e4..2b8759b149 100644
--- a/js/app/packages/core/mobile/isTouchDevice.ts
+++ b/js/app/packages/core/mobile/isTouchDevice.ts
@@ -1,30 +1,10 @@
-const isTouchDevice = (() => {
+export function isTouchDevice(): boolean {
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
return false;
- // Check if primary input is coarse (finger/stylus) rather than fine (mouse)
+ // "Primarily touch" == touch-first input (primary pointer is coarse AND primary hover is none).
const hasCoarsePointer = window.matchMedia('(pointer: coarse)').matches;
+ const hasNoHover = window.matchMedia('(hover: none)').matches;
- // Check if hover capability is limited (typical of touch-first devices)
- const hasLimitedHover = window.matchMedia('(hover: none)').matches;
-
- // For touch-first devices, both conditions are typically true
- if (hasCoarsePointer && hasLimitedHover) return true;
-
- // Additional check for smaller screens that are likely mobile/tablet
- const isSmallScreen = window.matchMedia('(max-width: 1024px)').matches;
-
- // Fallback for older devices - but only on smaller screens
- if (isSmallScreen) {
- return (
- 'ontouchstart' in window ||
- navigator.maxTouchPoints > 0 ||
- // @ts-ignore - for older IE/Edge
- navigator.msMaxTouchPoints > 0
- );
- }
-
- return false;
-})();
-
-export { isTouchDevice };
+ return hasCoarsePointer && hasNoHover;
+}
diff --git a/js/app/packages/core/util/platform.ts b/js/app/packages/core/util/platform.ts
index a020a1e1ad..1ade6704a7 100644
--- a/js/app/packages/core/util/platform.ts
+++ b/js/app/packages/core/util/platform.ts
@@ -9,7 +9,7 @@ const VALID_PLATFORMS: ReadonlyArray<MacroPlatform> = [
];
function resolveBuildPlatform(): MacroPlatform {
- const platform = import.meta?.env?.VITE_PLATFORM as MacroPlatform | undefined;
+ const platform = import.meta.env.VITE_PLATFORM;
if (platform && VALID_PLATFORMS.includes(platform)) return platform;
return 'web';
}
@@ -27,18 +27,23 @@ export function isPlatform(target: MacroPlatform | MacroPlatform[]): boolean {
: platform === target;
}
-export function isMobilePlatform(): boolean {
- return isPlatform(['ios', 'android']);
+export function isMobilePlatform(): boolean;
+export function isMobilePlatform(
+ platform: MacroPlatform
+): platform is NativeMobilePlatform;
+export function isMobilePlatform(
+ platform: MacroPlatform = getPlatform()
+): boolean {
+ return platform === 'ios' || platform === 'android';
}
export function isDesktopPlatform(): boolean {
return isPlatform('desktop');
}
-export function getNativeMobilePlatform(): NativeMobilePlatform | undefined {
- return isMobilePlatform()
- ? (getPlatform() as NativeMobilePlatform)
- : undefined;
+export function getNativeMobilePlatform() {
+ const platform = getPlatform();
+ return isMobilePlatform(platform) ? platform : undefined;
}
export function isTauri(): boolean {
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index 00e65dcf48..4261c65240 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -815,16 +815,16 @@ export function EntityWithEverything(
}}
classList={{
'outline outline-accent/20 outline-offset-[-1px]':
- !isTouchDevice && props.selected && !props.checked,
+ !isTouchDevice() && props.selected && !props.checked,
'!bg-accent/5 outline outline-accent/20 outline-offset-[-1px]':
props.checked,
'bracket outline outline-accent/20 outline-offset-[-1px]':
- !isTouchDevice && props.selected,
+ !isTouchDevice() && props.selected,
'active:bracket active:outline active:outline-accent/20 active:outline-offset-[-1px]':
- isTouchDevice && !props.checked,
+ isTouchDevice() && !props.checked,
}}
onMouseOver={(e) => {
- if (isTouchDevice) return;
+ if (isTouchDevice()) return;
if (!didCursorMove(e)) {
return;
}
diff --git a/js/app/packages/macro-icons/wide/plus.svg b/js/app/packages/macro-icons/wide/plus.svg
new file mode 100644
index 0000000000..4e804efce7
--- /dev/null
+++ b/js/app/packages/macro-icons/wide/plus.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="currentColor"><path d="M10.5 4v6.5H0v3h10.5V20h3v-6.5H24v-3H13.5V4z"/></svg>
\ No newline at end of file