mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
refactor: give ModalOverlay mobile presentation and android back
This commit is contained in:
20 files changed
+340
-466
No files matched your search
+17
-3
@@ -4,19 +4,27 @@ export default defineConfig({
|
||||
testDir: './tests/e2e',
|
||||
testMatch: '**/*.spec.ts',
|
||||
snapshotPathTemplate: 'tests/e2e/__screenshots__/{projectName}/{testFileName}/{arg}{ext}',
|
||||
// Every context shares one Matrix account and device id from the seeded
|
||||
// storageState, so concurrent clients contend over sync and crypto state.
|
||||
// Parallelising would need a worker-scoped account fixture; the suite runs in
|
||||
// well under a minute serially, so it is not worth the plumbing.
|
||||
fullyParallel: false,
|
||||
workers: 1,
|
||||
// Locally a failure should surface at once; CI keeps retries for flakes.
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
reporter: [['html', { open: 'never' }], ['list']],
|
||||
globalSetup: './tests/e2e/global-setup.ts',
|
||||
// Tests run in 3-6s against a built app; this is headroom, not a wait budget.
|
||||
timeout: 60_000,
|
||||
expect: {
|
||||
toHaveScreenshot: { maxDiffPixelRatio: 0.01 },
|
||||
},
|
||||
use: {
|
||||
baseURL: 'http://localhost:8080',
|
||||
baseURL: 'http://localhost:8081',
|
||||
storageState: 'tests/e2e/.auth/state.json',
|
||||
trace: 'on-first-retry',
|
||||
// Sheets skip their entrance animation here, so a click cannot land mid-slide.
|
||||
reducedMotion: 'reduce',
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
@@ -29,9 +37,15 @@ export default defineConfig({
|
||||
},
|
||||
],
|
||||
webServer: {
|
||||
command: 'pnpm run build && pnpm exec vite preview --port 8080 --strictPort',
|
||||
url: 'http://localhost:8080',
|
||||
// A real build, not the dev server: no HMR and no dependency optimiser, both
|
||||
// of which invalidate the module graph mid-run and make the suite lie.
|
||||
// Port 8081, not the dev server's 8080, so a running `pnpm dev` is untouched.
|
||||
command: 'pnpm run build && pnpm exec vite preview --port 8081 --strictPort',
|
||||
url: 'http://localhost:8081',
|
||||
// Never reuse: a leftover server would silently serve a stale build. The
|
||||
// build is ~30s, which is worth paying to know what is under test.
|
||||
reuseExistingServer: false,
|
||||
// ~35s observed (31s build + preview start), with headroom for a cold CI box.
|
||||
timeout: 180_000,
|
||||
env: { NODE_OPTIONS: '--max-old-space-size=8192' },
|
||||
},
|
||||
|
||||
@@ -1,61 +1,22 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useRef } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { useDismissOnBack } from '$utils/androidBack';
|
||||
import { Modal } from 'folds';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
|
||||
type Modal500Props = {
|
||||
requestClose: () => void;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
/** A size-500 modal on desktop that fills the viewport on a phone. */
|
||||
export function Modal500({ requestClose, children }: Modal500Props) {
|
||||
const modalRef = useRef<HTMLDivElement | null>(null);
|
||||
const screenSize = useScreenSizeContext();
|
||||
|
||||
// Android back closes the overlay instead of navigating away.
|
||||
useDismissOnBack(requestClose);
|
||||
|
||||
if (screenSize === ScreenSize.Mobile) {
|
||||
return (
|
||||
<Overlay open>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
escapeDeactivates: stopPropagation,
|
||||
onDeactivate: requestClose,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
ref={modalRef}
|
||||
tabIndex={-1}
|
||||
style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column' }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</FocusTrap>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
fallbackFocus: () => modalRef.current ?? document.body,
|
||||
clickOutsideDeactivates: true,
|
||||
onDeactivate: requestClose,
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Modal ref={modalRef} tabIndex={-1} size="500" variant="Background">
|
||||
{children}
|
||||
</Modal>
|
||||
</FocusTrap>
|
||||
</OverlayCenter>
|
||||
</Overlay>
|
||||
<ModalOverlay requestClose={requestClose} mobile="fullscreen" contentRef={modalRef}>
|
||||
<Modal ref={modalRef} tabIndex={-1} size="500" variant="Background">
|
||||
{children}
|
||||
</Modal>
|
||||
</ModalOverlay>
|
||||
);
|
||||
}
|
||||
@@ -17,7 +17,6 @@ export function SwipeableChatWrapper({
|
||||
onOpenMembers,
|
||||
onReply,
|
||||
}: SwipeableChatWrapperProps) {
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const [rightSwipeAction] = useSetting(settingsAtom, 'rightSwipeAction');
|
||||
const x = useMotionValue(0);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
@@ -57,16 +56,16 @@ export function SwipeableChatWrapper({
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const element = containerRef.current;
|
||||
if (!drawer || !element || !mobileGestures || !mobileOrTablet()) return undefined;
|
||||
if (!drawer || !element || !mobileOrTablet()) return undefined;
|
||||
|
||||
return drawer.registerChatSwipe(element, {
|
||||
move,
|
||||
end: ({ distanceX, velocityX }) => finish(true, distanceX, velocityX),
|
||||
cancel: () => finish(false),
|
||||
});
|
||||
}, [drawer, finish, mobileGestures, move]);
|
||||
}, [drawer, finish, move]);
|
||||
|
||||
if (!mobileGestures || !mobileOrTablet()) {
|
||||
if (!mobileOrTablet()) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
|
||||
@@ -171,11 +171,8 @@ export function SwipeableMessageWrapper({
|
||||
const settings = useAtomValue(settingsAtom);
|
||||
|
||||
const isSwipeToReplyEnabled = useMemo(
|
||||
() =>
|
||||
settings.mobileGestures &&
|
||||
mobileOrTablet() &&
|
||||
settings.rightSwipeAction !== RightSwipeAction.Members,
|
||||
[settings.mobileGestures, settings.rightSwipeAction]
|
||||
() => mobileOrTablet() && settings.rightSwipeAction !== RightSwipeAction.Members,
|
||||
[settings.rightSwipeAction]
|
||||
);
|
||||
|
||||
if (!isSwipeToReplyEnabled || !onReply) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { animate, motion, useMotionValue } from 'framer-motion';
|
||||
import { useDrag } from '@use-gesture/react';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
|
||||
interface SwipeableOverlayWrapperProps {
|
||||
@@ -16,7 +14,6 @@ export function SwipeableOverlayWrapper({
|
||||
onClose,
|
||||
direction,
|
||||
}: SwipeableOverlayWrapperProps) {
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const x = useMotionValue(0);
|
||||
|
||||
const bind = useDrag(
|
||||
@@ -28,7 +25,7 @@ export function SwipeableOverlayWrapper({
|
||||
}
|
||||
}
|
||||
|
||||
if (!mobileGestures || !mobileOrTablet()) return;
|
||||
if (!mobileOrTablet()) return;
|
||||
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -68,7 +65,7 @@ export function SwipeableOverlayWrapper({
|
||||
}
|
||||
);
|
||||
|
||||
if (!mobileGestures || !mobileOrTablet()) {
|
||||
if (!mobileOrTablet()) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
|
||||
@@ -2,8 +2,6 @@ import { type RefObject, useLayoutEffect, useRef } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { useDrag } from '@use-gesture/react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useAndroidBackHandler } from '$utils/androidBack';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
@@ -47,7 +45,6 @@ export function AttachmentSheet({
|
||||
onPickLocation,
|
||||
containerRef,
|
||||
}: AttachmentSheetProps) {
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const containerEl = containerRef.current;
|
||||
const sheetRef = useRef<HTMLDivElement>(null);
|
||||
const skipReturnFocusRef = useRef(false);
|
||||
@@ -69,7 +66,7 @@ export function AttachmentSheet({
|
||||
return true;
|
||||
}, open);
|
||||
|
||||
const gesturesEnabled = mobileGestures && mobileOrTablet();
|
||||
const gesturesEnabled = mobileOrTablet();
|
||||
|
||||
const bind = useDrag(
|
||||
({ first, active, offset: [, oy], velocity: [, vy], direction: [, dy], event }) => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Box, Button, Dialog, Header, IconButton, Spinner, Text, color, config } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { Box, Button, Spinner, Text, color, config } from 'folds';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
|
||||
type DirectInvitePromptProps = {
|
||||
onCancel: () => void;
|
||||
@@ -18,58 +17,39 @@ export function DirectInvitePrompt({
|
||||
convertError,
|
||||
}: DirectInvitePromptProps) {
|
||||
return (
|
||||
<ModalOverlay requestClose={onCancel}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Invite another Member</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text size="T300">
|
||||
This is a <b>Direct Message</b> room, intended for a conversation between two persons.
|
||||
Would you like to convert it into a <b>group chat</b> before continuing?
|
||||
<PromptDialog title="Invite another Member" requestClose={onCancel}>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text size="T300">
|
||||
This is a <b>Direct Message</b> room, intended for a conversation between two persons.
|
||||
Would you like to convert it into a <b>group chat</b> before continuing?
|
||||
</Text>
|
||||
{convertError && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to convert direct message to room! {convertError}
|
||||
</Text>
|
||||
{convertError && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to convert direct message to room! {convertError}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
variant="Primary"
|
||||
onClick={onConvertAndInvite}
|
||||
disabled={converting}
|
||||
before={
|
||||
converting ? <Spinner fill="Solid" variant="Primary" size="200" /> : undefined
|
||||
}
|
||||
aria-disabled={converting}
|
||||
>
|
||||
<Text size="B400">
|
||||
{converting ? 'Converting...' : 'Convert to Group Chat and Invite'}
|
||||
</Text>
|
||||
</Button>
|
||||
<Button variant="Warning" fill="Soft" onClick={onInviteDirect} disabled={converting}>
|
||||
<Text size="B400">Invite to Direct Message anyway</Text>
|
||||
</Button>
|
||||
<Button variant="Secondary" fill="Soft" onClick={onCancel} disabled={converting}>
|
||||
<Text size="B400">Cancel</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Dialog>
|
||||
</ModalOverlay>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
variant="Primary"
|
||||
onClick={onConvertAndInvite}
|
||||
disabled={converting}
|
||||
before={converting ? <Spinner fill="Solid" variant="Primary" size="200" /> : undefined}
|
||||
aria-disabled={converting}
|
||||
>
|
||||
<Text size="B400">
|
||||
{converting ? 'Converting...' : 'Convert to Group Chat and Invite'}
|
||||
</Text>
|
||||
</Button>
|
||||
<Button variant="Warning" fill="Soft" onClick={onInviteDirect} disabled={converting}>
|
||||
<Text size="B400">Invite to Direct Message anyway</Text>
|
||||
</Button>
|
||||
<Button variant="Secondary" fill="Soft" onClick={onCancel} disabled={converting}>
|
||||
<Text size="B400">Cancel</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</PromptDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { Dialog, Header, config, Box, Text, IconButton, Button, Input, color } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { config, Box, Text, Button, Input, color } from 'folds';
|
||||
import { isRoomAlias, isRoomId } from '$utils/matrix';
|
||||
import { parseMatrixToRoom, parseMatrixToRoomEvent, testMatrixTo } from '$plugins/matrix-to';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
|
||||
type JoinAddressProps = {
|
||||
onOpen: (roomIdOrAlias: string, via?: string[], eventId?: string) => void;
|
||||
@@ -47,60 +46,44 @@ export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<ModalOverlay requestClose={onCancel}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Join with Address</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleSubmit}
|
||||
style={{ padding: config.space.S400, paddingTop: 0 }}
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400" size="T300">
|
||||
Enter public address to join the community. Addresses looks like:
|
||||
</Text>
|
||||
<Text as="ul" size="T200" priority="300" style={{ paddingLeft: config.space.S400 }}>
|
||||
<li>#community:server</li>
|
||||
<li>https://matrix.to/#/#community:server</li>
|
||||
<li>https://matrix.to/#/!xYzAj?via=server</li>
|
||||
</Text>
|
||||
</Box>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Address</Text>
|
||||
<Input
|
||||
size="500"
|
||||
autoFocus
|
||||
name="addressInput"
|
||||
variant="Background"
|
||||
placeholder="#community:server"
|
||||
required
|
||||
/>
|
||||
{invalid && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>Invalid Address</b>
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
<Button type="submit" variant="Primary">
|
||||
<Text size="B400">Open</Text>
|
||||
</Button>
|
||||
<PromptDialog title="Join with Address" requestClose={onCancel}>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleSubmit}
|
||||
style={{ padding: config.space.S400, paddingTop: 0 }}
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400" size="T300">
|
||||
Enter public address to join the community. Addresses looks like:
|
||||
</Text>
|
||||
<Text as="ul" size="T200" priority="300" style={{ paddingLeft: config.space.S400 }}>
|
||||
<li>#community:server</li>
|
||||
<li>https://matrix.to/#/#community:server</li>
|
||||
<li>https://matrix.to/#/!xYzAj?via=server</li>
|
||||
</Text>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</ModalOverlay>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Address</Text>
|
||||
<Input
|
||||
size="500"
|
||||
autoFocus
|
||||
name="addressInput"
|
||||
variant="Background"
|
||||
placeholder="#community:server"
|
||||
required
|
||||
/>
|
||||
{invalid && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>Invalid Address</b>
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
<Button type="submit" variant="Primary">
|
||||
<Text size="B400">Open</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</PromptDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,24 +1,12 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
Header,
|
||||
config,
|
||||
Box,
|
||||
Text,
|
||||
IconButton,
|
||||
Input,
|
||||
color,
|
||||
Button,
|
||||
Spinner,
|
||||
} from 'folds';
|
||||
import { config, Box, Text, Input, color, Button, Spinner } from 'folds';
|
||||
import type { MatrixError } from '$types/matrix-sdk';
|
||||
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
|
||||
const debugLog = createDebugLogger('KnockRoomPrompt');
|
||||
|
||||
@@ -57,67 +45,50 @@ export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProp
|
||||
}, [knockState, onDone, roomId]);
|
||||
|
||||
return (
|
||||
<ModalOverlay requestClose={onCancel}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Knock On Room</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleKnock}
|
||||
style={{ padding: config.space.S400 }}
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">
|
||||
Request to join this room. You can optionally leave a reason for the moderators.
|
||||
</Text>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">
|
||||
Reason{' '}
|
||||
<Text as="span" size="T200">
|
||||
(Optional)
|
||||
</Text>
|
||||
<PromptDialog title="Knock On Room" requestClose={onCancel}>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleKnock}
|
||||
style={{ padding: config.space.S400 }}
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">
|
||||
Request to join this room. You can optionally leave a reason for the moderators.
|
||||
</Text>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">
|
||||
Reason{' '}
|
||||
<Text as="span" size="T200">
|
||||
(Optional)
|
||||
</Text>
|
||||
<Input name="reasonInput" variant="Background" />
|
||||
{knockState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to knock! {knockState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Primary"
|
||||
before={
|
||||
knockState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Primary" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
knockState.status === AsyncStatus.Loading || knockState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{knockState.status === AsyncStatus.Loading ? 'Knocking...' : 'Knock'}
|
||||
</Text>
|
||||
</Button>
|
||||
<Input name="reasonInput" variant="Background" />
|
||||
{knockState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to knock! {knockState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</ModalOverlay>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Primary"
|
||||
before={
|
||||
knockState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Primary" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
knockState.status === AsyncStatus.Loading || knockState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{knockState.status === AsyncStatus.Loading ? 'Knocking...' : 'Knock'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</PromptDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { Dialog, Header, config, Box, Text, IconButton, color, Button, Spinner } from 'folds';
|
||||
import { config, Box, Text, color, Button, Spinner } from 'folds';
|
||||
import type { MatrixError } from '$types/matrix-sdk';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
|
||||
const debugLog = createDebugLogger('LeaveRoomPrompt');
|
||||
@@ -36,51 +36,34 @@ export function LeaveRoomPrompt({ roomId, onDone, onCancel }: LeaveRoomPromptPro
|
||||
}, [leaveState, onDone, roomId]);
|
||||
|
||||
return (
|
||||
<ModalOverlay requestClose={onCancel}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Leave Room</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">Are you sure you want to leave this room?</Text>
|
||||
{leaveState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave room! {leaveState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={handleLeave}
|
||||
before={
|
||||
leaveState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Critical" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
leaveState.status === AsyncStatus.Loading || leaveState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{leaveState.status === AsyncStatus.Loading ? 'Leaving...' : 'Leave'}
|
||||
<PromptDialog title="Leave Room" requestClose={onCancel}>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">Are you sure you want to leave this room?</Text>
|
||||
{leaveState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave room! {leaveState.error.message}
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
</Dialog>
|
||||
</ModalOverlay>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={handleLeave}
|
||||
before={
|
||||
leaveState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Critical" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
leaveState.status === AsyncStatus.Loading || leaveState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{leaveState.status === AsyncStatus.Loading ? 'Leaving...' : 'Leave'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</PromptDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { Dialog, Header, config, Box, Text, IconButton, color, Button, Spinner } from 'folds';
|
||||
import { config, Box, Text, color, Button, Spinner } from 'folds';
|
||||
import type { MatrixError } from '$types/matrix-sdk';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { getJoinedSpaceChildrenSummary, getRecursiveSpaceLeaveOrder } from '$utils/room';
|
||||
import { rateLimitedActions } from '$utils/matrix';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
|
||||
type LeaveSpacePromptProps = {
|
||||
roomId: string;
|
||||
@@ -77,70 +76,53 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP
|
||||
}, [leaveState, leaveAllState, onDone]);
|
||||
|
||||
return (
|
||||
<ModalOverlay requestClose={onCancel}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Leave Space</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">Are you sure you want to leave this space?</Text>
|
||||
{joinedChildrenCount > 0 && (
|
||||
<Text priority="300" size="T300">
|
||||
{formatJoinedContentsMessage(roomCount, subspaceCount)}
|
||||
</Text>
|
||||
)}
|
||||
{leaveState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave space! {leaveState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
{leaveAllState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave space, rooms, and subspaces! {leaveAllState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={() => leaveSpace()}
|
||||
before={leaving ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined}
|
||||
aria-disabled={isBusy || leaveState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">{leaving ? 'Leaving...' : 'Leave Space Only'}</Text>
|
||||
</Button>
|
||||
{joinedChildrenCount > 0 && (
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="Soft"
|
||||
onClick={() => leaveAll()}
|
||||
before={
|
||||
leavingAll ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined
|
||||
}
|
||||
aria-disabled={isBusy || leaveAllState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">
|
||||
{formatRecursiveLeaveLabel(leavingAll, roomCount, subspaceCount)}
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
<PromptDialog title="Leave Space" requestClose={onCancel}>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">Are you sure you want to leave this space?</Text>
|
||||
{joinedChildrenCount > 0 && (
|
||||
<Text priority="300" size="T300">
|
||||
{formatJoinedContentsMessage(roomCount, subspaceCount)}
|
||||
</Text>
|
||||
)}
|
||||
{leaveState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave space! {leaveState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
{leaveAllState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave space, rooms, and subspaces! {leaveAllState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Dialog>
|
||||
</ModalOverlay>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={() => leaveSpace()}
|
||||
before={leaving ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined}
|
||||
aria-disabled={isBusy || leaveState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">{leaving ? 'Leaving...' : 'Leave Space Only'}</Text>
|
||||
</Button>
|
||||
{joinedChildrenCount > 0 && (
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="Soft"
|
||||
onClick={() => leaveAll()}
|
||||
before={
|
||||
leavingAll ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined
|
||||
}
|
||||
aria-disabled={isBusy || leaveAllState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">
|
||||
{formatRecursiveLeaveLabel(leavingAll, roomCount, subspaceCount)}
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</PromptDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,22 +1,69 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import type { ComponentProps, MutableRefObject, ReactNode } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { useDismissOnBack } from '$utils/androidBack';
|
||||
|
||||
type FocusTrapOptions = ComponentProps<typeof FocusTrap>['focusTrapOptions'];
|
||||
|
||||
type ModalOverlayProps = {
|
||||
open?: boolean;
|
||||
requestClose: () => void;
|
||||
/** Set false for overlays that must be dismissed deliberately, not by a stray click. */
|
||||
dismissOnClickOutside?: boolean;
|
||||
initialFocus?: FocusTrapOptions['initialFocus'];
|
||||
/** `fullscreen` drops the centred modal on phones and fills the viewport instead. */
|
||||
mobile?: 'centred' | 'fullscreen';
|
||||
/** The modal element, used as the focus fallback and as the fullscreen wrapper. */
|
||||
contentRef?: MutableRefObject<HTMLDivElement | null>;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export function ModalOverlay({ open = true, requestClose, children }: ModalOverlayProps) {
|
||||
export function ModalOverlay({
|
||||
open = true,
|
||||
requestClose,
|
||||
dismissOnClickOutside = true,
|
||||
initialFocus = false,
|
||||
mobile = 'centred',
|
||||
contentRef,
|
||||
children,
|
||||
}: ModalOverlayProps) {
|
||||
const isMobile = useScreenSizeContext() === ScreenSize.Mobile;
|
||||
|
||||
// Android back closes the overlay instead of navigating away.
|
||||
useDismissOnBack(requestClose, open);
|
||||
|
||||
if (open && isMobile && mobile === 'fullscreen') {
|
||||
return (
|
||||
<Overlay open>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus,
|
||||
escapeDeactivates: stopPropagation,
|
||||
onDeactivate: requestClose,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
ref={contentRef}
|
||||
tabIndex={-1}
|
||||
style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column' }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</FocusTrap>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Overlay open={open} backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
clickOutsideDeactivates: true,
|
||||
initialFocus,
|
||||
fallbackFocus: () => contentRef?.current ?? document.body,
|
||||
clickOutsideDeactivates: dismissOnClickOutside,
|
||||
onDeactivate: requestClose,
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, Dialog, Header, IconButton, Text, config } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { ModalOverlay } from './ModalOverlay';
|
||||
|
||||
type PromptDialogProps = {
|
||||
title: string;
|
||||
requestClose: () => void;
|
||||
/** Prompts that must be answered deliberately opt out of click-outside dismiss. */
|
||||
dismissOnClickOutside?: boolean;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
/** A titled dialog with a close button, over a dimmed backdrop. */
|
||||
export function PromptDialog({
|
||||
title,
|
||||
requestClose,
|
||||
dismissOnClickOutside,
|
||||
children,
|
||||
}: PromptDialogProps) {
|
||||
return (
|
||||
<ModalOverlay requestClose={requestClose} dismissOnClickOutside={dismissOnClickOutside}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">{title}</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={requestClose} radii="300">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
{children}
|
||||
</Dialog>
|
||||
</ModalOverlay>
|
||||
);
|
||||
}
|
||||
@@ -10,8 +10,6 @@ import {
|
||||
} from 'react';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { matchPath, useLocation, useNavigate } from 'react-router-dom';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { lastVisitedRoomAtom } from '$state/room/lastRoom';
|
||||
import { useReducedMotion } from 'framer-motion';
|
||||
import {
|
||||
@@ -57,7 +55,6 @@ type ActiveTouchGesture = {
|
||||
|
||||
/** Sliding mobile drawer with one touch coordinator and a GPU-transformed panel track. */
|
||||
export function MobileNavDrawer({ nav, rail, bottomNav, children }: MobileNavDrawerProps) {
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const reduceMotion = useReducedMotion();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
@@ -344,7 +341,7 @@ export function MobileNavDrawer({ nav, rail, bottomNav, children }: MobileNavDra
|
||||
onTouchStartCapture={(event) => {
|
||||
const viewport = viewportRef.current;
|
||||
const touch = event.touches[0];
|
||||
if (!mobileGestures || !viewport || !touch) return;
|
||||
if (!viewport || !touch) return;
|
||||
if (event.touches.length !== 1) {
|
||||
finishGesture(true);
|
||||
return;
|
||||
|
||||
@@ -3,8 +3,6 @@ import { Box, Header, Line, Scroll, Text, as } from 'folds';
|
||||
import classNames from 'classnames';
|
||||
import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { MobileNavDrawer } from './MobileNavDrawer';
|
||||
import * as css from './style.css';
|
||||
|
||||
@@ -18,10 +16,9 @@ type PageRootProps = {
|
||||
|
||||
export function PageRoot({ nav, rail, bottomNav, children, mobileDrawer = true }: PageRootProps) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const isMobile = screenSize === ScreenSize.Mobile;
|
||||
|
||||
if (isMobile && mobileGestures && mobileDrawer) {
|
||||
if (isMobile && mobileDrawer) {
|
||||
return (
|
||||
<Box grow="Yes" className={ContainerColor({ variant: 'Background' })}>
|
||||
<MobileNavDrawer nav={nav} rail={rail} bottomNav={bottomNav}>
|
||||
|
||||
@@ -963,32 +963,15 @@ function SelectRightSwipeAction({ disabled }: Readonly<{ disabled?: boolean }>)
|
||||
}
|
||||
|
||||
function Gestures({ isMobile }: Readonly<{ isMobile: boolean }>) {
|
||||
const [mobileGestures, setMobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100" style={{ opacity: isMobile ? 1 : 0.5 }}>
|
||||
<Text size="L400">Gestures {!isMobile && '(Mobile Only)'}</Text>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Enable Swiping"
|
||||
focusId="enable-swiping"
|
||||
description="Swipe left for rooms, swipe right for actions."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={mobileGestures}
|
||||
onChange={setMobileGestures}
|
||||
disabled={!isMobile}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Right Swipe Action"
|
||||
focusId="right-swipe-action"
|
||||
description="What happens when you swipe right on a message."
|
||||
after={<SelectRightSwipeAction disabled={!isMobile || !mobileGestures} />}
|
||||
after={<SelectRightSwipeAction disabled={!isMobile} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useMatch } from 'react-router-dom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import {
|
||||
DIRECT_PATH,
|
||||
EXPLORE_PATH,
|
||||
@@ -40,7 +38,6 @@ export function MobileFriendlySidebarNav({ children }: MobileFriendlyClientNavPr
|
||||
|
||||
export function MobileFriendlyBottomNav({ children }: MobileFriendlyClientNavProps) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const homeMatch = useMatch({ path: HOME_PATH, caseSensitive: true, end: true });
|
||||
const directMatch = useMatch({ path: DIRECT_PATH, caseSensitive: true, end: true });
|
||||
const spaceMatch = useMatch({ path: SPACE_PATH, caseSensitive: true, end: true });
|
||||
@@ -52,7 +49,7 @@ export function MobileFriendlyBottomNav({ children }: MobileFriendlyClientNavPro
|
||||
homeMatch || directMatch || spaceMatch || inboxMatch || navigateMatch || profileMatch;
|
||||
if (
|
||||
screenSize !== ScreenSize.Mobile ||
|
||||
(mobileGestures && !inboxMatch && !navigateMatch && !profileMatch) ||
|
||||
(!inboxMatch && !navigateMatch && !profileMatch) ||
|
||||
!onBarDestination ||
|
||||
settingsMatch
|
||||
) {
|
||||
@@ -61,24 +58,3 @@ export function MobileFriendlyBottomNav({ children }: MobileFriendlyClientNavPro
|
||||
|
||||
return children;
|
||||
}
|
||||
type MobileFriendlyPageNavProps = {
|
||||
path: string;
|
||||
children: ReactNode;
|
||||
};
|
||||
export function MobileFriendlyPageNav({ path, children }: MobileFriendlyPageNavProps) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const exactPath = useMatch({
|
||||
path,
|
||||
caseSensitive: true,
|
||||
end: true,
|
||||
});
|
||||
|
||||
// With mobile gestures on, the list stays mounted so MobileNavDrawer can reveal it as a
|
||||
// co-present panel. Without gestures, fall back to the route-based single-view behavior.
|
||||
if (screenSize === ScreenSize.Mobile && !mobileGestures && !exactPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
+10
-38
@@ -104,11 +104,7 @@ const PublicRooms = lazy(() =>
|
||||
import { setAfterLoginRedirectPath } from './afterLoginRedirectPath';
|
||||
import { WelcomePage } from './client/WelcomePage';
|
||||
import { SidebarNav } from './client/SidebarNav';
|
||||
import {
|
||||
MobileFriendlyPageNav,
|
||||
MobileFriendlySidebarNav,
|
||||
MobileFriendlyBottomNav,
|
||||
} from './MobileFriendly';
|
||||
import { MobileFriendlySidebarNav, MobileFriendlyBottomNav } from './MobileFriendly';
|
||||
import { ClientInitStorageAtom } from './client/ClientInitStorageAtom';
|
||||
import { AuthRouteThemeManager, UnAuthRouteThemeManager } from './ThemeManager';
|
||||
import { TauriDeepLinkBridge } from './TauriDeepLinkBridge';
|
||||
@@ -293,15 +289,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
<Route
|
||||
path={HOME_PATH}
|
||||
element={
|
||||
<PageRoot
|
||||
rail={<SidebarNav />}
|
||||
bottomNav={<UserQuickToolsProvider />}
|
||||
nav={
|
||||
<MobileFriendlyPageNav path={HOME_PATH}>
|
||||
<Home />
|
||||
</MobileFriendlyPageNav>
|
||||
}
|
||||
>
|
||||
<PageRoot rail={<SidebarNav />} bottomNav={<UserQuickToolsProvider />} nav={<Home />}>
|
||||
<Outlet />
|
||||
</PageRoot>
|
||||
}
|
||||
@@ -323,15 +311,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
<Route
|
||||
path={DIRECT_PATH}
|
||||
element={
|
||||
<PageRoot
|
||||
rail={<SidebarNav />}
|
||||
bottomNav={<UserQuickToolsProvider />}
|
||||
nav={
|
||||
<MobileFriendlyPageNav path={DIRECT_PATH}>
|
||||
<Direct />
|
||||
</MobileFriendlyPageNav>
|
||||
}
|
||||
>
|
||||
<PageRoot rail={<SidebarNav />} bottomNav={<UserQuickToolsProvider />} nav={<Direct />}>
|
||||
<Outlet />
|
||||
</PageRoot>
|
||||
}
|
||||
@@ -354,11 +334,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
<PageRoot
|
||||
rail={<SidebarNav />}
|
||||
bottomNav={<UserQuickToolsProvider />}
|
||||
nav={
|
||||
<MobileFriendlyPageNav path={SPACE_PATH}>
|
||||
<Space />
|
||||
</MobileFriendlyPageNav>
|
||||
}
|
||||
nav={<Space />}
|
||||
>
|
||||
<Outlet />
|
||||
</PageRoot>
|
||||
@@ -398,11 +374,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
<PageRoot
|
||||
rail={<SidebarNav />}
|
||||
nav={
|
||||
<MobileFriendlyPageNav path={EXPLORE_PATH}>
|
||||
<Suspense fallback={<SplashScreen>{null}</SplashScreen>}>
|
||||
<Explore />
|
||||
</Suspense>
|
||||
</MobileFriendlyPageNav>
|
||||
<Suspense fallback={<SplashScreen>{null}</SplashScreen>}>
|
||||
<Explore />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Outlet />
|
||||
@@ -465,11 +439,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
element={
|
||||
<PageRoot
|
||||
nav={
|
||||
<MobileFriendlyPageNav path={INBOX_PATH}>
|
||||
<Suspense fallback={<SplashScreen>{null}</SplashScreen>}>
|
||||
<Inbox />
|
||||
</Suspense>
|
||||
</MobileFriendlyPageNav>
|
||||
<Suspense fallback={<SplashScreen>{null}</SplashScreen>}>
|
||||
<Inbox />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Outlet />
|
||||
|
||||
@@ -2,8 +2,6 @@ import type { ReactNode } from 'react';
|
||||
import { Box } from 'folds';
|
||||
import { matchPath, useLocation } from 'react-router-dom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { SETTINGS_PATH } from '../paths';
|
||||
import { isShallowRoute } from './shallowRoute';
|
||||
|
||||
@@ -14,12 +12,11 @@ type ClientLayoutProps = {
|
||||
export function ClientLayout({ nav, children }: ClientLayoutProps) {
|
||||
const location = useLocation();
|
||||
const screenSize = useScreenSizeContext();
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const fullPageSettings =
|
||||
Boolean(matchPath(SETTINGS_PATH, location.pathname)) &&
|
||||
!isShallowRoute(location.pathname, location.state, screenSize);
|
||||
|
||||
const railInDrawer = screenSize === ScreenSize.Mobile && mobileGestures;
|
||||
const railInDrawer = screenSize === ScreenSize.Mobile;
|
||||
|
||||
return (
|
||||
<Box grow="Yes" direction="Row">
|
||||
|
||||
@@ -204,7 +204,6 @@ export interface Settings {
|
||||
|
||||
// Sable features!
|
||||
sendPresence: boolean;
|
||||
mobileGestures: boolean;
|
||||
rightSwipeAction: RightSwipeAction;
|
||||
hideMembershipInReadOnly: boolean;
|
||||
useRightBubbles: boolean;
|
||||
@@ -383,7 +382,6 @@ export const defaultSettings: Settings = {
|
||||
|
||||
// Sable features!
|
||||
sendPresence: true,
|
||||
mobileGestures: true,
|
||||
rightSwipeAction: RightSwipeAction.Reply,
|
||||
hideMembershipInReadOnly: true,
|
||||
useRightBubbles: false,
|
||||
|
||||
Reference in new issue
Block a user