Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[space][web] Add friend profile sheets and refresh navigation

Anand Baburajanb387ba9a894f
diff --git a/web/apps/space/next.config.js b/web/apps/space/next.config.js
index 8f522cbd82..78a22f3003 100644
--- a/web/apps/space/next.config.js
+++ b/web/apps/space/next.config.js
@@ -21,6 +21,10 @@ module.exports = {
// Static deployments serve arbitrary profile links through profile-link.html.
// In development, mirror that behavior with fallback rewrites.
...(process.env.NODE_ENV === "development" && {
+ allowedDevOrigins: [
+ ...(baseConfig.allowedDevOrigins ?? []),
+ ...(process.env.ENTE_SPACE_ALLOWED_DEV_ORIGINS?.split(",") ?? []),
+ ],
output: undefined,
async rewrites() {
return {
diff --git a/web/apps/space/public/_redirects b/web/apps/space/public/_redirects
index 1076831251..786267b56b 100644
--- a/web/apps/space/public/_redirects
+++ b/web/apps/space/public/_redirects
@@ -16,6 +16,7 @@
/login /login 200
/manifest.webmanifest /manifest.webmanifest 200
/manifest-public.webmanifest /manifest-public.webmanifest 200
+/favicon.ico /favicon.ico 200
/sw.js /sw.js 200
/passkeys/finish /passkeys/finish 200
/passkeys/verify /passkeys/verify 200
diff --git a/web/apps/space/public/favicon.ico b/web/apps/space/public/favicon.ico
new file mode 100644
index 0000000000..18e7e713f2
Binary files /dev/null and b/web/apps/space/public/favicon.ico differ
diff --git a/web/apps/space/public/images/apple-touch-icon.png b/web/apps/space/public/images/apple-touch-icon.png
index 7ce1a7c59b..0c07c5cdb6 100644
Binary files a/web/apps/space/public/images/apple-touch-icon.png and b/web/apps/space/public/images/apple-touch-icon.png differ
diff --git a/web/apps/space/public/images/favicon.png b/web/apps/space/public/images/favicon.png
index fe1df8057e..1ce537b665 100644
Binary files a/web/apps/space/public/images/favicon.png and b/web/apps/space/public/images/favicon.png differ
diff --git a/web/apps/space/public/images/pwa-icon-192.png b/web/apps/space/public/images/pwa-icon-192.png
index 27c009c680..e0bd697269 100644
Binary files a/web/apps/space/public/images/pwa-icon-192.png and b/web/apps/space/public/images/pwa-icon-192.png differ
diff --git a/web/apps/space/public/images/pwa-icon-512.png b/web/apps/space/public/images/pwa-icon-512.png
index dce34c9e6f..86b9f6baa6 100644
Binary files a/web/apps/space/public/images/pwa-icon-512.png and b/web/apps/space/public/images/pwa-icon-512.png differ
diff --git a/web/apps/space/src/components/AddFriendDialog.tsx b/web/apps/space/src/components/AddFriendDialog.tsx
index c5cfcba7b8..0acd48fbb1 100644
--- a/web/apps/space/src/components/AddFriendDialog.tsx
+++ b/web/apps/space/src/components/AddFriendDialog.tsx
@@ -239,7 +239,6 @@ export const SpaceAddFriendDialog: React.FC<SpaceAddFriendDialogProps> = ({
autoCapitalize="none"
autoComplete="off"
autoCorrect="off"
- autoFocus
aria-label="Friend's username"
aria-invalid={hasError || undefined}
disabled={isSubmitting || isSent}
diff --git a/web/apps/space/src/components/AppNavigation.tsx b/web/apps/space/src/components/AppNavigation.tsx
index a3c548a2a3..0cf479e7ed 100644
--- a/web/apps/space/src/components/AppNavigation.tsx
+++ b/web/apps/space/src/components/AppNavigation.tsx
@@ -1,8 +1,7 @@
import {
BubbleChatIcon,
Home01Icon,
- PlusSignSquareIcon,
- UserCircleIcon,
+ PlusSignIcon,
UserMultiple02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -18,11 +17,7 @@ import {
emptySpaceUnreadStatus,
SpaceUnreadStatusContext,
} from "state/navigation";
-import {
- spaceAppBackgroundColor,
- spaceText,
- spaceTextMuted,
-} from "styles/colors";
+import { spaceText } from "styles/colors";
import {
spaceNavigationDestination,
spaceUnreadStatusChangedEvent,
@@ -38,13 +33,21 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {
profileLoadStatus,
setPendingPostPhotoFiles,
} = useSpaceAppState();
- const showNavigation = Boolean(
+ const isAppPage = Boolean(
router.pathname == spaceRoutes.home ||
router.pathname.startsWith(`${spaceRoutes.home}/`) ||
(profile && router.pathname == spaceRoutes.friendPage),
);
+ const isConversation = router.pathname.startsWith(
+ `${spaceRoutes.messages}/`,
+ );
+ const isFriendPreview =
+ router.pathname == spaceRoutes.friends &&
+ typeof router.query.friend == "string" &&
+ router.query.expanded != "1";
+ const showNavigation = isAppPage && !isConversation && !isFriendPreview;
const spaceID =
- showNavigation && profileLoadStatus == "ready"
+ isAppPage && profileLoadStatus == "ready"
? profile?.spaceId
: undefined;
const [unreadStatus, setUnreadStatus] = React.useState(
@@ -55,8 +58,8 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {
const path = router.asPath.split(/[?#]/)[0] ?? router.pathname;
React.useEffect(() => {
- if (showNavigation) void preloadPostLikeAnimation();
- }, [showNavigation]);
+ if (isAppPage) void preloadPostLikeAnimation();
+ }, [isAppPage]);
React.useEffect(() => {
if (!spaceID) {
@@ -85,7 +88,7 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {
}, [spaceID, path]);
React.useEffect(() => {
- if (!showNavigation) return;
+ if (!isAppPage) return;
if (isSpaceIOS())
layoutRef.current?.style.setProperty(
"--space-bottom-nav-padding",
@@ -112,6 +115,10 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {
"--space-viewport-height",
`${viewport.height}px`,
);
+ layoutRef.current?.style.setProperty(
+ "--space-viewport-offset-top",
+ `${Math.max(0, viewport.offsetTop)}px`,
+ );
layoutRef.current?.style.setProperty(
"--space-keyboard-inset",
`${keyboardInset}px`,
@@ -128,36 +135,40 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {
document.removeEventListener("focusin", updateViewport);
document.removeEventListener("focusout", updateViewport);
};
- }, [showNavigation]);
+ }, [isAppPage]);
- const destinations = [
- { label: "Home", href: spaceRoutes.home, icon: Home01Icon, size: 23 },
- {
- label: "Messages",
- href: spaceRoutes.messages,
- icon: BubbleChatIcon,
- size: 23,
- },
- { label: "Post", icon: PlusSignSquareIcon, href: undefined, size: 25 },
- {
- label: "Friends",
- href: spaceRoutes.friends,
- icon: UserMultiple02Icon,
- size: 22,
- },
- {
- label: "Profile",
- href: spaceRoutes.profile,
- icon: UserCircleIcon,
- size: 22,
- },
+ const destinationGroups = [
+ [
+ {
+ label: "Messages",
+ href: spaceRoutes.messages,
+ icon: BubbleChatIcon,
+ size: 23,
+ },
+ ],
+ [
+ {
+ label: "Space",
+ href: spaceRoutes.home,
+ icon: Home01Icon,
+ size: 23,
+ },
+ {
+ label: "Friends",
+ href: spaceRoutes.friends,
+ icon: UserMultiple02Icon,
+ size: 22,
+ },
+ ],
+ [{ label: "Post", icon: PlusSignIcon, href: undefined, size: 25 }],
];
return (
<SpaceUnreadStatusContext.Provider value={unreadStatus}>
<Box
ref={layoutRef}
- className={showNavigation ? "space-app-layout" : undefined}
+ className={isAppPage ? "space-app-layout" : undefined}
+ data-space-conversation={isConversation || undefined}
>
{children}
{showNavigation && (
@@ -166,145 +177,262 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {
inputRef={postInputRef}
onSelect={setPendingPostPhotoFiles}
/>
+ <Box
+ aria-hidden
+ sx={{
+ bottom: "var(--space-keyboard-inset, 0px)",
+ height: "calc(54px + var(--space-bottom-nav-padding))",
+ left: "50%",
+ pointerEvents: "none",
+ position: "fixed",
+ transform: "translateX(-50%)",
+ width: "calc(100% - 16px)",
+ zIndex: 19,
+ "@media (min-width: 600px)": { maxWidth: 374 },
+ }}
+ >
+ {[
+ { blur: 0.5, start: 0, fade: 16 },
+ { blur: 1.5, start: 8, fade: 24 },
+ { blur: 3.5, start: 16, fade: 32 },
+ ].map(({ blur, start, fade }) => {
+ const mask = `linear-gradient(to bottom, transparent ${start}px, rgba(0, 0, 0, 0.104) ${start + fade / 4}px, rgba(0, 0, 0, 0.5) ${start + fade / 2}px, rgba(0, 0, 0, 0.896) ${start + (3 * fade) / 4}px, #000 ${start + fade}px)`;
+ return (
+ <Box
+ key={blur}
+ sx={{
+ position: "absolute",
+ inset: 0,
+ backdropFilter: `blur(${blur}px)`,
+ WebkitBackdropFilter: `blur(${blur}px)`,
+ maskImage: mask,
+ WebkitMaskImage: mask,
+ }}
+ />
+ );
+ })}
+ </Box>
<Box
component="nav"
aria-label="Main navigation"
sx={{
alignItems: "center",
- bgcolor: spaceAppBackgroundColor,
bottom: "var(--space-keyboard-inset, 0px)",
- display: "flex",
+ display: "grid",
+ columnGap: "12px",
+ gridTemplateColumns:
+ "52px minmax(0, 208px) 52px",
justifyContent: "space-between",
height: "var(--space-bottom-nav-height)",
- pb: "var(--space-bottom-nav-padding)",
+ pb: "calc(12px + var(--space-bottom-nav-padding))",
+ pt: "8px",
left: "50%",
- px: "10px",
+ px: "20px",
position: "fixed",
transform: "translateX(-50%)",
- viewTransitionName: "space-bottom-nav",
width: "100%",
zIndex: 20,
"@media (min-width: 600px)": { maxWidth: 390 },
}}
>
- {destinations.map(({ label, href, icon, size }) => {
- const selected = Boolean(
- href &&
- href ==
- spaceNavigationDestination(
- router.pathname,
- ),
- );
- const isPost = label == "Post";
- return (
- <Box
- key={label}
- component={isPost ? "button" : "a"}
- href={href}
- type={isPost ? "button" : undefined}
- disabled={
- isPost
- ? Boolean(pendingPostPhotoFiles)
- : undefined
- }
- aria-label={
- label == "Messages" &&
- unreadStatus.messagesUnread
- ? "Messages with unread activity"
- : label
- }
- aria-current={
- selected ? "page" : undefined
- }
- onClick={(
- event: React.MouseEvent<HTMLElement>,
- ) => {
- if (isPost) {
- postInputRef.current?.click();
- } else if (
+ {destinationGroups.map((destinations) => (
+ <Box
+ key={destinations[0]!.label}
+ data-space-bottom-nav-pill
+ sx={{
+ alignItems: "center",
+ backdropFilter:
+ "blur(24px) saturate(120%)",
+ WebkitBackdropFilter:
+ "blur(24px) saturate(120%)",
+ bgcolor: "rgba(32, 32, 32, 0.7)",
+ borderRadius: "999px",
+ display: "flex",
+ height: 52,
+ minWidth: 0,
+ p: "4px",
+ viewTransitionName: `space-bottom-nav-${destinations[0]!.label.toLowerCase()}`,
+ }}
+ >
+ {destinations.map(
+ ({ label, href, icon, size }) => {
+ const selected = Boolean(
href &&
- !event.metaKey &&
- !event.ctrlKey &&
- !event.shiftKey &&
- !event.altKey
- ) {
- event.preventDefault();
- if (path == href)
- window.scrollTo({
- top: 0,
- behavior: "smooth",
- });
- else void router.push(href);
- }
- }}
- sx={{
- alignItems: "center",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "24px",
- color: selected
- ? spaceText
- : spaceTextMuted,
- cursor: "pointer",
- display: "flex",
- height: 52,
- justifyContent: "center",
- minWidth: 0,
- width: 44,
- p: 0,
- textDecoration: "none",
- "&:focus-visible": {
- outline: "2px solid #08C225",
- outlineOffset: 2,
- },
- "&:disabled": {
- opacity: 0.6,
- cursor: "default",
- },
- }}
- >
- <Box
- sx={{
- alignItems: "center",
- display: "flex",
- height: size,
- justifyContent: "center",
- position: "relative",
- width: size,
- "& svg path:last-of-type":
- label == "Messages"
- ? { display: "none" }
- : undefined,
- }}
- >
- <HugeiconsIcon
- icon={icon}
- size={size}
- strokeWidth={1.8}
- absoluteStrokeWidth
- />
- {label == "Messages" &&
- unreadStatus.messagesUnread && (
+ href ==
+ spaceNavigationDestination(
+ router.pathname,
+ ),
+ );
+ const isPost = label == "Post";
+ const isCenter =
+ destinations.length > 1;
+ return (
+ <Box
+ key={label}
+ component={
+ isPost ? "button" : "a"
+ }
+ href={href}
+ type={
+ isPost
+ ? "button"
+ : undefined
+ }
+ disabled={
+ isPost
+ ? Boolean(
+ pendingPostPhotoFiles,
+ )
+ : undefined
+ }
+ aria-label={
+ label == "Messages" &&
+ unreadStatus.messagesUnread
+ ? "Messages with unread activity"
+ : label
+ }
+ aria-current={
+ selected
+ ? "page"
+ : undefined
+ }
+ onClick={(
+ event: React.MouseEvent<HTMLElement>,
+ ) => {
+ if (isPost) {
+ postInputRef.current?.click();
+ } else if (
+ href &&
+ !event.metaKey &&
+ !event.ctrlKey &&
+ !event.shiftKey &&
+ !event.altKey
+ ) {
+ event.preventDefault();
+ if (path == href)
+ window.scrollTo(
+ {
+ top: 0,
+ behavior:
+ "smooth",
+ },
+ );
+ else
+ void router.push(
+ href,
+ );
+ }
+ }}
+ sx={{
+ alignItems: "center",
+ bgcolor: selected
+ ? "rgba(255, 255, 255, 0.14)"
+ : "transparent",
+ border: 0,
+ borderRadius: "24px",
+ color: selected
+ ? spaceText
+ : "rgba(255, 255, 255, 0.75)",
+ cursor: "pointer",
+ display: "flex",
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 500,
+ height: 44,
+ justifyContent:
+ "center",
+ minWidth: 0,
+ width: isCenter
+ ? "50%"
+ : 44,
+ p: 0,
+ textDecoration: "none",
+ "&:focus-visible": {
+ outline:
+ "2px solid #08C225",
+ outlineOffset: 2,
+ },
+ "&:disabled": {
+ opacity: 0.6,
+ cursor: "default",
+ },
+ }}
+ >
<Box
- aria-hidden
- className="space-unread-indicator"
sx={{
- bgcolor: "#FF0000",
- border: `2.5px solid ${spaceAppBackgroundColor}`,
- borderRadius: "50%",
- height: 11.5,
+ alignItems:
+ "center",
+ display: "flex",
+ height: isCenter
+ ? undefined
+ : size,
+ justifyContent:
+ "center",
position:
- "absolute",
- right: "-0.75px",
- top: "-0.75px",
- width: 11.5,
+ "relative",
+ width: isCenter
+ ? undefined
+ : size,
+ "& svg":
+ label ==
+ "Messages" &&
+ unreadStatus.messagesUnread
+ ? {
+ maskImage:
+ "radial-gradient(circle at calc(100% - 5px) 5px, transparent 5.75px, #000 6px)",
+ WebkitMaskImage:
+ "radial-gradient(circle at calc(100% - 5px) 5px, transparent 5.75px, #000 6px)",
+ }
+ : undefined,
+ "& svg path:last-of-type":
+ label ==
+ "Messages"
+ ? {
+ display:
+ "none",
+ }
+ : undefined,
}}
- />
- )}
- </Box>
- </Box>
- );
- })}
+ >
+ {isCenter ? (
+ label
+ ) : (
+ <HugeiconsIcon
+ icon={icon}
+ size={size}
+ strokeWidth={
+ 1.8
+ }
+ absoluteStrokeWidth
+ />
+ )}
+ {label == "Messages" &&
+ unreadStatus.messagesUnread && (
+ <Box
+ aria-hidden
+ className="space-unread-indicator"
+ sx={{
+ bgcolor:
+ "#FF0000",
+ borderRadius:
+ "50%",
+ height: 6.5,
+ position:
+ "absolute",
+ right: "1.75px",
+ top: "1.75px",
+ width: 6.5,
+ }}
+ />
+ )}
+ </Box>
+ </Box>
+ );
+ },
+ )}
+ </Box>
+ ))}
</Box>
</>
)}
diff --git a/web/apps/space/src/components/AuthenticatedFriendProfile.tsx b/web/apps/space/src/components/AuthenticatedFriendProfile.tsx
index 34c74bad43..19d5202d57 100644
--- a/web/apps/space/src/components/AuthenticatedFriendProfile.tsx
+++ b/web/apps/space/src/components/AuthenticatedFriendProfile.tsx
@@ -1,3 +1,4 @@
+import { Portal } from "@mui/material";
import { spaceDefaultProfilePicPath } from "components/AvatarImage";
import { SpacePageMeta } from "components/PageMeta";
import { SpaceRouteFallback } from "components/RouteFallback";
@@ -28,12 +29,23 @@ import { spaceRoutes } from "utils/routes";
interface AuthenticatedFriendProfileProps {
friendSpaceId: string;
+ headerRef?: React.Ref<HTMLDivElement>;
+ isPreview?: boolean;
+ onBack?: () => void;
+ showPostLoadingIndicator?: boolean;
username: string;
}
export const AuthenticatedFriendProfile: React.FC<
AuthenticatedFriendProfileProps
-> = ({ friendSpaceId, username }) => {
+> = ({
+ friendSpaceId,
+ headerRef,
+ isPreview = false,
+ onBack,
+ showPostLoadingIndicator = false,
+ username,
+}) => {
const router = useSpaceRouter();
const { friends, profile, profileLoadError, profileLoadStatus } =
useSpaceAppState();
@@ -94,9 +106,7 @@ export const AuthenticatedFriendProfile: React.FC<
let cancelled = false;
setFriendProfile(undefined);
- setPosts([]);
setIsProfileLoading(true);
- setIsPostsLoading(true);
void loadCurrentSpaceProfile(friendSpaceId, viewerSpaceId)
.then((nextProfile) => {
if (!cancelled) setFriendProfile(nextProfile);
@@ -107,6 +117,19 @@ export const AuthenticatedFriendProfile: React.FC<
.finally(() => {
if (!cancelled) setIsProfileLoading(false);
});
+
+ return () => {
+ cancelled = true;
+ };
+ }, [friendSpaceId, profile?.spaceId]);
+
+ React.useEffect(() => {
+ const viewerSpaceId = profile?.spaceId;
+ if (isPreview || !viewerSpaceId) return;
+
+ let cancelled = false;
+ setPosts([]);
+ setIsPostsLoading(true);
void loadCurrentSpaceProfilePostsPage(friendSpaceId, viewerSpaceId)
.then((page) => {
if (!cancelled) setPosts(page.items);
@@ -121,7 +144,7 @@ export const AuthenticatedFriendProfile: React.FC<
return () => {
cancelled = true;
};
- }, [friendSpaceId, profile?.spaceId]);
+ }, [friendSpaceId, isPreview, profile?.spaceId]);
const goBack = () => {
void router.back(spaceRoutes.home);
@@ -157,11 +180,13 @@ export const AuthenticatedFriendProfile: React.FC<
title={`${friendDisplayName}'s profile`}
/>
<ProfileScreen
+ headerRef={headerRef}
headerVariant="friend"
+ isPreview={isPreview}
isCoverLoading={isProfileLoading}
isNameLoading={isProfileLoading && !immediateFriendProfile}
isPostsLoading={isPostsLoading}
- onBack={goBack}
+ onBack={onBack ?? goBack}
onLoadPostImage={loadCurrentSpacePostAssetURL}
onMessageFriend={() =>
void router.push(spaceRoutes.message(friendSpaceId))
@@ -206,23 +231,25 @@ export const AuthenticatedFriendProfile: React.FC<
}
postItems={postItems}
profile={displayedProfile}
- showPostLoadingIndicator={false}
+ showPostLoadingIndicator={showPostLoadingIndicator}
/>
{openProfileImage && (
<>
<SpacePageMeta
themeColor={friendProfileImageViewerBackground}
/>
- <FriendProfileImageViewerScreen
- displayName={friendDisplayName}
- imageUrl={
- openProfileImage == "cover"
- ? friendCoverUrl
- : friendAvatarUrl
- }
- onClose={() => setOpenProfileImage(null)}
- variant={openProfileImage}
- />
+ <Portal>
+ <FriendProfileImageViewerScreen
+ displayName={friendDisplayName}
+ imageUrl={
+ openProfileImage == "cover"
+ ? friendCoverUrl
+ : friendAvatarUrl
+ }
+ onClose={() => setOpenProfileImage(null)}
+ variant={openProfileImage}
+ />
+ </Portal>
</>
)}
</>
diff --git a/web/apps/space/src/components/AvatarCropPage.tsx b/web/apps/space/src/components/AvatarCropPage.tsx
index 964ddd7b8c..706e731131 100644
--- a/web/apps/space/src/components/AvatarCropPage.tsx
+++ b/web/apps/space/src/components/AvatarCropPage.tsx
@@ -19,7 +19,7 @@ const textLight = spaceTextMuted;
const warning = "#F63A3A";
export const spaceAppAvatarCropSize =
- "min(calc(100vw - 48px), calc(100dvh - 308px), 342px)";
+ "min(calc(100vw - 48px), calc(100dvh - 320px), 342px)";
export const spaceSetupAvatarCropSize =
"min(calc(100vw - 48px), calc(100dvh - 294px), 342px)";
export const spaceSetupAvatarCropFooterHeight = "130px";
@@ -195,7 +195,7 @@ export const SpaceAvatarCropPage: React.FC<SpaceAvatarCropPageProps> = ({
boxSizing: "border-box",
display: "grid",
gridTemplateRows: isAppHeader
- ? "56px minmax(0, 1fr) auto auto"
+ ? "68px minmax(0, 1fr) auto auto"
: `42px minmax(0, 1fr) auto ${spaceSetupAvatarCropFooterHeight}`,
height: "100%",
minHeight: 0,
@@ -219,7 +219,7 @@ export const SpaceAvatarCropPage: React.FC<SpaceAvatarCropPageProps> = ({
alignItems: "center",
display: "grid",
gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ height: 68,
px: 2,
width: "100%",
}
diff --git a/web/apps/space/src/components/ConversationPokeButton.tsx b/web/apps/space/src/components/ConversationPokeButton.tsx
new file mode 100644
index 0000000000..43e3bb782c
--- /dev/null
+++ b/web/apps/space/src/components/ConversationPokeButton.tsx
@@ -0,0 +1,148 @@
+import {
+ Cancel01Icon,
+ HandPointingRightIcon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Box } from "@mui/material";
+import type { SpaceActionPhase } from "components/ActionFeedback";
+import { SpaceActionToast } from "components/ActionToast";
+import log from "ente-base/log";
+import React from "react";
+import {
+ spaceDialogBackground,
+ spaceSurfaceHover,
+ spaceText,
+} from "styles/colors";
+import { spaceTouchTargetSize } from "styles/touch-targets";
+
+export const SpaceConversationPokeButton = ({
+ disabled,
+ friendName,
+ onPokeFriend,
+}: {
+ disabled: boolean;
+ friendName: string;
+ onPokeFriend: (requestID: string) => Promise<void>;
+}) => {
+ const [phase, setPhase] = React.useState<SpaceActionPhase>();
+ const [failed, setFailed] = React.useState(false);
+ const requestID = React.useRef<string | undefined>(undefined);
+
+ const poke = async () => {
+ if (disabled || phase) return;
+ setPhase("busy");
+ setFailed(false);
+ requestID.current ??= crypto.randomUUID();
+ try {
+ await onPokeFriend(requestID.current);
+ requestID.current = undefined;
+ setPhase("done");
+ } catch (error) {
+ log.error("Failed to send poke", error);
+ setFailed(true);
+ setPhase(undefined);
+ }
+ };
+
+ React.useEffect(() => {
+ if (phase != "done") return;
+ const timeout = window.setTimeout(() => setPhase(undefined), 2100);
+ return () => window.clearTimeout(timeout);
+ }, [phase]);
+
+ return (
+ <>
+ <Box
+ component="button"
+ type="button"
+ aria-label={phase == "done" ? "Poked" : `Poke ${friendName}`}
+ aria-busy={phase == "busy"}
+ aria-live="polite"
+ disabled={disabled || phase !== undefined}
+ onClick={() => void poke()}
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ borderRadius: "999px",
+ color: phase == "done" ? "#08C225" : spaceText,
+ cursor: disabled || phase ? "default" : "pointer",
+ display: "flex",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 600,
+ height: spaceTouchTargetSize,
+ justifyContent: "flex-end",
+ opacity: disabled ? 0.5 : 1,
+ p: 0,
+ pr: "4px",
+ width: "100%",
+ "&:hover:not(:disabled) > span": {
+ bgcolor: spaceSurfaceHover,
+ },
+ "&:focus-visible": {
+ outline: "2px solid #08C225",
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <Box
+ component="span"
+ aria-hidden
+ sx={{
+ alignItems: "center",
+ bgcolor:
+ phase == "done"
+ ? "rgba(8, 194, 37, 0.14)"
+ : spaceDialogBackground,
+ borderRadius: "999px",
+ display: "flex",
+ height: 36,
+ justifyContent: "center",
+ overflow: "hidden",
+ transition:
+ "width 220ms cubic-bezier(0.2, 0.8, 0.2, 1), background-color 160ms ease-out",
+ whiteSpace: "nowrap",
+ width: phase == "done" ? 68 : 36,
+ "& > span": {
+ animation: "spacePokeFeedback 180ms ease-out",
+ },
+ "@keyframes spacePokeFeedback": {
+ from: { opacity: 0, transform: "scale(0.9)" },
+ to: { opacity: 1, transform: "scale(1)" },
+ },
+ "@media (prefers-reduced-motion: reduce)": {
+ transition: "none",
+ "& > span": { animation: "none" },
+ },
+ }}
+ >
+ <Box
+ key={phase == "done" ? "done" : "idle"}
+ component="span"
+ sx={{ alignItems: "center", display: "flex" }}
+ >
+ {phase == "done" ? (
+ "Poked"
+ ) : (
+ <HugeiconsIcon
+ icon={HandPointingRightIcon}
+ size={22}
+ strokeWidth={2.2}
+ />
+ )}
+ </Box>
+ </Box>
+ </Box>
+ {failed && (
+ <SpaceActionToast
+ animateEntrance
+ closeLabel="Dismiss poke error"
+ icon={<HugeiconsIcon icon={Cancel01Icon} size={20} />}
+ message="Couldn't send poke. Try again."
+ onClose={() => setFailed(false)}
+ />
+ )}
+ </>
+ );
+};
diff --git a/web/apps/space/src/components/FileViewer.tsx b/web/apps/space/src/components/FileViewer.tsx
index 1c820a9321..cd1ba29441 100644
--- a/web/apps/space/src/components/FileViewer.tsx
+++ b/web/apps/space/src/components/FileViewer.tsx
@@ -11,7 +11,7 @@ import {
Tick02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { Box, Fade, Menu, MenuItem, Modal } from "@mui/material";
+import { Box, Fade, Menu, MenuItem, Modal, Portal } from "@mui/material";
import { keyframes } from "@mui/material/styles";
import { visuallyHidden } from "@mui/utils";
import {
@@ -73,7 +73,6 @@ const viewerBackground = "#000000";
const inputBackground = spaceControlBackground;
const inputBackgroundActive = spaceControlBackgroundHover;
const dangerColor = "#F63A3A";
-const viewerHeaderHeight = 56;
const viewerBottomPadding = 88;
const viewerDesktopMinWidth = 600;
const captionInputMinHeight = 40;
@@ -174,6 +173,7 @@ export interface SpaceFileViewerController {
interface SpaceFileViewerProps {
ref?: React.Ref<SpaceFileViewerController>;
closeOnSwipePastEnd?: boolean;
+ headerHeight?: number;
draftPhotoControls?: React.ReactNode;
onLoadPhoto?: SpacePostAssetURLLoader;
isDraftPostPreviewPending?: boolean;
@@ -206,7 +206,10 @@ interface SpaceFileViewerProps {
const setViewerBackground = (root: HTMLElement, opacity: number) =>
root.style.setProperty("--space-viewer-bg-opacity", String(opacity));
-const viewerPadding = (hasDraftPhotoControls: boolean) => {
+const viewerPadding = (
+ hasDraftPhotoControls: boolean,
+ headerHeight: number,
+) => {
const isDesktop = window.innerWidth >= viewerDesktopMinWidth;
return {
bottom: hasDraftPhotoControls
@@ -216,7 +219,7 @@ const viewerPadding = (hasDraftPhotoControls: boolean) => {
: viewerBottomPadding,
left: 0,
right: 0,
- top: isDesktop ? 0 : viewerHeaderHeight,
+ top: isDesktop ? 0 : headerHeight,
};
};
@@ -454,6 +457,7 @@ const SpaceViewerPhotoOverlay: React.FC<{
export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
ref,
closeOnSwipePastEnd = false,
+ headerHeight = 68,
draftPhotoControls,
onLoadPhoto,
focusReplyOnOpen = false,
@@ -710,6 +714,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
const viewport = viewerViewportSize();
const { top, bottom } = viewerPadding(
hasDraftPhotoControlsRef.current,
+ headerHeight,
);
const areaHeight = viewport.y - top - bottom;
const scale = Math.min(1, viewport.x / width, areaHeight / height);
@@ -722,7 +727,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
h,
};
},
- [viewerViewportSize],
+ [headerHeight, viewerViewportSize],
);
const requestCloseRef = React.useRef<
@@ -1258,6 +1263,31 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
pswpRef.current?.updateSize(true);
}, [hasDraftPhotoControls]);
+ React.useEffect(() => {
+ if (!isSpaceIOS() || !canReplyToPost) return;
+ const viewport = window.visualViewport;
+ if (!viewport) return;
+
+ const updateReplyViewport = () => {
+ const rect =
+ pswpRef.current?.currSlide?.content.element?.getBoundingClientRect();
+ if (rect && rect.width > 0)
+ motionRef.current.flight?.retarget({
+ x: rect.left,
+ y: rect.top,
+ w: rect.width,
+ h: rect.height,
+ });
+ };
+
+ viewport.addEventListener("resize", updateReplyViewport);
+ viewport.addEventListener("scroll", updateReplyViewport);
+ return () => {
+ viewport.removeEventListener("resize", updateReplyViewport);
+ viewport.removeEventListener("scroll", updateReplyViewport);
+ };
+ }, [canReplyToPost]);
+
const handleDeleteSheetExited = () => {
if (!isDeleteExit) return;
@@ -1416,7 +1446,10 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
loop: false,
mainClass: "pswp-space-viewer",
paddingFn: () =>
- viewerPadding(hasDraftPhotoControlsRef.current),
+ viewerPadding(
+ hasDraftPhotoControlsRef.current,
+ headerHeight,
+ ),
pinchToClose: false,
returnFocus: false,
showHideAnimationType: "none",
@@ -1689,7 +1722,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
pswp?.destroy();
root.style.removeProperty("--space-viewer-bg-opacity");
};
- }, [isDraftPost, viewerViewportSize]);
+ }, [headerHeight, isDraftPost, viewerViewportSize]);
React.useEffect(() => {
if (typeof document == "undefined") return;
@@ -1767,6 +1800,13 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
transition: `opacity ${draftPostExitDurationMs}ms cubic-bezier(0.22, 1, 0.36, 1)`,
width: "100%",
zIndex: 1300,
+ "& > .pswp, & > header, & > [data-space-viewer-chrome='true']":
+ {
+ translate:
+ isSpaceIOS() && canReplyToPost
+ ? "0 calc(-1 * var(--space-keyboard-inset, 0px))"
+ : undefined,
+ },
"& .space-photo-placeholder": {
alignItems: "center",
color: spaceTextMuted,
@@ -1795,6 +1835,15 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
},
}}
>
+ {isSpaceIOS() && isReplyFocused && (
+ <Portal
+ container={() =>
+ viewerRootRef.current?.parentElement ?? null
+ }
+ >
+ <SpaceViewerPostBackdrop />
+ </Portal>
+ )}
{!isDraftPost && (
<Box
component="span"
@@ -1816,7 +1865,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
flexShrink: 0,
gap: "12px",
gridTemplateColumns: "minmax(0, 1fr) auto",
- minHeight: viewerHeaderHeight,
+ minHeight: headerHeight,
position: "relative",
pl: "16px",
pr: "4px",
diff --git a/web/apps/space/src/components/FriendOrbit.tsx b/web/apps/space/src/components/FriendOrbit.tsx
index 9e9a2e81c0..1c57c30977 100644
--- a/web/apps/space/src/components/FriendOrbit.tsx
+++ b/web/apps/space/src/components/FriendOrbit.tsx
@@ -228,7 +228,7 @@ export const FriendOrbit: React.FC<FriendOrbitProps> = ({
suppressClick.current = false;
}}
sx={{
- height: "calc(var(--space-page-height, 100svh) - 56px)",
+ height: "calc(var(--space-page-height, 100svh) - 68px)",
listStyle: "none",
m: 0,
overflow: "hidden",
diff --git a/web/apps/space/src/components/FriendProfileSheet.tsx b/web/apps/space/src/components/FriendProfileSheet.tsx
new file mode 100644
index 0000000000..20296d2bdd
--- /dev/null
+++ b/web/apps/space/src/components/FriendProfileSheet.tsx
@@ -0,0 +1,381 @@
+import { Box, useMediaQuery } from "@mui/material";
+import FocusTrap from "@mui/material/Unstable_TrapFocus";
+import { AuthenticatedFriendProfile } from "components/AuthenticatedFriendProfile";
+import type { FriendProfile } from "data/friends";
+import React from "react";
+import { spaceAppBackgroundColor } from "styles/colors";
+import {
+ friendSheetSnap,
+ stepFriendSheetSpring,
+} from "utils/friend-profile-sheet";
+
+interface FriendProfileSheetProps {
+ expanded: boolean;
+ friend: FriendProfile;
+ onClose: () => void;
+ onExpand: () => void;
+}
+
+type SheetSnap = "collapsed" | "expanded" | "closed";
+const handleHeight = 28;
+
+export const FriendProfileSheet: React.FC<FriendProfileSheetProps> = ({
+ expanded,
+ friend,
+ onClose,
+ onExpand,
+}) => {
+ const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
+ const rootRef = React.useRef<HTMLDivElement>(null);
+ const panelRef = React.useRef<HTMLDivElement>(null);
+ const contentRef = React.useRef<HTMLDivElement>(null);
+ const headerRef = React.useRef<HTMLDivElement>(null);
+ const handleRef = React.useRef<HTMLButtonElement>(null);
+ const backdropRef = React.useRef<HTMLDivElement>(null);
+ const geometry = React.useRef({ collapsed: 0, height: 0 });
+ const motion = React.useRef({ position: 0, velocity: 0, frame: 0 });
+ const destination = React.useRef<SheetSnap>(
+ expanded ? "expanded" : "collapsed",
+ );
+ const callbacks = React.useRef({ onClose, onExpand });
+ callbacks.current = { onClose, onExpand };
+ const gesture = React.useRef<{
+ pointerId: number;
+ startY: number;
+ startPosition: number;
+ lastY: number;
+ lastTime: number;
+ velocity: number;
+ moved: boolean;
+ } | null>(null);
+ const suppressClick = React.useRef(false);
+
+ const paint = React.useCallback((position: number) => {
+ const { collapsed, height } = geometry.current;
+ const preview = collapsed > 0 ? Math.min(1, position / collapsed) : 0;
+ const backdrop =
+ position > collapsed
+ ? (0.64 * (height - position)) / (height - collapsed)
+ : 1 - 0.36 * preview;
+ motion.current.position = position;
+ panelRef.current!.style.transform = `translate3d(0, ${position}px, 0)`;
+ panelRef.current!.style.borderRadius = `${28 * preview}px ${28 * preview}px 0 0`;
+ panelRef.current!.style.setProperty(
+ "--space-friend-profile-reveal",
+ String(1 - preview),
+ );
+ handleRef.current!.style.opacity = String(preview);
+ backdropRef.current!.style.opacity = String(Math.max(0, backdrop));
+ }, []);
+
+ const animate = React.useCallback(
+ (snap: SheetSnap, complete?: () => void) => {
+ destination.current = snap;
+ cancelAnimationFrame(motion.current.frame);
+ let previousTime = performance.now();
+ const frame = (time: number) => {
+ const { collapsed, height } = geometry.current;
+ const target =
+ snap == "expanded"
+ ? 0
+ : snap == "closed"
+ ? height
+ : collapsed;
+ const next = stepFriendSheetSpring(
+ motion.current.position,
+ motion.current.velocity,
+ target,
+ time - previousTime,
+ );
+ previousTime = time;
+ if (
+ reducedMotion ||
+ (Math.abs(next.position - target) < 0.5 &&
+ Math.abs(next.velocity) < 5)
+ ) {
+ motion.current.velocity = 0;
+ motion.current.frame = 0;
+ paint(target);
+ complete?.();
+ return;
+ }
+ motion.current.velocity = next.velocity;
+ paint(Math.max(0, Math.min(height, next.position)));
+ motion.current.frame = requestAnimationFrame(frame);
+ };
+ motion.current.frame = requestAnimationFrame(frame);
+ },
+ [paint, reducedMotion],
+ );
+
+ React.useLayoutEffect(() => {
+ if (expanded) {
+ panelRef.current!.style.removeProperty("transform");
+ panelRef.current!.style.removeProperty("border-radius");
+ window.scrollTo(0, 0);
+ return;
+ }
+ const animation = motion.current;
+ const overflow = document.body.style.overflow;
+ document.body.style.overflow = "hidden";
+ const measure = () => {
+ const header = headerRef.current;
+ if (!header) return;
+ const height = rootRef.current!.clientHeight;
+ const headerBottom =
+ header.getBoundingClientRect().bottom -
+ contentRef.current!.getBoundingClientRect().top;
+ const bottomPadding = parseFloat(
+ getComputedStyle(contentRef.current!).paddingBottom,
+ );
+ const collapsed = Math.max(
+ handleHeight,
+ height - headerBottom - bottomPadding,
+ );
+ const initial = geometry.current.height == 0;
+ geometry.current = { collapsed, height };
+ if (initial) {
+ paint(height);
+ }
+ if (!gesture.current && !motion.current.frame) {
+ animate(destination.current);
+ }
+ };
+ const observer = new ResizeObserver(measure);
+ observer.observe(rootRef.current!);
+ observer.observe(contentRef.current!);
+ return () => {
+ observer.disconnect();
+ cancelAnimationFrame(animation.frame);
+ animation.frame = 0;
+ document.body.style.overflow = overflow;
+ };
+ }, [animate, expanded, paint]);
+
+ const dismiss = () => {
+ panelRef.current!.scrollTop = 0;
+ animate("closed", () => callbacks.current.onClose());
+ };
+ const expand = () =>
+ animate("expanded", () => callbacks.current.onExpand());
+
+ const finishDrag = (event: React.PointerEvent<HTMLDivElement>) => {
+ const current = gesture.current;
+ if (event.pointerId != current?.pointerId) return;
+ gesture.current = null;
+ if (!current.moved) {
+ animate("collapsed");
+ return;
+ }
+ suppressClick.current = true;
+ motion.current.velocity =
+ event.timeStamp - current.lastTime < 100 ? current.velocity : 0;
+ const { collapsed, height } = geometry.current;
+ const snap = friendSheetSnap(
+ motion.current.position,
+ motion.current.velocity,
+ collapsed,
+ height,
+ );
+ animate(
+ snap,
+ snap == "expanded"
+ ? () => callbacks.current.onExpand()
+ : snap == "closed"
+ ? () => callbacks.current.onClose()
+ : undefined,
+ );
+ };
+
+ return (
+ <Box
+ ref={rootRef}
+ sx={{
+ "--space-profile-post-loading-top": "70%",
+ ...(expanded
+ ? { position: "relative" }
+ : { inset: 0, position: "fixed", zIndex: 1300 }),
+ }}
+ >
+ <Box
+ ref={backdropRef}
+ aria-hidden
+ onClick={expanded ? undefined : dismiss}
+ sx={{
+ bgcolor: spaceAppBackgroundColor,
+ display: expanded ? "none" : "block",
+ inset: 0,
+ opacity: expanded ? 1 : 0,
+ position: "absolute",
+ }}
+ />
+ <FocusTrap open={!expanded} disableEnforceFocus>
+ <Box
+ ref={panelRef}
+ role={expanded ? undefined : "dialog"}
+ aria-modal={expanded ? undefined : true}
+ aria-label={`${friend.fullName.trim() || friend.username}'s profile`}
+ tabIndex={-1}
+ onKeyDown={(event) => {
+ if (
+ event.key == "Escape" &&
+ !event.defaultPrevented &&
+ (event.target as HTMLElement).closest(
+ '[role="dialog"]',
+ ) == event.currentTarget
+ ) {
+ event.stopPropagation();
+ dismiss();
+ }
+ }}
+ onPointerDown={(event) => {
+ if (
+ expanded ||
+ !event.isPrimary ||
+ event.button != 0 ||
+ !event.currentTarget.contains(event.target as Node)
+ )
+ return;
+ (event.target as Element).setPointerCapture(
+ event.pointerId,
+ );
+ cancelAnimationFrame(motion.current.frame);
+ motion.current.frame = 0;
+ motion.current.velocity = 0;
+ suppressClick.current = false;
+ gesture.current = {
+ pointerId: event.pointerId,
+ startY: event.clientY,
+ startPosition: motion.current.position,
+ lastY: event.clientY,
+ lastTime: event.timeStamp,
+ velocity: 0,
+ moved: false,
+ };
+ }}
+ onPointerMove={(event) => {
+ const current = gesture.current;
+ if (event.pointerId != current?.pointerId) return;
+ const distance = event.clientY - current.startY;
+ if (!current.moved && Math.abs(distance) < 6) return;
+ if (!current.moved)
+ event.currentTarget.setPointerCapture(
+ event.pointerId,
+ );
+ current.moved = true;
+ const elapsed = event.timeStamp - current.lastTime;
+ if (elapsed > 0)
+ current.velocity =
+ 0.5 * current.velocity +
+ ((0.5 * (event.clientY - current.lastY)) /
+ elapsed) *
+ 1000;
+ current.lastY = event.clientY;
+ current.lastTime = event.timeStamp;
+ paint(
+ Math.max(
+ 0,
+ Math.min(
+ geometry.current.height,
+ current.startPosition + distance,
+ ),
+ ),
+ );
+ }}
+ onPointerUp={finishDrag}
+ onPointerCancel={() => {
+ if (!gesture.current) return;
+ gesture.current = null;
+ motion.current.velocity = 0;
+ animate("collapsed");
+ }}
+ onDragStart={(event) => {
+ if (!expanded) event.preventDefault();
+ }}
+ onClickCapture={(event) => {
+ if (expanded || !suppressClick.current) return;
+ suppressClick.current = false;
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ sx={{
+ bgcolor: spaceAppBackgroundColor,
+ borderRadius: expanded ? 0 : "28px 28px 0 0",
+ height: expanded ? "auto" : "100%",
+ inset: expanded ? undefined : 0,
+ mx: "auto",
+ outline: "none",
+ overflow: expanded ? "visible" : "hidden",
+ overscrollBehavior: expanded ? "auto" : "contain",
+ position: expanded ? "relative" : "absolute",
+ touchAction: expanded ? "auto" : "none",
+ userSelect: expanded ? "auto" : "none",
+ transform: expanded
+ ? "none"
+ : "translate3d(0, 100%, 0)",
+ willChange: expanded ? "auto" : "transform",
+ width: "100%",
+ ...(!expanded && { "& *": { touchAction: "none" } }),
+ }}
+ >
+ <Box
+ ref={contentRef}
+ sx={{
+ pb: expanded
+ ? 0
+ : "max(24px, env(safe-area-inset-bottom))",
+ }}
+ >
+ <AuthenticatedFriendProfile
+ friendSpaceId={friend.spaceId ?? friend.id}
+ headerRef={headerRef}
+ isPreview={!expanded}
+ showPostLoadingIndicator
+ onBack={expanded ? onClose : dismiss}
+ username={friend.username}
+ />
+ </Box>
+ <Box
+ ref={handleRef}
+ component="button"
+ type="button"
+ aria-label="Expand profile"
+ aria-hidden={expanded}
+ tabIndex={expanded ? -1 : 0}
+ onClick={expand}
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ cursor: "grab",
+ display: expanded ? "none" : "flex",
+ height: handleHeight,
+ justifyContent: "center",
+ opacity: expanded ? 0 : 1,
+ pointerEvents: expanded ? "none" : "auto",
+ p: 0,
+ position: "absolute",
+ top: 0,
+ width: "100%",
+ zIndex: 4,
+ "&:focus-visible": {
+ outline: "2px solid #08C225",
+ outlineOffset: -2,
+ },
+ }}
+ >
+ <Box
+ sx={{
+ bgcolor: "#D8D8D8",
+ borderRadius: "999px",
+ boxShadow: "0 1px 3px rgba(0, 0, 0, 0.4)",
+ height: 5,
+ width: 44,
+ }}
+ />
+ </Box>
+ </Box>
+ </FocusTrap>
+ </Box>
+ );
+};
diff --git a/web/apps/space/src/components/HomeHeader.tsx b/web/apps/space/src/components/HomeHeader.tsx
index 9d094f201a..3ee44051a2 100644
--- a/web/apps/space/src/components/HomeHeader.tsx
+++ b/web/apps/space/src/components/HomeHeader.tsx
@@ -1,13 +1,29 @@
-import { Menu01Icon, Notification01Icon } from "@hugeicons/core-free-icons";
+import { Notification01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { Box } from "@mui/material";
+import { Box, Skeleton } from "@mui/material";
+import { SpaceAvatarImage } from "components/AvatarImage";
import React from "react";
+import type { SetupProfile } from "screens/SetupProfileScreen";
+import { useSpaceAppState } from "state/app-state";
import { useSpaceUnreadStatus } from "state/navigation";
-import { spaceAppBackgroundColor, spaceText } from "styles/colors";
+import {
+ spaceAppBackgroundColor,
+ spaceSurface,
+ spaceText,
+} from "styles/colors";
import { useSpaceRouter } from "utils/route-transitions";
import { spaceRoutes } from "utils/routes";
-export const SpaceHomeHeader: React.FC = () => {
+const headerAvatarImageSize = 28;
+const avatarFadeSx = {
+ "@keyframes spaceAvatarFade": { from: { opacity: 0 }, to: { opacity: 1 } },
+ animation: "spaceAvatarFade 320ms cubic-bezier(0.22, 1, 0.36, 1) both",
+ "@media (prefers-reduced-motion: reduce)": { animation: "none" },
+} as const;
+
+export const SpaceHomeHeader: React.FC<{ profile: SetupProfile | null }> = ({
+ profile,
+}) => {
const router = useSpaceRouter();
const { notificationsUnread } = useSpaceUnreadStatus();
const [visible, setVisible] = React.useState(true);
@@ -59,7 +75,7 @@ export const SpaceHomeHeader: React.FC = () => {
color: spaceText,
display: "grid",
gridTemplateColumns: "44px minmax(0, 1fr) 44px",
- height: 60,
+ height: 68,
mx: "auto",
px: 2,
position: "sticky",
@@ -77,16 +93,11 @@ export const SpaceHomeHeader: React.FC = () => {
<Box
component="button"
type="button"
- aria-label="Settings"
- onClick={() => void router.push(spaceRoutes.settings)}
+ aria-label="Profile"
+ onClick={() => void router.push(spaceRoutes.profile)}
sx={{ ...actionSx, justifyContent: "flex-start" }}
>
- <HugeiconsIcon
- icon={Menu01Icon}
- size={23}
- strokeWidth={1.8}
- absoluteStrokeWidth
- />
+ <SpaceHomeHeaderAvatar profile={profile} />
</Box>
<Box
component="img"
@@ -146,3 +157,36 @@ export const SpaceHomeHeader: React.FC = () => {
</Box>
);
};
+
+const SpaceHomeHeaderAvatar: React.FC<{ profile: SetupProfile | null }> = ({
+ profile,
+}) => {
+ const { cachedProfileAvatarUrl } = useSpaceAppState();
+ const avatarUrl = profile ? profile.avatarUrl : cachedProfileAvatarUrl;
+
+ return avatarUrl || (profile && !profile.avatarObjectID) ? (
+ <Box
+ key={avatarUrl ?? "default-avatar"}
+ sx={{
+ ...avatarFadeSx,
+ borderRadius: "50%",
+ filter: avatarUrl ? undefined : "brightness(0.9)",
+ height: headerAvatarImageSize,
+ overflow: "hidden",
+ width: headerAvatarImageSize,
+ }}
+ >
+ <SpaceAvatarImage src={avatarUrl} />
+ </Box>
+ ) : (
+ <Skeleton
+ variant="circular"
+ sx={{
+ bgcolor: spaceSurface,
+ height: headerAvatarImageSize,
+ transform: "none",
+ width: headerAvatarImageSize,
+ }}
+ />
+ );
+};
diff --git a/web/apps/space/src/components/MessagesPage.tsx b/web/apps/space/src/components/MessagesPage.tsx
index 515c126c79..9be2afa564 100644
--- a/web/apps/space/src/components/MessagesPage.tsx
+++ b/web/apps/space/src/components/MessagesPage.tsx
@@ -15,6 +15,7 @@ import {
markCurrentMessagesRead,
replyToCurrentMessage,
sendCurrentMessage,
+ sendCurrentPoke,
setCurrentMessageReaction,
shouldAutoReadMessageActivities,
type SpaceMessage,
@@ -625,6 +626,9 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
onLoadActivityPost={(post) =>
loadCurrentPostPreview(post, actorSpaceId)
}
+ onPokeFriend={(spaceId, requestID) =>
+ sendCurrentPoke(actorSpaceId, spaceId, requestID)
+ }
onSendMessage={async (spaceId, text) => {
const sender = currentProfileMessageActor(profile);
const recipient =
diff --git a/web/apps/space/src/components/PostGrid.tsx b/web/apps/space/src/components/PostGrid.tsx
index 9f0216400f..48aacd6f71 100644
--- a/web/apps/space/src/components/PostGrid.tsx
+++ b/web/apps/space/src/components/PostGrid.tsx
@@ -1,8 +1,6 @@
import { Box } from "@mui/material";
import React from "react";
-import { minimumPostPhotoFrameAspectRatio } from "styles/tiles";
-
-const gap = 8;
+import { layoutPostGrid } from "utils/post-grid";
interface PostGridItem {
id: string;
@@ -36,56 +34,18 @@ export const SpacePostGrid = <Item extends PostGridItem>({
const fullWidth =
postCount != undefined && Math.max(postCount, items.length) < 4;
- const columnCount = fullWidth ? 1 : 2;
- const columnWidth = (width - (columnCount - 1) * gap) / columnCount;
- const columnHeights = new Array<number>(columnCount).fill(0);
- const tiles =
- width > gap
- ? items.map((item, index) => {
- const column =
- fullWidth || columnHeights[0]! <= columnHeights[1]!
- ? 0
- : 1;
- const top = columnHeights[column]!;
- const photoAspectRatio =
- item.frameAspectRatio ??
- (item.width && item.height
- ? item.width / item.height
- : 1);
- const aspectRatio = Math.max(
- minimumPostPhotoFrameAspectRatio,
- photoAspectRatio,
- );
- const height = columnWidth / aspectRatio;
- columnHeights[column] = top + height + gap;
- return (
- <Box
- key={item.id}
- sx={{
- height,
- left: column * (columnWidth + gap),
- position: "absolute",
- top,
- width: columnWidth,
- }}
- >
- {renderTile(item, index)}
- </Box>
- );
- })
- : [];
+ const { tiles, height } = layoutPostGrid(items, width, fullWidth);
return (
- <Box
- ref={gridRef}
- sx={{
- height:
- Math.max(0, ...columnHeights) - (tiles.length ? gap : 0),
- position: "relative",
- width: "100%",
- }}
- >
- {tiles}
+ <Box ref={gridRef} sx={{ height, position: "relative", width: "100%" }}>
+ {tiles.map((tile, index) => (
+ <Box
+ key={items[index]!.id}
+ sx={{ ...tile, position: "absolute" }}
+ >
+ {renderTile(items[index]!, index)}
+ </Box>
+ ))}
</Box>
);
};
diff --git a/web/apps/space/src/components/PostPhotosBadge.tsx b/web/apps/space/src/components/PostPhotosBadge.tsx
index 8a757da6a9..a316be4c3b 100644
--- a/web/apps/space/src/components/PostPhotosBadge.tsx
+++ b/web/apps/space/src/components/PostPhotosBadge.tsx
@@ -13,6 +13,7 @@ export const SpacePostPhotosBadge = ({
<Box
component="span"
aria-label={`${count} items`}
+ data-space-viewer-photos-badge
sx={{
alignItems: "center",
color: "#FFFFFF",
diff --git a/web/apps/space/src/components/viewer-transition.ts b/web/apps/space/src/components/viewer-transition.ts
index 962c7f0b18..b0ef361535 100644
--- a/web/apps/space/src/components/viewer-transition.ts
+++ b/web/apps/space/src/components/viewer-transition.ts
@@ -204,15 +204,18 @@ const createRider = (flyer: HTMLElement, tile: HTMLElement) => {
"[data-space-viewer-avatar]",
);
const avatar = button?.firstElementChild;
- if (!button || !(avatar instanceof HTMLElement)) return undefined;
+ const badge = tile.querySelector<HTMLElement>(
+ "[data-space-viewer-photos-badge]",
+ );
+ const elements: HTMLElement[] = [];
+ if (button && avatar instanceof HTMLElement) elements.push(avatar);
+ if (badge) elements.push(badge);
+ if (!elements.length) return undefined;
+
const tileRect = rectOf(tile);
- const avatarRect = rectOf(avatar);
- const left = avatarRect.x - tileRect.x;
- const fromBottom = tileRect.y + tileRect.h - avatarRect.y;
- const rider = avatar.cloneNode(true) as HTMLElement;
- for (const element of [rider, ...rider.querySelectorAll("*")])
- if (element instanceof HTMLElement) element.style.animation = "none";
+ const rider = document.createElement("div");
rider.setAttribute("aria-hidden", "true");
+ rider.inert = true;
Object.assign(rider.style, {
left: "0",
pointerEvents: "none",
@@ -220,20 +223,44 @@ const createRider = (flyer: HTMLElement, tile: HTMLElement) => {
top: "0",
zIndex: "1",
});
+ const drawElements = elements.map((element) => {
+ const bounds = rectOf(element);
+ const clone = element.cloneNode(true) as HTMLElement;
+ for (const child of [clone, ...clone.querySelectorAll("*")])
+ if (child instanceof HTMLElement) child.style.animation = "none";
+ Object.assign(clone.style, {
+ left: "0",
+ position: "absolute",
+ right: "auto",
+ top: "0",
+ });
+ rider.append(clone);
+ element.style.opacity = "0";
+ return (v: ViewerRect) => {
+ const x =
+ element == avatar
+ ? v.x + bounds.x - tileRect.x
+ : v.x + v.w - (tileRect.x + tileRect.w - bounds.x);
+ const y =
+ element == avatar
+ ? v.y + v.h - (tileRect.y + tileRect.h - bounds.y)
+ : v.y + bounds.y - tileRect.y;
+ clone.style.transform = `translate3d(${x}px, ${y}px, 0)`;
+ };
+ });
flyer.after(rider);
- button.style.opacity = "0";
return {
element: rider,
draw: ({ visible: v }: ViewerPhotoState, t: number) => {
- rider.style.transform = `translate3d(${v.x + left}px, ${v.y + v.h - fromBottom}px, 0)`;
+ for (const drawElement of drawElements) drawElement(v);
rider.style.opacity = String(
1 - Math.min(1, Math.max(0, t / 0.35)),
);
},
remove: () => rider.remove(),
reveal: () => {
- button.style.opacity = "";
+ for (const element of elements) element.style.opacity = "";
},
};
};
diff --git a/web/apps/space/src/pages/_app.tsx b/web/apps/space/src/pages/_app.tsx
index 8870b11a5d..bf477f3023 100644
--- a/web/apps/space/src/pages/_app.tsx
+++ b/web/apps/space/src/pages/_app.tsx
@@ -119,7 +119,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
>
<CustomHead
title={spacePageTitle(router.pathname)}
- viewportContent="width=device-width, initial-scale=1, maximum-scale=1"
+ viewportContent="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover"
>
<link
rel="preload"
@@ -149,6 +149,13 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
<link
rel="apple-touch-icon"
href="/images/apple-touch-icon.png"
+ sizes="180x180"
+ />
+ <link
+ rel="icon"
+ href="/favicon.ico"
+ sizes="16x16 32x32 48x48"
+ type="image/x-icon"
/>
</CustomHead>
<CssBaseline enableColorScheme />
diff --git a/web/apps/space/src/pages/app/friends/index.tsx b/web/apps/space/src/pages/app/friends/index.tsx
index 143ce35e0a..c9f8f79203 100644
--- a/web/apps/space/src/pages/app/friends/index.tsx
+++ b/web/apps/space/src/pages/app/friends/index.tsx
@@ -1,3 +1,5 @@
+import { Box } from "@mui/material";
+import { FriendProfileSheet } from "components/FriendProfileSheet";
import { SpaceFriendRequestCanceledToast } from "components/FriendRequestCanceledToast";
import { SpacePageMeta } from "components/PageMeta";
import { SpaceRouteFallback } from "components/RouteFallback";
@@ -36,6 +38,10 @@ const Page: React.FC = () => {
const [isFriendsLoading, setIsFriendsLoading] = React.useState(true);
const [showFriendRequestCanceledToast, setShowFriendRequestCanceledToast] =
React.useState(false);
+ const selectedFriend = friends.find(
+ (friend) => friend.username == router.query.friend,
+ );
+ const isProfileExpanded = router.query.expanded == "1";
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -84,121 +90,162 @@ const Page: React.FC = () => {
return (
<>
<SpacePageMeta themeColor={spaceAppBackgroundColor} />
- <FriendsScreen
- friendRequests={friendRequests}
- friends={friends}
- isLoading={isFriendsLoading}
- onBack={() => void router.back(spaceRoutes.home)}
- onLoadFriendAvatar={loadCurrentFriendAvatarURL}
- onAddFriend={async (username) => {
- const actorSpaceId = profile.spaceId;
- if (!actorSpaceId) throw new Error("Missing space.");
- const status = await requestFriendByUsername({
- spaceUsername: username,
- });
- try {
- if (status == "friend") {
- clearSpaceFriendsCache();
- const [requests, friends] = await Promise.all([
- loadCurrentFriendRequests(actorSpaceId),
- loadCurrentSpaceFriends(actorSpaceId),
- ]);
- setFriendRequests(requests);
- setFriends(friends);
- } else {
- setFriendRequests(
- await loadCurrentFriendRequests(actorSpaceId),
+ {!(selectedFriend && isProfileExpanded) && (
+ <Box inert={Boolean(selectedFriend)}>
+ <FriendsScreen
+ friendRequests={friendRequests}
+ friends={friends}
+ isLoading={isFriendsLoading}
+ onBack={() => void router.back(spaceRoutes.home)}
+ onLoadFriendAvatar={loadCurrentFriendAvatarURL}
+ onAddFriend={async (username) => {
+ const actorSpaceId = profile.spaceId;
+ if (!actorSpaceId)
+ throw new Error("Missing space.");
+ const status = await requestFriendByUsername({
+ spaceUsername: username,
+ });
+ try {
+ if (status == "friend") {
+ clearSpaceFriendsCache();
+ const [requests, friends] =
+ await Promise.all([
+ loadCurrentFriendRequests(
+ actorSpaceId,
+ ),
+ loadCurrentSpaceFriends(
+ actorSpaceId,
+ ),
+ ]);
+ setFriendRequests(requests);
+ setFriends(friends);
+ } else {
+ setFriendRequests(
+ await loadCurrentFriendRequests(
+ actorSpaceId,
+ ),
+ );
+ }
+ } catch (error) {
+ log.error(
+ "Failed to refresh friends after sending request",
+ error,
+ );
+ }
+ return status;
+ }}
+ onOpenFriend={(friendID) => {
+ const friend = friends.find(
+ (candidate) =>
+ candidate.id == friendID ||
+ candidate.spaceId == friendID,
+ );
+ if (friend)
+ void router.push(
+ {
+ pathname: spaceRoutes.friends,
+ query: { friend: friend.username },
+ },
+ undefined,
+ { shallow: true, scroll: false },
+ );
+ }}
+ profileLink={spaceInviteURL({
+ spaceUsername: profile.username,
+ })}
+ username={profile.username}
+ onAcceptFriendRequest={async (requestID) => {
+ const actorSpaceId = profile.spaceId;
+ if (!actorSpaceId) return false;
+ try {
+ await confirmCurrentFriendRequest(
+ actorSpaceId,
+ requestID,
+ );
+ } catch (error: unknown) {
+ if (!isFriendRequestCanceledError(error))
+ throw error;
+ setFriendRequests((currentRequests) =>
+ currentRequests.filter(
+ (request) =>
+ request.requestId != requestID,
+ ),
+ );
+ setShowFriendRequestCanceledToast(true);
+ return false;
+ }
+ const loadedFriends =
+ await loadCurrentSpaceFriends(actorSpaceId);
+ setFriendRequests((currentRequests) =>
+ currentRequests.filter(
+ (request) => request.requestId != requestID,
+ ),
+ );
+ setFriends(loadedFriends);
+ return true;
+ }}
+ onDeleteFriendRequest={async (requestID) => {
+ const actorSpaceId = profile.spaceId;
+ if (!actorSpaceId) return;
+ const friendRequest = friendRequests.find(
+ (request) => request.requestId == requestID,
);
- }
- } catch (error) {
- log.error(
- "Failed to refresh friends after sending request",
- error,
- );
- }
- return status;
- }}
- onOpenFriend={(friendID) => {
- const friend = friends.find(
- (candidate) =>
- candidate.id == friendID ||
- candidate.spaceId == friendID,
- );
- if (friend)
- void router.push(
- spaceRoutes.friendPage,
- spaceRoutes.friend(friend.username),
- );
- }}
- profileLink={spaceInviteURL({
- spaceUsername: profile.username,
- })}
- username={profile.username}
- onAcceptFriendRequest={async (requestID) => {
- const actorSpaceId = profile.spaceId;
- if (!actorSpaceId) return false;
- try {
- await confirmCurrentFriendRequest(
- actorSpaceId,
- requestID,
- );
- } catch (error: unknown) {
- if (!isFriendRequestCanceledError(error)) throw error;
- setFriendRequests((currentRequests) =>
- currentRequests.filter(
- (request) => request.requestId != requestID,
- ),
- );
- setShowFriendRequestCanceledToast(true);
- return false;
- }
- const loadedFriends =
- await loadCurrentSpaceFriends(actorSpaceId);
- setFriendRequests((currentRequests) =>
- currentRequests.filter(
- (request) => request.requestId != requestID,
- ),
- );
- setFriends(loadedFriends);
- return true;
- }}
- onDeleteFriendRequest={async (requestID) => {
- const actorSpaceId = profile.spaceId;
- if (!actorSpaceId) return;
- const friendRequest = friendRequests.find(
- (request) => request.requestId == requestID,
- );
- try {
- await deleteCurrentFriendRequest(
- actorSpaceId,
- requestID,
- );
- } catch (error: unknown) {
- if (!isFriendRequestCanceledError(error)) throw error;
- clearSpaceFriendsCache();
- const [requests, friends] = await Promise.all([
- loadCurrentFriendRequests(actorSpaceId),
- loadCurrentSpaceFriends(actorSpaceId),
- ]);
- setFriendRequests(requests);
- setFriends(friends);
- setShowFriendRequestCanceledToast(
- !friendRequest ||
- !friends.some(
- (friend) =>
- friend.id == friendRequest.friend.id,
+ try {
+ await deleteCurrentFriendRequest(
+ actorSpaceId,
+ requestID,
+ );
+ } catch (error: unknown) {
+ if (!isFriendRequestCanceledError(error))
+ throw error;
+ clearSpaceFriendsCache();
+ const [requests, friends] = await Promise.all([
+ loadCurrentFriendRequests(actorSpaceId),
+ loadCurrentSpaceFriends(actorSpaceId),
+ ]);
+ setFriendRequests(requests);
+ setFriends(friends);
+ setShowFriendRequestCanceledToast(
+ !friendRequest ||
+ !friends.some(
+ (friend) =>
+ friend.id ==
+ friendRequest.friend.id,
+ ),
+ );
+ return;
+ }
+ setFriendRequests((currentRequests) =>
+ currentRequests.filter(
+ (request) => request.requestId != requestID,
),
- );
- return;
+ );
+ }}
+ />
+ </Box>
+ )}
+ {selectedFriend && (
+ <FriendProfileSheet
+ key={selectedFriend.id}
+ expanded={isProfileExpanded}
+ friend={selectedFriend}
+ onClose={() => void router.back(spaceRoutes.friends)}
+ onExpand={() =>
+ void router.replace(
+ {
+ pathname: spaceRoutes.friends,
+ query: {
+ friend: selectedFriend.username,
+ expanded: "1",
+ },
+ },
+ spaceRoutes.friend(selectedFriend.username),
+ { shallow: true, scroll: false },
+ )
}
- setFriendRequests((currentRequests) =>
- currentRequests.filter(
- (request) => request.requestId != requestID,
- ),
- );
- }}
- />
+ />
+ )}
{showFriendRequestCanceledToast && (
<SpaceFriendRequestCanceledToast
onClose={() => setShowFriendRequestCanceledToast(false)}
diff --git a/web/apps/space/src/pages/app/notifications.tsx b/web/apps/space/src/pages/app/notifications.tsx
index 64f7a9210e..652800a81e 100644
--- a/web/apps/space/src/pages/app/notifications.tsx
+++ b/web/apps/space/src/pages/app/notifications.tsx
@@ -1053,7 +1053,7 @@ const Page: React.FC = () => {
display: "grid",
alignItems: "center",
gridTemplateColumns: "44px 1fr 44px",
- height: 56,
+ height: 68,
px: 2,
}}
>
diff --git a/web/apps/space/src/pages/app/profile.tsx b/web/apps/space/src/pages/app/profile.tsx
index 2aee41e0f4..352446ce90 100644
--- a/web/apps/space/src/pages/app/profile.tsx
+++ b/web/apps/space/src/pages/app/profile.tsx
@@ -195,6 +195,7 @@ const Page: React.FC = () => {
onOpenProfilePhoto={() =>
void router.push(spaceRoutes.profilePhoto)
}
+ onOpenSettings={() => void router.push(spaceRoutes.settings)}
onLoadPostImage={loadCurrentSpacePostAssetURL}
onSetPostLiked={async (postId, liked) => {
await setCurrentPostLiked(actorSpaceId, postId, liked);
diff --git a/web/apps/space/src/pages/app/settings.tsx b/web/apps/space/src/pages/app/settings.tsx
index b9a89367dc..d0e3ec553c 100644
--- a/web/apps/space/src/pages/app/settings.tsx
+++ b/web/apps/space/src/pages/app/settings.tsx
@@ -32,7 +32,7 @@ const Page: React.FC = () => {
<>
<SpacePageMeta themeColor={spaceAppBackgroundColor} />
<SettingsScreen
- onBack={() => void router.back(spaceRoutes.home)}
+ onBack={() => void router.back(spaceRoutes.profile)}
onChangeCoverImage={() =>
void router.push(spaceRoutes.profileCoverFrom("settings"))
}
diff --git a/web/apps/space/src/screens/EditProfilePhotoScreen.tsx b/web/apps/space/src/screens/EditProfilePhotoScreen.tsx
index bc061bf91e..65835d973c 100644
--- a/web/apps/space/src/screens/EditProfilePhotoScreen.tsx
+++ b/web/apps/space/src/screens/EditProfilePhotoScreen.tsx
@@ -74,7 +74,7 @@ const EditProfilePhotoShell: React.FC<
alignItems: "center",
display: "grid",
gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ height: 68,
px: 2,
width: "100%",
}}
diff --git a/web/apps/space/src/screens/FriendRequestScreen.tsx b/web/apps/space/src/screens/FriendRequestScreen.tsx
index f6562fa206..225281f125 100644
--- a/web/apps/space/src/screens/FriendRequestScreen.tsx
+++ b/web/apps/space/src/screens/FriendRequestScreen.tsx
@@ -64,7 +64,7 @@ export const FriendRequestScreen: React.FC<FriendRequestScreenProps> = ({
display: "grid",
flexShrink: 0,
gridTemplateColumns: "44px 1fr 44px",
- height: 56,
+ height: 68,
px: 2,
}}
>
diff --git a/web/apps/space/src/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsx
index 471fc23818..66b6315d3e 100644
--- a/web/apps/space/src/screens/FriendsScreen.tsx
+++ b/web/apps/space/src/screens/FriendsScreen.tsx
@@ -136,6 +136,7 @@ const FriendIdentity: React.FC<FriendIdentityProps> = ({
type="button"
onClick={onOpen}
aria-label={`Open ${displayName}'s profile`}
+ aria-haspopup="dialog"
sx={{
alignItems: "center",
bgcolor: "transparent",
@@ -353,7 +354,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
alignItems: "center",
display: "grid",
gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ height: 68,
maxWidth: 390,
mx: "auto",
px: 2,
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 6c0b8d0212..be518ab41f 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -2298,7 +2298,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
"@media (min-width: 600px)": { maxWidth: 390 },
}}
>
- <SpaceHomeHeader />
+ <SpaceHomeHeader profile={profile} />
<Box
component="section"
id="space-main-content"
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsx
index 4d07c164f6..dc2e352307 100644
--- a/web/apps/space/src/screens/MessagesScreen.tsx
+++ b/web/apps/space/src/screens/MessagesScreen.tsx
@@ -22,6 +22,7 @@ import {
SpaceActivityAvatar as Avatar,
SpaceActivityIdentity,
} from "components/ActivityList";
+import { SpaceConversationPokeButton } from "components/ConversationPokeButton";
import { SpaceLiveStatus } from "components/LiveStatus";
import {
MessageQuickReactions,
@@ -38,6 +39,7 @@ import { SpaceShareInviteButton } from "components/ShareInviteButton";
import { SpaceSkipLink } from "components/SkipLink";
import { emojiName } from "data/emojis";
import log from "ente-base/log";
+import { isSpaceIOS } from "hooks/use-pwa-install-prompt";
import React from "react";
import { flushSync } from "react-dom";
import type { SetupProfile } from "screens/SetupProfileScreen";
@@ -90,7 +92,7 @@ const messageBubblePaddingX = "16px";
const messageBubblePaddingY = "14px";
const composerPadding = 14;
const composerPaddingLeft = 18;
-const postQuoteThumbnailSize = 200;
+const postQuoteWidth = 264;
const threadBottomThresholdPx = 96;
const messageGroupTimeThresholdMs = 10 * 60 * 1000;
const messageTimeSeparatorThresholdMs = 60 * 60 * 1000;
@@ -118,6 +120,7 @@ interface MessagesScreenProps {
onLoadActivityPost?: (
post: SpaceMessageActivityPost,
) => Promise<SpaceMessageActivityPost | undefined>;
+ onPokeFriend: (spaceId: string, requestID: string) => Promise<void>;
onReplyToMessage: (
spaceId: string,
messageId: string,
@@ -859,19 +862,10 @@ const MessageReplyPreview: React.FC<{
const PostQuotePreview: React.FC<{
activityPost?: SpaceMessageActivityPost;
- isOwn: boolean;
message: SpaceMessage;
- mb?: string;
onLoadActivityPost?: (post: SpaceMessageActivityPost) => void;
onOpenQuotePost: (quote: SpaceMessageQuote) => void;
-}> = ({
- activityPost,
- isOwn,
- message,
- mb,
- onLoadActivityPost,
- onOpenQuotePost,
-}) => {
+}> = ({ activityPost, message, onLoadActivityPost, onOpenQuotePost }) => {
const quote = message.quote;
const preview = activityPost ?? quote;
const isUnavailable = !quote || Boolean(preview?.isUnavailable);
@@ -918,38 +912,51 @@ const PostQuotePreview: React.FC<{
]);
return (
- <QuoteFrame isOwn={isOwn} mb={mb}>
+ <Box
+ component={canOpen || canRetry ? "button" : "div"}
+ type={canOpen || canRetry ? "button" : undefined}
+ aria-label={
+ canOpen
+ ? "Open quoted photo"
+ : canRetry
+ ? "Retry loading post"
+ : undefined
+ }
+ onClick={(event: React.MouseEvent) => {
+ event.stopPropagation();
+ if (canRetry && quote) onLoadActivityPost?.(quote);
+ else if (loadedQuote) onOpenQuotePost(loadedQuote);
+ }}
+ sx={{
+ appearance: "none",
+ bgcolor: spaceSurface,
+ border: 0,
+ borderRadius: "inherit",
+ borderBottomLeftRadius: 0,
+ borderBottomRightRadius: 0,
+ color: "inherit",
+ cursor: canOpen || canRetry ? "pointer" : "default",
+ display: "flex",
+ flexDirection: "column",
+ font: "inherit",
+ overflow: "hidden",
+ p: 0,
+ position: "relative",
+ textAlign: "left",
+ width: "100%",
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
<Box
- component={canOpen || canRetry ? "button" : "div"}
- type={canOpen || canRetry ? "button" : undefined}
- aria-label={
- canOpen
- ? "Open quoted photo"
- : canRetry
- ? "Retry loading post"
- : undefined
- }
- onClick={(event: React.MouseEvent) => {
- event.stopPropagation();
- if (canRetry && quote) onLoadActivityPost?.(quote);
- else if (loadedQuote) onOpenQuotePost(loadedQuote);
- }}
+ component="span"
sx={{
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "28px",
- color: "inherit",
- cursor: canOpen || canRetry ? "pointer" : "default",
- display: "inline-flex",
- font: "inherit",
- overflow: "hidden",
- p: 0,
+ aspectRatio: "1",
+ display: "block",
position: "relative",
- "&:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: 2,
- },
+ width: "100%",
}}
>
{imageUrl ? (
@@ -959,14 +966,17 @@ const PostQuotePreview: React.FC<{
src={imageUrl}
sx={{
display: "block",
- height: postQuoteThumbnailSize,
+ height: "100%",
+ inset: 0,
objectFit: "cover",
objectPosition: "center",
- width: postQuoteThumbnailSize,
+ position: "absolute",
+ width: "100%",
}}
/>
) : (
<Box
+ component="span"
role="img"
aria-label={
isLoading
@@ -987,12 +997,12 @@ const PostQuotePreview: React.FC<{
fontFamily: '"Inter Variable", Inter, sans-serif',
fontSize: 12,
fontWeight: 700,
- height: postQuoteThumbnailSize,
+ height: "100%",
justifyContent: "center",
lineHeight: "16px",
textAlign: "center",
textWrap: "balance",
- width: postQuoteThumbnailSize,
+ width: "100%",
px: "12px",
}}
>
@@ -1020,8 +1030,29 @@ const PostQuotePreview: React.FC<{
{canOpen && (
<SpacePostVideoBadge durationMs={loadedQuote?.durationMs} />
)}
+ <Box
+ component="span"
+ aria-hidden
+ sx={{
+ alignItems: "center",
+ backdropFilter: "blur(12px)",
+ bgcolor: alpha("#000000", 0.45),
+ borderRadius: "999px",
+ color: "#FFFFFF",
+ display: "inline-flex",
+ height: 32,
+ justifyContent: "center",
+ left: 12,
+ position: "absolute",
+ top: 12,
+ width: 32,
+ "& svg": { height: 12, width: 16 },
+ }}
+ >
+ <ReplyIcon />
+ </Box>
</Box>
- </QuoteFrame>
+ </Box>
);
};
@@ -1080,15 +1111,11 @@ const MessageBubble: React.FC<{
const isPostReply = !isUnavailable && message.kind == "post_reply";
const isSystemMessage = isFriendAdded;
const hasMessageReply = !isUnavailable && Boolean(message.replyMessageId);
- const actionLabel = isPostReply
+ const actionLabel = hasMessageReply
? isOwn
- ? "You replied to a post"
- : "Replied to your post"
- : hasMessageReply
- ? isOwn
- ? "You replied"
- : "Replied to you"
- : undefined;
+ ? "You replied"
+ : "Replied to you"
+ : undefined;
const hasBodyBubble = !isSystemMessage;
const hasActionsTrigger = canOpenActions && !isUnavailable;
const rowAlignItems = isFriendAdded
@@ -1360,16 +1387,6 @@ const MessageBubble: React.FC<{
profile={profile}
/>
)}
- {isPostReply && (
- <PostQuotePreview
- activityPost={activityPost}
- isOwn={isOwn}
- mb={hasBodyBubble ? "8px" : "0"}
- message={message}
- onLoadActivityPost={onLoadActivityPost}
- onOpenQuotePost={onOpenQuotePost}
- />
- )}
{hasBodyBubble && (
<Box sx={{ maxWidth: "100%", position: "relative" }}>
{canReply && !isUnavailable && !isPoke && (
@@ -1423,7 +1440,9 @@ const MessageBubble: React.FC<{
bgcolor: isOwn
? outgoingBubble
: incomingBubble,
- borderRadius: bubbleBorderRadius,
+ borderRadius: isPostReply
+ ? "24px"
+ : bubbleBorderRadius,
"&:focus-visible": {
outline: `2px solid ${green}`,
outlineOffset: 2,
@@ -1440,8 +1459,8 @@ const MessageBubble: React.FC<{
ml: 0,
overflow: "visible",
position: "relative",
- px: messageBubblePaddingX,
- py: messageBubblePaddingY,
+ px: isPostReply ? 0 : messageBubblePaddingX,
+ py: isPostReply ? 0 : messageBubblePaddingY,
textAlign: "left",
touchAction: "pan-y",
transform: `translateX(${swipeOffset}px)`,
@@ -1455,7 +1474,9 @@ const MessageBubble: React.FC<{
userSelect: "none",
WebkitTouchCallout: "none",
WebkitUserSelect: "none",
- width: "fit-content",
+ width: isPostReply
+ ? postQuoteWidth
+ : "fit-content",
"& *": {
userSelect: "none",
WebkitTouchCallout: "none",
@@ -1463,6 +1484,14 @@ const MessageBubble: React.FC<{
},
}}
>
+ {isPostReply && (
+ <PostQuotePreview
+ activityPost={activityPost}
+ message={message}
+ onLoadActivityPost={onLoadActivityPost}
+ onOpenQuotePost={onOpenQuotePost}
+ />
+ )}
<Box
sx={{
color: isOwn
@@ -1478,6 +1507,12 @@ const MessageBubble: React.FC<{
fontWeight: 600,
lineHeight: "21px",
overflowWrap: "anywhere",
+ px: isPostReply
+ ? messageBubblePaddingX
+ : undefined,
+ py: isPostReply
+ ? messageBubblePaddingY
+ : undefined,
whiteSpace: "pre-wrap",
}}
>
@@ -1554,6 +1589,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
onOpenQuotePost,
onOpenThread,
onLoadActivityPost,
+ onPokeFriend,
onReplyToMessage,
onSendMessage,
onSetMessageReaction,
@@ -1825,7 +1861,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
closeMessageActions();
setReplyingTo(messageByID.get(message.id) ?? message);
});
- composerRef.current?.focus();
+ composerRef.current?.focus({ preventScroll: true });
};
const reactToMessage = (message: SpaceMessage, emoji: string) => {
@@ -1923,6 +1959,10 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
};
const handleComposerFocus = () => {
+ if (composerBlurResetTimeoutRef.current != undefined) {
+ window.clearTimeout(composerBlurResetTimeoutRef.current);
+ composerBlurResetTimeoutRef.current = undefined;
+ }
const scroller = threadScrollRef.current;
if (scroller && !isThreadNearBottom(scroller)) return;
stickToThreadBottomRef.current = true;
@@ -2087,12 +2127,18 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
height: isThreadOpen
? "var(--space-page-height, 100dvh)"
: undefined,
+ left: isThreadOpen ? 0 : undefined,
minHeight: isThreadOpen
? 0
: "var(--space-page-height, 100svh)",
overflow: isThreadOpen ? "hidden" : undefined,
overflowX: "hidden",
placeItems: { xs: "stretch", sm: "start center" },
+ position: isThreadOpen ? "fixed" : undefined,
+ right: isThreadOpen ? 0 : undefined,
+ top: isThreadOpen
+ ? "var(--space-viewport-offset-top, 0px)"
+ : undefined,
}}
>
<SpaceSkipLink />
@@ -2103,8 +2149,8 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
display: isThreadOpen ? "grid" : undefined,
gridTemplateRows: isThreadOpen
? isThreadReadOnly
- ? "56px minmax(0, 1fr)"
- : "56px minmax(0, 1fr) auto"
+ ? "68px minmax(0, 1fr)"
+ : "68px minmax(0, 1fr) auto"
: undefined,
height: isThreadOpen ? "100%" : undefined,
minHeight: isThreadOpen
@@ -2122,8 +2168,10 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
sx={{
alignItems: "center",
display: "grid",
- gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ gridTemplateColumns: isThreadOpen
+ ? `${spaceTouchTargetSize}px minmax(0, 1fr) 76px`
+ : `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
+ height: 68,
px: 2,
width: "100%",
}}
@@ -2162,8 +2210,9 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
<Box
component="h1"
sx={{
- justifySelf: "center",
+ justifySelf: "start",
m: 0,
+ maxWidth: "100%",
minWidth: 0,
overflow: "hidden",
textOverflow: "ellipsis",
@@ -2201,10 +2250,12 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
'"Inter Variable", Inter, sans-serif',
fontSize: 18,
fontWeight: 700,
- justifyContent: "center",
+ gap: "10px",
+ justifyContent: "flex-start",
lineHeight: "24px",
m: 0,
maxWidth: "100%",
+ minHeight: spaceTouchTargetSize,
minWidth: 0,
overflow: "hidden",
p: 0,
@@ -2216,6 +2267,11 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
},
}}
>
+ <Avatar
+ avatarUrl={selectedFriend.avatarUrl}
+ loading={isThreadRecipientLoading}
+ size={36}
+ />
<Box
component="span"
sx={{
@@ -2249,7 +2305,18 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
Messages
</Box>
)}
- <Box aria-hidden />
+ {isThreadOpen && selectedThreadID ? (
+ <SpaceConversationPokeButton
+ key={selectedThreadID}
+ disabled={!canInteract}
+ friendName={selectedName}
+ onPokeFriend={(requestID) =>
+ onPokeFriend(selectedThreadID, requestID)
+ }
+ />
+ ) : (
+ <Box aria-hidden />
+ )}
</Box>
{isThreadOpen && selectedFriend ? (
@@ -2634,6 +2701,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
display: "grid",
gap: "8px",
p: "10px 14px",
+ pb: "max(10px, calc(env(safe-area-inset-bottom) - var(--space-keyboard-inset, 0px)))",
width: "100%",
}}
>
@@ -2780,6 +2848,18 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
}}
onBlur={handleComposerBlur}
onFocus={handleComposerFocus}
+ onMouseDown={(event) => {
+ if (
+ !isSpaceIOS() ||
+ document.activeElement ==
+ event.currentTarget
+ )
+ return;
+ event.preventDefault();
+ event.currentTarget.focus({
+ preventScroll: true,
+ });
+ }}
placeholder="Message..."
disabled={isThreadRecipientLoading}
rows={1}
diff --git a/web/apps/space/src/screens/ProfileImageViewerScreen.tsx b/web/apps/space/src/screens/ProfileImageViewerScreen.tsx
index 87ec797281..6f1f898d76 100644
--- a/web/apps/space/src/screens/ProfileImageViewerScreen.tsx
+++ b/web/apps/space/src/screens/ProfileImageViewerScreen.tsx
@@ -218,7 +218,7 @@ export const ProfileImageViewerScreen: React.FC<
bgcolor: "transparent",
boxSizing: "border-box",
display: "grid",
- gridTemplateRows: "56px minmax(0, 1fr) auto",
+ gridTemplateRows: "68px minmax(0, 1fr) auto",
minHeight: "var(--space-page-height, 100svh)",
mx: "auto",
width: "100%",
@@ -243,7 +243,7 @@ export const ProfileImageViewerScreen: React.FC<
alignItems: "center",
display: "grid",
gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ height: 68,
px: 2,
width: "100%",
}}
diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsx
index 80c5993c4e..70c3f90439 100644
--- a/web/apps/space/src/screens/ProfileScreen.tsx
+++ b/web/apps/space/src/screens/ProfileScreen.tsx
@@ -3,6 +3,7 @@ import {
ArrowLeft02Icon,
BubbleChatIcon,
HandPointingRightIcon,
+ Menu01Icon,
Tick02Icon,
UserRemove01Icon,
} from "@hugeicons/core-free-icons";
@@ -63,11 +64,8 @@ const profileCoverBackground = spaceSurface;
const profileCoverTopShadow =
"linear-gradient(180deg, rgba(0, 0, 0, 0.26) 0%, rgba(0, 0, 0, 0.18) 36%, rgba(0, 0, 0, 0.08) 72%, rgba(0, 0, 0, 0) 100%)";
const profileCoverSkeletonBackground = spaceSurface;
-const profileHeaderHeight = 56;
const profileAvatarTopOffset = 54;
const profileAvatarSize = 132;
-const profileCoverHeight =
- profileHeaderHeight + profileAvatarTopOffset + profileAvatarSize / 2;
const photoPlaceholderBackground = spaceSurface;
const profileCoverRadius = "24px";
const profilePostLoadRootMargin = "800px 0px";
@@ -189,7 +187,9 @@ const PublicProfileActionButton: React.FC<PublicProfileActionButtonProps> = ({
</Box>
);
-const ProfilePostLoadingIndicator: React.FC = () => (
+const ProfilePostLoadingIndicator: React.FC<{ coverHeight: number }> = ({
+ coverHeight,
+}) => (
<Box
sx={{
alignItems: "center",
@@ -199,7 +199,7 @@ const ProfilePostLoadingIndicator: React.FC = () => (
justifyContent: "center",
pointerEvents: "none",
position: "absolute",
- top: `${profileCoverHeight}px`,
+ top: `var(--space-profile-post-loading-top, ${coverHeight}px)`,
width: "100%",
}}
>
@@ -208,6 +208,7 @@ const ProfilePostLoadingIndicator: React.FC = () => (
);
interface ProfileScreenProps {
+ headerRef?: React.Ref<HTMLDivElement>;
friendsCount?: number;
headerVariant?: "friend" | "owner" | "public" | "public-anonymous";
isAddingFriend?: boolean;
@@ -215,6 +216,7 @@ interface ProfileScreenProps {
isCoverLoading?: boolean;
isNameLoading?: boolean;
isPostsLoading?: boolean;
+ isPreview?: boolean;
isPostPhotoOpening?: boolean;
isStatsLoading?: boolean;
showPostLoadingIndicator?: boolean;
@@ -227,6 +229,7 @@ interface ProfileScreenProps {
onOpenFriends?: () => void;
onOpenProfileCover?: () => void;
onOpenProfilePhoto?: () => void;
+ onOpenSettings?: () => void;
onLoadPostImage?: (asset: SpacePostAsset) => Promise<string>;
onMessageFriend?: () => void;
onPokeFriend?: (requestID: string) => Promise<void>;
@@ -248,12 +251,14 @@ interface ProfileScreenProps {
}
export const ProfileScreen: React.FC<ProfileScreenProps> = ({
+ headerRef,
friendsCount = 0,
headerVariant = "owner",
isAddingFriend = false,
isCoverLoading = false,
isNameLoading = false,
isPostsLoading = false,
+ isPreview = false,
isPostPhotoOpening = false,
isStatsLoading = false,
onBack,
@@ -265,6 +270,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
onOpenFriends,
onOpenProfileCover,
onOpenProfilePhoto,
+ onOpenSettings,
onLoadPostImage,
onMessageFriend,
onPokeFriend,
@@ -318,6 +324,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
const isAnonymousPublicProfile = headerVariant == "public-anonymous";
const isPublicProfile =
headerVariant == "public" || isAnonymousPublicProfile;
+ const profileHeaderHeight = isAnonymousPublicProfile ? 56 : 68;
+ const profileCoverHeight =
+ profileHeaderHeight + profileAvatarTopOffset + profileAvatarSize / 2;
const isUnfriendActionRunning = unfriendActionPhase != null;
const canManageFriend =
isFriendProfile &&
@@ -643,6 +652,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
return (
<Box
component="header"
+ inert={isPreview}
sx={{
alignItems: "center",
color: coverForeground,
@@ -655,12 +665,17 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
? "space-between"
: undefined,
mx: "auto",
+ opacity: isPreview
+ ? "clamp(0, calc((var(--space-friend-profile-reveal, 0) - 0.7) * 5), 1)"
+ : 1,
position: "relative",
px: isPublicProfile ? 1 : 2,
py: 0,
width: "100%",
zIndex: 3,
- "@media (min-width: 600px)": { maxWidth: 390 },
+ "@media (min-width: 600px)": {
+ maxWidth: isPreview ? "none" : 390,
+ },
}}
>
{isPublicProfile ? (
@@ -754,7 +769,43 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
>
{firstName}
</Box>
- <Box aria-hidden sx={{ width: spaceTouchTargetSize }} />
+ {isOwnerProfile && onOpenSettings ? (
+ <Box
+ component="button"
+ type="button"
+ aria-label="Settings"
+ onClick={onOpenSettings}
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ color: "inherit",
+ cursor: "pointer",
+ display: "flex",
+ height: spaceTouchTargetSize,
+ justifyContent: "flex-end",
+ p: 0,
+ width: spaceTouchTargetSize,
+ "&:focus-visible": {
+ borderRadius: "50%",
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={Menu01Icon}
+ size={23}
+ strokeWidth={1.8}
+ absoluteStrokeWidth
+ />
+ </Box>
+ ) : (
+ <Box
+ aria-hidden
+ sx={{ width: spaceTouchTargetSize }}
+ />
+ )}
</>
)}
</Box>
@@ -774,7 +825,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
position: "relative",
}}
>
- {!isPublicProfile && <SpaceSkipLink />}
+ {!isPublicProfile && !isPreview && <SpaceSkipLink />}
<Box
sx={{
bgcolor: "transparent",
@@ -786,7 +837,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
overflow: "hidden",
position: "relative",
width: "100%",
- "@media (min-width: 600px)": { maxWidth: 390 },
+ "@media (min-width: 600px)": {
+ maxWidth: isPreview ? "none" : 390,
+ },
}}
>
{isOwnerProfile && onPostPhotoSelect && (
@@ -881,8 +934,13 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
)}
{renderHeader()}
<Box
+ ref={headerRef}
component={isPublicProfile ? "div" : "section"}
- id={isPublicProfile ? undefined : "space-main-content"}
+ id={
+ isPublicProfile || isPreview
+ ? undefined
+ : "space-main-content"
+ }
aria-label={
isPublicProfile ? undefined : `${displayName}'s profile`
}
@@ -1331,10 +1389,14 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
</Box>
<Box
component="section"
+ inert={isPreview}
sx={{
alignItems: "stretch",
boxSizing: "border-box",
display: "flex",
+ opacity: isPreview
+ ? "var(--space-friend-profile-reveal, 0)"
+ : 1,
flex: hasProfilePosts ? "0 0 auto" : "1 1 0",
flexDirection: "column",
minHeight: 0,
@@ -1365,7 +1427,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
/>
</Box>
) : shouldShowPostLoadingIndicator ? (
- <ProfilePostLoadingIndicator />
+ <ProfilePostLoadingIndicator
+ coverHeight={profileCoverHeight}
+ />
) : isPostsLoading ? null : (
<Box
sx={{
@@ -1446,6 +1510,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
<SpaceFileViewer
ref={viewerRef}
closeOnSwipePastEnd
+ headerHeight={profileHeaderHeight}
photo={selectedPost.photo}
photos={profileViewerPhotos}
photoIndex={selectedPhotoIndex}
diff --git a/web/apps/space/src/screens/SettingsScreen.tsx b/web/apps/space/src/screens/SettingsScreen.tsx
index 5102c02178..408989cf1d 100644
--- a/web/apps/space/src/screens/SettingsScreen.tsx
+++ b/web/apps/space/src/screens/SettingsScreen.tsx
@@ -364,7 +364,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
alignItems: "center",
display: "grid",
gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ height: 68,
px: 2,
width: "100%",
}}
@@ -586,7 +586,7 @@ export const ChangeNameSettingsScreen: React.FC<
alignItems: "center",
display: "grid",
gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
- height: 56,
+ height: 68,
px: 2,
width: "100%",
}}
diff --git a/web/apps/space/src/styles/globals.css b/web/apps/space/src/styles/globals.css
index c3e13860c4..59e88efc8e 100644
--- a/web/apps/space/src/styles/globals.css
+++ b/web/apps/space/src/styles/globals.css
@@ -9,7 +9,7 @@
.space-app-layout {
--space-bottom-nav-padding: env(safe-area-inset-bottom);
- --space-bottom-nav-height: calc(60px + var(--space-bottom-nav-padding));
+ --space-bottom-nav-height: calc(72px + var(--space-bottom-nav-padding));
--space-page-height: calc(
var(--space-viewport-height, 100svh) - var(--space-bottom-nav-height)
);
@@ -17,6 +17,10 @@
padding-bottom: var(--space-bottom-nav-height);
}
+.space-app-layout[data-space-conversation] {
+ --space-bottom-nav-height: 0px;
+}
+
.space-unread-indicator {
z-index: 1;
}
@@ -47,16 +51,29 @@
}
}
-::view-transition-group(space-bottom-nav) {
+html[data-space-route-motion="fade-with-navigation"]
+ [data-space-bottom-nav-pill] {
+ view-transition-name: none;
+}
+
+::view-transition-group(space-bottom-nav-space),
+::view-transition-group(space-bottom-nav-messages),
+::view-transition-group(space-bottom-nav-post) {
z-index: 1;
animation: none;
+ border-radius: 999px;
+ overflow: clip;
}
-::view-transition-old(space-bottom-nav) {
+::view-transition-old(space-bottom-nav-space),
+::view-transition-old(space-bottom-nav-messages),
+::view-transition-old(space-bottom-nav-post) {
display: none;
}
-::view-transition-new(space-bottom-nav) {
+::view-transition-new(space-bottom-nav-space),
+::view-transition-new(space-bottom-nav-messages),
+::view-transition-new(space-bottom-nav-post) {
animation: none;
}
diff --git a/web/apps/space/src/utils/friend-profile-sheet.ts b/web/apps/space/src/utils/friend-profile-sheet.ts
new file mode 100644
index 0000000000..650165bea7
--- /dev/null
+++ b/web/apps/space/src/utils/friend-profile-sheet.ts
@@ -0,0 +1,27 @@
+export const stepFriendSheetSpring = (
+ position: number,
+ velocity: number,
+ target: number,
+ elapsedMs: number,
+) => {
+ const time = elapsedMs / 1000;
+ const displacement = position - target;
+ const coefficient = velocity + 24 * displacement;
+ const decay = Math.exp(-24 * time);
+ return {
+ position: target + (displacement + coefficient * time) * decay,
+ velocity: (velocity - 24 * coefficient * time) * decay,
+ };
+};
+
+export const friendSheetSnap = (
+ position: number,
+ velocity: number,
+ collapsed: number,
+ height: number,
+) => {
+ const projected = position + velocity * 0.18;
+ if (projected < collapsed * 0.65) return "expanded";
+ if (projected > collapsed + (height - collapsed) * 0.35) return "closed";
+ return "collapsed";
+};
diff --git a/web/apps/space/src/utils/navigation.ts b/web/apps/space/src/utils/navigation.ts
index 30a42f605b..04a1e161c1 100644
--- a/web/apps/space/src/utils/navigation.ts
+++ b/web/apps/space/src/utils/navigation.ts
@@ -4,11 +4,7 @@ export const spaceUnreadStatusChangedEvent = "space-unread-status-changed";
export const spaceNavigationDestination = (pathname: string) => {
if (pathname == spaceRoutes.friendPage) return spaceRoutes.friends;
- for (const destination of [
- spaceRoutes.friends,
- spaceRoutes.messages,
- spaceRoutes.profile,
- ]) {
+ for (const destination of [spaceRoutes.friends, spaceRoutes.messages]) {
if (pathname == destination || pathname.startsWith(`${destination}/`))
return destination;
}
diff --git a/web/apps/space/src/utils/post-grid.ts b/web/apps/space/src/utils/post-grid.ts
new file mode 100644
index 0000000000..87051a5191
--- /dev/null
+++ b/web/apps/space/src/utils/post-grid.ts
@@ -0,0 +1,141 @@
+import { minimumPostPhotoFrameAspectRatio } from "../styles/tiles";
+
+const gap = 8;
+
+interface PostGridPhoto {
+ frameAspectRatio?: number;
+ width?: number;
+ height?: number;
+}
+
+interface TileRect {
+ left: number;
+ top: number;
+ width: number;
+ height: number;
+}
+
+interface PhotoGroup {
+ kind: "single" | "row" | "split";
+ side?: "left" | "right";
+ height: number;
+ tiles: TileRect[];
+}
+
+const photoGroups = (ratios: number[], width: number): PhotoGroup[] => {
+ const [first, second, third] = ratios;
+ const groups: PhotoGroup[] = [
+ {
+ kind: "single",
+ height: width / first!,
+ tiles: [{ left: 0, top: 0, width, height: width / first! }],
+ },
+ ];
+ if (second != undefined) {
+ const height = (width - gap) / (first! + second);
+ const firstWidth = height * first!;
+ groups.push({
+ kind: "row",
+ height,
+ tiles: [
+ { left: 0, top: 0, width: firstWidth, height },
+ {
+ left: firstWidth + gap,
+ top: 0,
+ width: width - firstWidth - gap,
+ height,
+ },
+ ],
+ });
+ }
+ if (second != undefined && third != undefined) {
+ for (const side of ["left", "right"] as const) {
+ const largeRatio = side == "left" ? first! : second;
+ const topRatio = side == "left" ? second : first!;
+ const stackRatio = 1 / (1 / topRatio + 1 / third);
+ const height =
+ (width - gap + gap * stackRatio) / (largeRatio + stackRatio);
+ const largeWidth = height * largeRatio;
+ const stackWidth = width - gap - largeWidth;
+ const stackLeft = side == "left" ? largeWidth + gap : 0;
+ const large = {
+ left: side == "left" ? 0 : stackWidth + gap,
+ top: 0,
+ width: largeWidth,
+ height,
+ };
+ const top = {
+ left: stackLeft,
+ top: 0,
+ width: stackWidth,
+ height: stackWidth / topRatio,
+ };
+ groups.push({
+ kind: "split",
+ side,
+ height,
+ tiles: [
+ ...(side == "left" ? [large, top] : [top, large]),
+ {
+ left: stackLeft,
+ top: top.height + gap,
+ width: stackWidth,
+ height: stackWidth / third,
+ },
+ ],
+ });
+ }
+ }
+ return groups;
+};
+
+export const layoutPostGrid = (
+ photos: PostGridPhoto[],
+ width: number,
+ fullWidth = false,
+): { tiles: TileRect[]; height: number } => {
+ const tiles: TileRect[] = [];
+ if (width <= gap) return { tiles, height: 0 };
+
+ const ratios = photos.map((photo) =>
+ Math.max(
+ minimumPostPhotoFrameAspectRatio,
+ photo.frameAspectRatio ??
+ (photo.width && photo.height ? photo.width / photo.height : 1),
+ ),
+ );
+ let top = 0;
+ let previousKind: PhotoGroup["kind"] | undefined;
+ let previousSide: PhotoGroup["side"];
+ while (tiles.length < photos.length) {
+ const candidates = photoGroups(
+ ratios.slice(tiles.length, tiles.length + (fullWidth ? 1 : 3)),
+ width,
+ );
+ const score = (group: PhotoGroup) => {
+ if (
+ group.tiles.length > 1 &&
+ group.tiles.some(
+ (tile) =>
+ tile.width < width * 0.28 || tile.height < width * 0.2,
+ )
+ )
+ return Infinity;
+ return (
+ Math.abs(group.height / width - 0.65) +
+ (group.kind == previousKind ? 0.35 : 0) +
+ (group.side && group.side == previousSide ? 0.04 : 0)
+ );
+ };
+ const group = candidates.reduce((best, candidate) =>
+ score(candidate) < score(best) ? candidate : best,
+ );
+ tiles.push(
+ ...group.tiles.map((tile) => ({ ...tile, top: tile.top + top })),
+ );
+ top += group.height + gap;
+ previousKind = group.kind;
+ if (group.side) previousSide = group.side;
+ }
+ return { tiles, height: tiles.length ? top - gap : 0 };
+};
diff --git a/web/apps/space/src/utils/route-transitions.tsx b/web/apps/space/src/utils/route-transitions.tsx
index d8ee5db2b4..c45f06151c 100644
--- a/web/apps/space/src/utils/route-transitions.tsx
+++ b/web/apps/space/src/utils/route-transitions.tsx
@@ -1,7 +1,7 @@
import log from "ente-base/log";
import { useRouter, type NextRouter } from "next/router";
import React from "react";
-import { spaceBackFallback } from "utils/routes";
+import { spaceBackFallback, spaceRoutes } from "utils/routes";
type SpaceRouteURL = Parameters<NextRouter["push"]>[0];
type SpaceRouteAs = Parameters<NextRouter["push"]>[1];
@@ -101,8 +101,14 @@ const initializeRouteHistory = (router: NextRouter) => {
const prefersReducedMotion = () =>
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
-const startSpaceRouteTransition = async <T,>(updateRoute: () => Promise<T>) => {
+const startSpaceRouteTransition = async <T,>(
+ fromPath: string,
+ destination: SpaceRouteURL,
+ updateRoute: () => Promise<T>,
+ skipTransition = false,
+) => {
if (
+ skipTransition ||
typeof document == "undefined" ||
typeof document.startViewTransition != "function" ||
prefersReducedMotion()
@@ -114,7 +120,15 @@ const startSpaceRouteTransition = async <T,>(updateRoute: () => Promise<T>) => {
const root = document.documentElement;
let result: T;
- root.dataset.spaceRouteMotion = "fade";
+ const toPath =
+ typeof destination == "string"
+ ? destination
+ : (destination.pathname ?? "");
+ root.dataset.spaceRouteMotion = [fromPath, toPath].some((path) =>
+ path.startsWith(`${spaceRoutes.messages}/`),
+ )
+ ? "fade-with-navigation"
+ : "fade";
const transition = document.startViewTransition(async () => {
result = await updateRoute();
@@ -144,8 +158,11 @@ const pushSpaceRoute = async (
options?: SpaceRouteOptions,
) => {
initializeRouteHistory(router);
- const didNavigate = await startSpaceRouteTransition(() =>
- router.push(url, as, options),
+ const didNavigate = await startSpaceRouteTransition(
+ router.asPath,
+ as ?? url,
+ () => router.push(url, as, options),
+ options?.shallow,
);
if (didNavigate) recordRoute("push");
return didNavigate;
@@ -257,8 +274,11 @@ export const useSpaceRouteTransitionPopState = () => {
)
return false;
- void startSpaceRouteTransition(() =>
- router.replace(state.url, state.as, state.options),
+ void startSpaceRouteTransition(
+ asPathRef.current,
+ state.as,
+ () => router.replace(state.url, state.as, state.options),
+ state.url.split("?")[0] == router.pathname,
)
.then((didNavigate) => {
if (didNavigate) {
diff --git a/web/apps/space/src/utils/routes.ts b/web/apps/space/src/utils/routes.ts
index 930902b35a..be4af1abd0 100644
--- a/web/apps/space/src/utils/routes.ts
+++ b/web/apps/space/src/utils/routes.ts
@@ -76,7 +76,7 @@ export const spaceBackFallback = (asPath: string, page = asPath) => {
[spaceRoutes.messages]: spaceRoutes.home,
[spaceRoutes.notifications]: spaceRoutes.home,
[spaceRoutes.profile]: spaceRoutes.home,
- [spaceRoutes.settings]: spaceRoutes.home,
+ [spaceRoutes.settings]: spaceRoutes.profile,
[spaceRoutes.settingsProfileName]: spaceRoutes.settings,
"/app/post": spaceRoutes.home,
} as Record<string, string | undefined>
diff --git a/web/apps/space/tests/friend-profile-sheet.test.ts b/web/apps/space/tests/friend-profile-sheet.test.ts
new file mode 100644
index 0000000000..0a062320c9
--- /dev/null
+++ b/web/apps/space/tests/friend-profile-sheet.test.ts
@@ -0,0 +1,54 @@
+import { describe, expect, it } from "vitest";
+import {
+ friendSheetSnap,
+ stepFriendSheetSpring,
+} from "../src/utils/friend-profile-sheet";
+
+describe("friend profile sheet motion", () => {
+ it("continues from the released position instead of jumping to a snap point", () => {
+ const next = stepFriendSheetSpring(260, -400, 0, 16);
+ expect(next.position).toBeLessThan(260);
+ expect(next.position).toBeGreaterThan(200);
+ });
+
+ it("uses elapsed time consistently across refresh rates", () => {
+ const step = stepFriendSheetSpring(400, -300, 0, 32);
+ const first = stepFriendSheetSpring(400, -300, 0, 16);
+ const second = stepFriendSheetSpring(
+ first.position,
+ first.velocity,
+ 0,
+ 16,
+ );
+ expect(second.position).toBeCloseTo(step.position, 8);
+ expect(second.velocity).toBeCloseTo(step.velocity, 8);
+ });
+
+ it("settles downward at the bottom of the viewport", () => {
+ let motion = { position: 400, velocity: 0 };
+ for (let frame = 0; frame < 60; frame++) {
+ const next = stepFriendSheetSpring(
+ motion.position,
+ motion.velocity,
+ 844,
+ 1000 / 60,
+ );
+ expect(next.position).toBeGreaterThanOrEqual(motion.position);
+ expect(next.position).toBeLessThanOrEqual(844);
+ motion = next;
+ }
+ expect(motion.position).toBeCloseTo(844, 2);
+ });
+
+ it.each([
+ [250, -900, "expanded"],
+ [460, 0, "collapsed"],
+ [540, 1200, "closed"],
+ [520, -1400, "expanded"],
+ ])(
+ "snaps position %s with velocity %s to %s",
+ (position, velocity, snap) => {
+ expect(friendSheetSnap(position, velocity, 460, 844)).toBe(snap);
+ },
+ );
+});
diff --git a/web/apps/space/tests/navigation.test.ts b/web/apps/space/tests/navigation.test.ts
index 7734f0a8da..b90521d12c 100644
--- a/web/apps/space/tests/navigation.test.ts
+++ b/web/apps/space/tests/navigation.test.ts
@@ -11,7 +11,7 @@ describe("navigation destinations", () => {
["/app/messages/[spaceId]", "/app/messages"],
["/app/friends", "/app/friends"],
["/profile-link", "/app/friends"],
- ["/app/profile/photo-edit", "/app/profile"],
+ ["/app/profile/photo-edit", "/app"],
["/login", undefined],
["/application", undefined],
])("keeps %s in its parent destination", (path, destination) => {
diff --git a/web/apps/space/tests/post-grid.test.ts b/web/apps/space/tests/post-grid.test.ts
new file mode 100644
index 0000000000..ced10daf29
--- /dev/null
+++ b/web/apps/space/tests/post-grid.test.ts
@@ -0,0 +1,148 @@
+import { describe, expect, it } from "vitest";
+import { layoutPostGrid } from "../src/utils/post-grid";
+
+const photosWithRatios = (ratios: number[]) =>
+ ratios.map((frameAspectRatio) => ({ frameAspectRatio }));
+
+describe("post grid mosaic", () => {
+ for (const width of [288, 304, 374, 414, 768]) {
+ for (const [name, ratios] of Object.entries({
+ portraits: [0.5, 0.75, 0.6, 0.8, 0.75, 0.9, 0.75],
+ landscapes: [1.5, 2, 1.8, 1.3, 2.5, 1.5, 1.6],
+ squares: Array<number>(12).fill(1),
+ mixed: [0.6, 1.5, 1.8, 1, 0.8, 3, 1.5, 0.75, 2, 1, 0.5],
+ })) {
+ it(`fits ${name} at ${width}px without overlap or extra cropping`, () => {
+ const { tiles, height } = layoutPostGrid(
+ photosWithRatios(ratios),
+ width,
+ );
+ expect(tiles).toHaveLength(ratios.length);
+ tiles.forEach((tile, index) => {
+ expect(tile.width).toBeGreaterThan(0);
+ expect(tile.height).toBeGreaterThan(0);
+ expect(tile.left).toBeGreaterThanOrEqual(0);
+ expect(tile.top).toBeGreaterThanOrEqual(0);
+ expect(tile.left + tile.width).toBeLessThanOrEqual(
+ width + 0.001,
+ );
+ expect(tile.top + tile.height).toBeLessThanOrEqual(
+ height + 0.001,
+ );
+ expect(tile.width / tile.height).toBeCloseTo(
+ Math.max(0.75, ratios[index]!),
+ );
+ for (const previous of tiles.slice(0, index)) {
+ expect(tile.top).toBeGreaterThanOrEqual(previous.top);
+ const horizontalGap = Math.max(
+ tile.left - previous.left - previous.width,
+ previous.left - tile.left - tile.width,
+ );
+ const verticalGap =
+ tile.top - previous.top - previous.height;
+ expect(
+ Math.max(horizontalGap, verticalGap),
+ ).toBeGreaterThanOrEqual(8 - 0.001);
+ }
+ });
+ expect(height).toBeCloseTo(
+ Math.max(...tiles.map((tile) => tile.top + tile.height)),
+ );
+ });
+ }
+ }
+
+ it("varies widths and alternates tall photos across the grid", () => {
+ const { tiles } = layoutPostGrid(
+ photosWithRatios(Array<number>(12).fill(1)),
+ 374,
+ );
+ expect(
+ new Set(tiles.map((tile) => Math.round(tile.width))).size,
+ ).toBeGreaterThan(2);
+ expect(tiles.some((tile) => tile.width > 220 && tile.left == 0)).toBe(
+ true,
+ );
+ expect(tiles.some((tile) => tile.width > 220 && tile.left > 0)).toBe(
+ true,
+ );
+ });
+
+ it("gives a wide panorama the full width", () => {
+ const { tiles } = layoutPostGrid(
+ photosWithRatios([3, 0.75, 1.5, 1.8]),
+ 374,
+ );
+ expect(tiles[0]!.width).toBe(374);
+ expect(tiles[0]!.height).toBeCloseTo(374 / 3);
+ });
+
+ it("mixes grouped and full-width landscape photos on narrow screens", () => {
+ const { tiles } = layoutPostGrid(
+ photosWithRatios([1.5, 2, 1.8, 1.3, 2.5, 1.5, 1.6]),
+ 288,
+ );
+ expect(tiles[0]!.width).toBe(288);
+ expect(tiles[1]!.width).toBeLessThan(288);
+ expect(tiles[1]!.top).toBe(tiles[2]!.top);
+ });
+
+ it("fits a row with unequal widths and aligned bottoms", () => {
+ const { tiles } = layoutPostGrid(photosWithRatios([1, 0.75]), 374);
+ expect(tiles[0]!.top).toBe(tiles[1]!.top);
+ expect(tiles[0]!.height).toBe(tiles[1]!.height);
+ expect(tiles[0]!.width).toBeGreaterThan(tiles[1]!.width);
+ expect(tiles[0]!.width + 8 + tiles[1]!.width).toBeCloseTo(374);
+ });
+
+ it("preserves the full-width layout for small collections", () => {
+ const { tiles } = layoutPostGrid(
+ photosWithRatios([0.5, 1.5, 1]),
+ 374,
+ true,
+ );
+ expect(tiles.every((tile) => tile.width == 374 && tile.left == 0)).toBe(
+ true,
+ );
+ expect(tiles[0]!.height).toBeCloseTo(374 / 0.75);
+ });
+
+ it("uses the frame ratio before dimensions and keeps unknown dimensions square", () => {
+ const { tiles } = layoutPostGrid(
+ [
+ { frameAspectRatio: 0.5, width: 200, height: 100 },
+ { width: 150, height: 100 },
+ {},
+ ],
+ 374,
+ );
+ expect(tiles.map((tile) => tile.width / tile.height)).toEqual([
+ expect.closeTo(0.75),
+ expect.closeTo(1.5),
+ expect.closeTo(1),
+ ]);
+ });
+
+ it("keeps completed groups stable when older posts are appended", () => {
+ const photos = photosWithRatios([
+ 0.75, 1.5, 1.8, 1, 0.8, 3, 1.5, 0.75, 2, 1,
+ ]);
+ const before = layoutPostGrid(photos, 374);
+ const after = layoutPostGrid(
+ [...photos, ...photosWithRatios([1.2, 0.75, 1.5])],
+ 374,
+ );
+ expect(after.tiles.slice(0, photos.length - 2)).toEqual(
+ before.tiles.slice(0, photos.length - 2),
+ );
+ expect(layoutPostGrid(photos, 374)).toEqual(before);
+ });
+
+ it("has no height before measurement or without photos", () => {
+ expect(layoutPostGrid(photosWithRatios([1, 0.75]), 0)).toEqual({
+ tiles: [],
+ height: 0,
+ });
+ expect(layoutPostGrid([], 374)).toEqual({ tiles: [], height: 0 });
+ });
+});
diff --git a/web/apps/space/tests/route-transitions.test.tsx b/web/apps/space/tests/route-transitions.test.tsx
index f91728b2c7..c1f97932e2 100644
--- a/web/apps/space/tests/route-transitions.test.tsx
+++ b/web/apps/space/tests/route-transitions.test.tsx
@@ -74,6 +74,7 @@ const setup = async (initialPath: string) => {
position++;
}
mocks.router.asPath = as;
+ mocks.router.pathname = url.split("?")[0]!;
render();
emit("routeChangeComplete", as);
return Promise.resolve(true);
@@ -83,6 +84,7 @@ const setup = async (initialPath: string) => {
popState(entries[position]!);
});
vi.stubGlobal("window", {
+ matchMedia: () => ({ matches: false }),
history: {
get state() {
return entries[position];
@@ -131,7 +133,80 @@ const setup = async (initialPath: string) => {
};
};
+describe("Space conversation transitions", () => {
+ it("leaves shallow friend sheet navigation to the sheet animation", async () => {
+ const app = await setup("/app/friends");
+ const startViewTransition = vi.fn();
+ vi.stubGlobal("document", { startViewTransition });
+ await app.router.push("/app/friends?friend=alex", undefined, {
+ shallow: true,
+ });
+ await app.router.replace(
+ "/app/friends?friend=alex&expanded=1",
+ "/alex",
+ { shallow: true },
+ );
+ await app.router.back("/app/friends");
+ expect(app.path).toBe("/app/friends");
+ expect(startViewTransition).not.toHaveBeenCalled();
+ });
+
+ it.each([
+ ["/app/messages", "/app/messages/alex", "fade-with-navigation"],
+ ["/app/messages/alex", "/app/messages", "fade-with-navigation"],
+ ["/app/friends", "/app/messages", "fade"],
+ ])("transitions from %s to %s using %s", async (from, to, motion) => {
+ const app = await setup(from);
+ const dataset: Record<string, string> = {};
+ const capturedMotions: (string | undefined)[] = [];
+ vi.stubGlobal("document", {
+ documentElement: { dataset },
+ startViewTransition: (update: () => Promise<unknown>) => {
+ capturedMotions.push(dataset.spaceRouteMotion);
+ const updateCallbackDone = Promise.resolve().then(update);
+ return {
+ ready: updateCallbackDone,
+ updateCallbackDone,
+ finished: updateCallbackDone,
+ };
+ },
+ });
+
+ await app.router.push(to);
+ await app.router.back(from);
+
+ expect(capturedMotions).toEqual([motion, motion]);
+ await vi.waitFor(() =>
+ expect(dataset.spaceRouteMotion).toBeUndefined(),
+ );
+ });
+});
+
describe("Space back navigation", () => {
+ it("expands a friend preview without adding another back step", async () => {
+ const app = await setup("/app/friends");
+ const options = { shallow: true, scroll: false };
+ await app.router.push("/app/friends?friend=alex", undefined, options);
+ const previewHistoryLength = app.length;
+ await app.router.replace(
+ "/app/friends?friend=alex&expanded=1",
+ "/alex",
+ options,
+ );
+
+ expect(mocks.router.replace).toHaveBeenLastCalledWith(
+ "/app/friends?friend=alex&expanded=1",
+ "/alex",
+ options,
+ );
+ expect(app.length).toBe(previewHistoryLength);
+ await app.router.push("/app/messages/alex");
+ await app.router.back("/app/messages");
+ expect(app.path).toBe("/alex");
+ await app.router.back("/app/friends");
+ expect(app.path).toBe("/app/friends");
+ });
+
it.each(["/app/friends", "/app/messages", "/anand"])(
"returns from a DM to its origin %s",
async (origin) => {