Skip to content

armgit / ente

Public Imported from GitHub
0

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

Revert "Redesign Space home with orbit layout"

Anand Baburajana1011d0507da
diff --git a/web/apps/space/src/components/HomeOrbit.tsx b/web/apps/space/src/components/HomeOrbit.tsx
deleted file mode 100644
index 404c02b553..0000000000
--- a/web/apps/space/src/components/HomeOrbit.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Box } from "@mui/material";
-import React from "react";
-import type { HomeOrbitPlacement } from "utils/home-orbit-layout";
-
-const green = "#08C225";
-
-interface SpaceHomeOrbitProps {
- children: React.ReactNode;
- hasNewPost: boolean;
- placement: HomeOrbitPlacement;
-}
-
-export const SpaceHomeOrbit = React.forwardRef<
- HTMLLIElement,
- SpaceHomeOrbitProps
->(function SpaceHomeOrbit({ children, hasNewPost, placement }, ref) {
- return (
- <Box
- ref={ref}
- component="li"
- sx={{
- height: placement.radius,
- left: "50%",
- listStyle: "none",
- position: "absolute",
- top: placement.top,
- transform: "translateX(-50%)",
- transition:
- "height 320ms ease, top 320ms ease, width 320ms ease",
- width: placement.radius * 2,
- "@media (prefers-reduced-motion: reduce)": {
- transition: "none",
- },
- }}
- >
- <Box
- component="svg"
- aria-hidden
- viewBox={`0 0 ${placement.radius * 2} ${placement.radius}`}
- sx={{
- height: "100%",
- inset: 0,
- overflow: "visible",
- pointerEvents: "none",
- position: "absolute",
- width: "100%",
- }}
- >
- <Box
- component="path"
- d={`M 0 ${placement.radius} A ${placement.radius} ${placement.radius} 0 0 1 ${placement.radius * 2} ${placement.radius}`}
- fill="none"
- stroke={hasNewPost ? green : "rgba(255, 255, 255, 0.16)"}
- strokeWidth={hasNewPost ? 2 : 1}
- vectorEffect="non-scaling-stroke"
- sx={{ transition: "stroke 180ms ease" }}
- />
- </Box>
- <Box
- sx={{
- height: placement.avatarSize,
- left: "50%",
- position: "absolute",
- top: 0,
- transform: "translate(-50%, -50%)",
- transition: "height 320ms ease, width 320ms ease",
- width: placement.avatarSize,
- zIndex: 1,
- "@media (prefers-reduced-motion: reduce)": {
- transition: "none",
- },
- }}
- >
- {children}
- </Box>
- </Box>
- );
-});
diff --git a/web/apps/space/src/pages/layout-demo.tsx b/web/apps/space/src/pages/layout-demo.tsx
deleted file mode 100644
index c27af601b0..0000000000
--- a/web/apps/space/src/pages/layout-demo.tsx
+++ /dev/null
@@ -1,263 +0,0 @@
-import { Add01Icon, MinusSignIcon } from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import { Box } from "@mui/material";
-import { SpaceHomeOrbit } from "components/HomeOrbit";
-import { SpacePageMeta } from "components/PageMeta";
-import React from "react";
-import { homeBackground } from "screens/HomeScreen";
-import { homeOrbitPlacements } from "utils/home-orbit-layout";
-
-const green = "#08C225";
-const headerChromeColor = "#202825";
-const headerHeight = 64;
-const postButtonSize = 64;
-const sampleColors = [
- "#D16B51",
- "#4F80C0",
- "#8A64B8",
- "#B79443",
- "#418C75",
- "#B85C8A",
-];
-
-interface DemoCanvasSize {
- height: number;
- width: number;
-}
-
-const HeaderControl: React.FC<{
- disabled?: boolean;
- icon: Parameters<typeof HugeiconsIcon>[0]["icon"];
- label: string;
- onClick: () => void;
-}> = ({ disabled = false, icon, label, onClick }) => (
- <Box
- component="button"
- type="button"
- aria-label={label}
- disabled={disabled}
- onClick={onClick}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: headerChromeColor,
- border: 0,
- borderRadius: "50%",
- color: "#FFF",
- cursor: disabled ? "default" : "pointer",
- display: "flex",
- height: 36,
- justifyContent: "center",
- opacity: disabled ? 0.35 : 1,
- p: 0,
- width: 36,
- "&:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: 2,
- },
- }}
- >
- <HugeiconsIcon icon={icon} size={22} strokeWidth={2.4} />
- </Box>
-);
-
-const Page = () => {
- const [count, setCount] = React.useState(1);
- const [canvasSize, setCanvasSize] = React.useState<DemoCanvasSize>({
- height: 0,
- width: 0,
- });
- const canvasRef = React.useRef<HTMLDivElement | null>(null);
-
- React.useEffect(() => {
- const canvas = canvasRef.current;
- if (!canvas) return;
-
- const updateSize = () => {
- const { height, width } = canvas.getBoundingClientRect();
- setCanvasSize({ height, width });
- };
- const observer = new ResizeObserver(updateSize);
- observer.observe(canvas);
- updateSize();
- return () => observer.disconnect();
- }, []);
-
- const placements = homeOrbitPlacements(
- count,
- canvasSize.width,
- canvasSize.height,
- );
- const avatarSize = placements[0]?.avatarSize;
-
- return (
- <>
- <SpacePageMeta themeColor={homeBackground} />
- <Box
- component="main"
- sx={{
- background:
- "radial-gradient(ellipse 120% 95% at 50% 58%, rgba(38, 78, 52, 0.16), transparent 72%), #0C1014",
- display: "grid",
- height: "100svh",
- overflow: "hidden",
- placeItems: { xs: "stretch", sm: "start center" },
- }}
- >
- <Box
- sx={{
- boxSizing: "border-box",
- height: "100svh",
- maxWidth: "100%",
- mx: "auto",
- overflow: "hidden",
- position: "relative",
- width: "100%",
- "@media (min-width: 600px)": { maxWidth: 390 },
- }}
- >
- <Box
- component="header"
- sx={{
- alignItems: "center",
- color: "#FFF",
- display: "grid",
- gridTemplateColumns: "44px minmax(0, 1fr) 44px",
- height: headerHeight,
- px: 2,
- position: "relative",
- zIndex: 2,
- }}
- >
- <HeaderControl
- disabled={count == 1}
- icon={MinusSignIcon}
- label="Remove friend"
- onClick={() =>
- setCount((current) => Math.max(1, current - 1))
- }
- />
- <Box
- sx={{
- bgcolor: headerChromeColor,
- borderRadius: "999px",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 650,
- justifySelf: "center",
- lineHeight: "20px",
- px: "14px",
- py: "8px",
- whiteSpace: "nowrap",
- }}
- >
- {`${count} ${count == 1 ? "friend" : "friends"}${avatarSize ? ` Β· ${Math.round(avatarSize)}px` : ""}`}
- </Box>
- <Box sx={{ justifySelf: "end" }}>
- <HeaderControl
- icon={Add01Icon}
- label="Add friend"
- onClick={() =>
- setCount((current) => current + 1)
- }
- />
- </Box>
- </Box>
- <Box
- sx={{
- height: "100%",
- inset: 0,
- position: "absolute",
- width: "100%",
- }}
- >
- <Box
- ref={canvasRef}
- sx={{
- height: "100%",
- position: "relative",
- width: "100%",
- }}
- >
- <Box
- component="ul"
- aria-label="Sample friends"
- sx={{
- height: "100%",
- m: 0,
- p: 0,
- position: "relative",
- width: "100%",
- }}
- >
- {placements.map((placement, index) => (
- <SpaceHomeOrbit
- key={index}
- hasNewPost={index % 3 == 1}
- placement={placement}
- >
- <Box
- role="img"
- aria-label={`Sample friend ${index + 1}`}
- sx={{
- alignItems: "center",
- bgcolor:
- sampleColors[
- index %
- sampleColors.length
- ],
- borderRadius: "50%",
- boxShadow:
- "0 3px 8px rgba(0, 0, 0, 0.2), 0 12px 24px rgba(0, 0, 0, 0.14)",
- color: "#FFF",
- display: "flex",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: Math.max(
- 8,
- placement.avatarSize * 0.3,
- ),
- fontWeight: 700,
- height: "100%",
- justifyContent: "center",
- width: "100%",
- }}
- >
- {index + 1}
- </Box>
- </SpaceHomeOrbit>
- ))}
- </Box>
- </Box>
- </Box>
- <Box
- aria-hidden
- sx={{
- alignItems: "center",
- bgcolor: green,
- borderRadius: "50%",
- bottom: "calc(env(safe-area-inset-bottom) + 20px)",
- boxShadow: "0 8px 24px rgba(0, 0, 0, 0.36)",
- color: "#FFF",
- display: "flex",
- height: postButtonSize,
- justifyContent: "center",
- position: "fixed",
- right: "max(20px, calc((100vw - 390px) / 2 + 20px))",
- width: postButtonSize,
- }}
- >
- <HugeiconsIcon
- icon={Add01Icon}
- size={34}
- strokeWidth={2.1}
- />
- </Box>
- </Box>
- </Box>
- </>
- );
-};
-
-export default Page;
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 6b11f34873..9ed30553d4 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -1,5 +1,4 @@
import {
- Add01Icon,
BubbleChatIcon,
MultiplicationSignIcon,
UserAdd02Icon,
@@ -14,7 +13,7 @@ import {
type SpaceViewerPhoto,
type SpaceViewerPostActionMode,
} from "components/FileViewer";
-import { SpaceHomeOrbit } from "components/HomeOrbit";
+import { SpacePostFloatingActionButton } from "components/PostFloatingActionButton";
import { SpacePWAInstallPrompt } from "components/PWAInstallPrompt";
import { SpaceLoadingSpinner } from "components/RouteFallback";
import type { FriendProfile } from "data/friends";
@@ -30,9 +29,10 @@ import {
import { spaceTouchTargetSize } from "styles/touch-targets";
import { firstNameFrom } from "utils/display";
import {
- homeOrbitPlacements,
- type HomeOrbitPlacement,
-} from "utils/home-orbit-layout";
+ homeCircleOrbitGap,
+ homeCirclePlacements,
+ type HomeCirclePlacement,
+} from "utils/home-circle-layout";
import { createLoadedLocalPostPhoto } from "utils/local-post-photo";
import {
canPreviewSpaceImageFile,
@@ -57,9 +57,7 @@ const headerHeight = 64;
const headerIconSize = 22;
const headerSideWidth = 36;
const homeHorizontalPadding = "16px";
-const orbitMediaLoadRootMargin = "640px 0px";
-const postButtonSize = 64;
-const postButtonIconSize = 34;
+const postCircleMediaLoadRootMargin = "640px 0px";
const waveAnimationDurationMs = 900;
const waveHoldDurationMs = 500;
const waveHoldMovementTolerancePx = 12;
@@ -108,7 +106,7 @@ interface DecodedImageState {
width?: number;
}
-interface OrbitCanvasSize {
+interface PostCircleCanvasSize {
height: number;
width: number;
}
@@ -180,6 +178,14 @@ const friendAvatarCacheKey = (friend: FriendProfile) =>
friend.avatarSize ?? "",
].join(":");
+const orbitPhaseFor = (value: string) => {
+ let hash = 0;
+ for (const character of value) {
+ hash = (hash * 31 + character.charCodeAt(0)) % 360;
+ }
+ return hash;
+};
+
const useDecodedImage = (
src?: string | null,
keepPreviousUntilReady = false,
@@ -243,7 +249,7 @@ const useDecodedImage = (
return { ready: !src, src };
};
-interface FriendOrbitProps {
+interface FriendPostCircleProps {
avatarUrl?: string | null;
friend: FriendProfile;
imageUrl?: string;
@@ -260,11 +266,11 @@ interface FriendOrbitProps {
) => void;
onPostUnavailable?: (friendSpaceID: string, postID: number) => void;
onWave?: () => Promise<void>;
- placement: HomeOrbitPlacement;
+ placement: HomeCirclePlacement;
posts: SpacePost[];
}
-const FriendOrbit: React.FC<FriendOrbitProps> = ({
+const FriendPostCircle: React.FC<FriendPostCircleProps> = ({
avatarUrl,
friend,
imageUrl,
@@ -315,8 +321,17 @@ const FriendOrbit: React.FC<FriendOrbitProps> = ({
: avatarUrl) ?? null;
const isPhotoReady = Boolean(displayImageUrl) && decodedPhoto.ready;
const canOpenPost = Boolean(post) && !postUnavailable && isPhotoReady;
- const isFriendDisabled =
+ const isCircleDisabled =
isLoading || Boolean(post && !postUnavailable && !isPhotoReady);
+ const orbitDotSize = Math.max(8, Math.min(12, placement.size * 0.05));
+ const orbitDurationSeconds = Math.max(
+ 30,
+ Math.min(42, placement.size * 0.13),
+ );
+ const orbitGap = homeCircleOrbitGap(placement.size);
+ const orbitAnimationDelaySeconds =
+ -(orbitPhaseFor(friend.spaceId ?? friend.id) / 360) *
+ orbitDurationSeconds;
React.useEffect(() => {
if (isLoading || !post || postUnavailable || shouldLoadMedia) return;
@@ -337,7 +352,7 @@ const FriendOrbit: React.FC<FriendOrbitProps> = ({
observer.disconnect();
}
},
- { rootMargin: orbitMediaLoadRootMargin },
+ { rootMargin: postCircleMediaLoadRootMargin },
);
observer.observe(element);
return () => observer.disconnect();
@@ -455,7 +470,7 @@ const FriendOrbit: React.FC<FriendOrbitProps> = ({
if (suppressClickRef.current) suppressPendingClick();
};
- const openFriend = () => {
+ const openCircle = () => {
if (suppressClickRef.current) {
suppressClickRef.current = false;
return;
@@ -484,141 +499,212 @@ const FriendOrbit: React.FC<FriendOrbitProps> = ({
};
return (
- <SpaceHomeOrbit
+ <Box
ref={rootRef}
- hasNewPost={hasNewPost}
- placement={placement}
+ component="li"
+ sx={{
+ aspectRatio: "1",
+ left: placement.x,
+ listStyle: "none",
+ minWidth: 0,
+ position: "absolute",
+ top: placement.y,
+ transition:
+ "left 420ms cubic-bezier(0.2, 0.8, 0.2, 1), top 420ms cubic-bezier(0.2, 0.8, 0.2, 1), width 420ms cubic-bezier(0.2, 0.8, 0.2, 1)",
+ width: placement.size,
+ "@media (prefers-reduced-motion: reduce)": {
+ transition: "none",
+ },
+ }}
>
<Box
- component="button"
- type="button"
- aria-label={
- isLoading
- ? `Loading ${firstName}`
- : post && !postUnavailable
- ? `View ${posts.length} new ${posts.length == 1 ? "post" : "posts"} from ${firstName}`
- : `View ${firstName}'s profile`
- }
- disabled={isFriendDisabled}
- onClick={openFriend}
- onContextMenu={(event) => {
- if (!hasNewPost) event.preventDefault();
- }}
- onPointerCancel={handlePointerEnd}
- onPointerDown={handlePointerDown}
- onPointerMove={handlePointerMove}
- onPointerUp={handlePointerEnd}
sx={{
- alignItems: "center",
- appearance: "none",
aspectRatio: "1",
- bgcolor: "#E5E7EA",
- border: 0,
- borderRadius: "50%",
- boxShadow: isHoldingWave
- ? "0 1px 3px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.14)"
- : "0 3px 8px rgba(0, 0, 0, 0.2), 0 12px 24px rgba(0, 0, 0, 0.14)",
- color: textBase,
- cursor: isFriendDisabled ? "default" : "pointer",
- display: "flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
height: "100%",
- justifyContent: "center",
- overflow: "hidden",
- p: 0,
position: "relative",
- transform: isHoldingWave ? "scale(0.98)" : "scale(1)",
- transition:
- "box-shadow 160ms ease-out, transform 160ms ease-out",
- userSelect: "none",
- WebkitTouchCallout: "none",
width: "100%",
- "@media (prefers-reduced-motion: reduce)": {
- transform: "none",
- transition: "box-shadow 160ms ease-out",
- },
+ zIndex: 1,
}}
>
- {isLoading || isAvatarPending ? (
- <Skeleton
- variant="circular"
+ {hasNewPost && (
+ <Box
+ aria-hidden
sx={{
- bgcolor: mediaSkeletonElementBackground,
- height: "100%",
- transform: "none",
- width: "100%",
+ "@keyframes spaceUnreadPostOrbit": {
+ from: { transform: "rotate(0deg)" },
+ to: { transform: "rotate(360deg)" },
+ },
+ animation: `spaceUnreadPostOrbit ${orbitDurationSeconds}s linear infinite`,
+ animationDelay: `${orbitAnimationDelaySeconds}s`,
+ border: "1px solid rgba(159, 181, 164, 0.3)",
+ borderRadius: "50%",
+ boxSizing: "border-box",
+ inset: `-${orbitGap}px`,
+ pointerEvents: "none",
+ position: "absolute",
+ zIndex: 3,
+ "@media (prefers-reduced-motion: reduce)": {
+ animation: "none",
+ transform: `rotate(${orbitPhaseFor(friend.spaceId ?? friend.id)}deg)`,
+ },
}}
- />
- ) : (
- <SpaceAvatarImage
- alt={`${displayName} profile photo`}
- src={displayAvatarUrl}
- />
+ >
+ {posts.map((item, index) => {
+ const angle =
+ -Math.PI / 2 +
+ (index * Math.PI * 2) / posts.length;
+ return (
+ <Box
+ key={item.postId}
+ component="span"
+ sx={{
+ bgcolor: green,
+ borderRadius: "50%",
+ boxShadow:
+ "0 2px 6px rgba(0, 0, 0, 0.5), 0 0 10px rgba(8, 194, 37, 0.8)",
+ height: orbitDotSize,
+ left: `${50 + Math.cos(angle) * 50}%`,
+ position: "absolute",
+ top: `${50 + Math.sin(angle) * 50}%`,
+ transform: "translate(-50%, -50%)",
+ width: orbitDotSize,
+ }}
+ />
+ );
+ })}
+ </Box>
)}
- </Box>
- {waveAnimationID > 0 && (
<Box
- key={waveAnimationID}
- component="span"
- aria-hidden
+ component="button"
+ type="button"
+ aria-label={
+ isLoading
+ ? `Loading ${firstName}`
+ : post && !postUnavailable
+ ? `View ${posts.length} new ${posts.length == 1 ? "post" : "posts"} from ${firstName}`
+ : `View ${firstName}'s profile`
+ }
+ disabled={isCircleDisabled}
+ onClick={openCircle}
+ onContextMenu={(event) => {
+ if (!hasNewPost) event.preventDefault();
+ }}
+ onPointerCancel={handlePointerEnd}
+ onPointerDown={handlePointerDown}
+ onPointerMove={handlePointerMove}
+ onPointerUp={handlePointerEnd}
sx={{
- "@keyframes spaceWaveSent": {
- "0%": {
- opacity: 0,
- transform:
- "translateY(8px) scale(0.7) rotate(0deg)",
- },
- "15%": {
- opacity: 1,
- transform:
- "translateY(0) scale(1) rotate(-18deg)",
- },
- "35%": {
- opacity: 1,
- transform:
- "translateY(-1px) scale(1) rotate(16deg)",
- },
- "55%": {
- opacity: 1,
- transform:
- "translateY(-3px) scale(1) rotate(-14deg)",
- },
- "75%": {
- opacity: 1,
- transform:
- "translateY(-6px) scale(1) rotate(12deg)",
- },
- "100%": {
- opacity: 0,
- transform:
- "translateY(-12px) scale(0.95) rotate(0deg)",
- },
- },
- "@keyframes spaceWaveSentReduced": {
- "0%, 80%": { opacity: 1 },
- "100%": { opacity: 0 },
- },
- animation: `spaceWaveSent ${waveAnimationDurationMs}ms ease-out both`,
- fontSize: Math.max(
- 24,
- Math.min(40, placement.avatarSize * 0.6),
- ),
- lineHeight: 1,
- bottom: "8%",
- pointerEvents: "none",
- position: "absolute",
- right: "8%",
- transformOrigin: "70% 75%",
- zIndex: 2,
+ alignItems: "center",
+ appearance: "none",
+ aspectRatio: "1",
+ bgcolor: "#E5E7EA",
+ border: 0,
+ borderRadius: "50%",
+ boxShadow: isHoldingWave
+ ? "0 1px 3px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.14)"
+ : "0 3px 8px rgba(0, 0, 0, 0.2), 0 12px 24px rgba(0, 0, 0, 0.14)",
+ color: textBase,
+ cursor: isCircleDisabled ? "default" : "pointer",
+ display: "flex",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ height: "100%",
+ justifyContent: "center",
+ overflow: "hidden",
+ p: 0,
+ position: "relative",
+ transform: isHoldingWave ? "scale(0.98)" : "scale(1)",
+ transition:
+ "box-shadow 160ms ease-out, transform 160ms ease-out",
+ userSelect: "none",
+ WebkitTouchCallout: "none",
+ width: "100%",
"@media (prefers-reduced-motion: reduce)": {
- animation: `spaceWaveSentReduced ${waveAnimationDurationMs}ms ease-out both`,
+ transform: "none",
+ transition: "box-shadow 160ms ease-out",
},
}}
>
- πŸ‘‹
+ {isLoading || isAvatarPending ? (
+ <Skeleton
+ variant="circular"
+ sx={{
+ bgcolor: mediaSkeletonElementBackground,
+ height: "100%",
+ transform: "none",
+ width: "100%",
+ }}
+ />
+ ) : (
+ <SpaceAvatarImage
+ alt={`${displayName} profile photo`}
+ src={displayAvatarUrl}
+ />
+ )}
</Box>
- )}
- </SpaceHomeOrbit>
+ {waveAnimationID > 0 && (
+ <Box
+ key={waveAnimationID}
+ component="span"
+ aria-hidden
+ sx={{
+ "@keyframes spaceWaveSent": {
+ "0%": {
+ opacity: 0,
+ transform:
+ "translateY(8px) scale(0.7) rotate(0deg)",
+ },
+ "15%": {
+ opacity: 1,
+ transform:
+ "translateY(0) scale(1) rotate(-18deg)",
+ },
+ "35%": {
+ opacity: 1,
+ transform:
+ "translateY(-1px) scale(1) rotate(16deg)",
+ },
+ "55%": {
+ opacity: 1,
+ transform:
+ "translateY(-3px) scale(1) rotate(-14deg)",
+ },
+ "75%": {
+ opacity: 1,
+ transform:
+ "translateY(-6px) scale(1) rotate(12deg)",
+ },
+ "100%": {
+ opacity: 0,
+ transform:
+ "translateY(-12px) scale(0.95) rotate(0deg)",
+ },
+ },
+ "@keyframes spaceWaveSentReduced": {
+ "0%, 80%": { opacity: 1 },
+ "100%": { opacity: 0 },
+ },
+ animation: `spaceWaveSent ${waveAnimationDurationMs}ms ease-out both`,
+ fontSize: Math.max(
+ 28,
+ Math.min(48, placement.size * 0.23),
+ ),
+ lineHeight: 1,
+ bottom: "8%",
+ pointerEvents: "none",
+ position: "absolute",
+ right: "8%",
+ transformOrigin: "70% 75%",
+ zIndex: 2,
+ "@media (prefers-reduced-motion: reduce)": {
+ animation: `spaceWaveSentReduced ${waveAnimationDurationMs}ms ease-out both`,
+ },
+ }}
+ >
+ πŸ‘‹
+ </Box>
+ )}
+ </Box>
+ </Box>
);
};
@@ -744,10 +830,8 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
}) => {
const [selectedViewer, setSelectedViewer] =
useState<SelectedHomeViewer | null>(null);
- const [orbitCanvasSize, setOrbitCanvasSize] = useState<OrbitCanvasSize>({
- height: 0,
- width: 0,
- });
+ const [postCircleCanvasSize, setPostCircleCanvasSize] =
+ useState<PostCircleCanvasSize>({ height: 0, width: 0 });
const [isDraftPostExitAnimating, setIsDraftPostExitAnimating] =
useState(false);
const [isDraftPostExiting, setIsDraftPostExiting] = useState(false);
@@ -760,7 +844,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
const [unavailablePostsByKey, setUnavailablePostsByKey] = useState<
Record<string, true>
>({});
- const orbitCanvasRef = React.useRef<HTMLDivElement | null>(null);
+ const postCircleCanvasRef = React.useRef<HTMLDivElement | null>(null);
const postInputRef = React.useRef<HTMLInputElement | null>(null);
const initialPostPhotoFileRef = React.useRef<File | null>(null);
const localPostObjectUrlsRef = React.useRef<Set<string>>(new Set());
@@ -800,22 +884,22 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
[friends],
);
React.useEffect(() => {
- const canvas = orbitCanvasRef.current;
+ const canvas = postCircleCanvasRef.current;
if (!canvas) return;
const updateSize = () => {
const { height, width } = canvas.getBoundingClientRect();
- setOrbitCanvasSize({ height, width });
+ setPostCircleCanvasSize({ height, width });
};
const observer = new ResizeObserver(updateSize);
observer.observe(canvas);
updateSize();
return () => observer.disconnect();
}, []);
- const orbitPlacements = homeOrbitPlacements(
+ const postCirclePlacements = homeCirclePlacements(
orderedFriends.length,
- orbitCanvasSize.width,
- orbitCanvasSize.height,
+ postCircleCanvasSize.width,
+ postCircleCanvasSize.height,
);
const isInstallPromptEnabled =
showInstallPrompt && !friendRequestSentToastName && !selectedViewer;
@@ -1083,8 +1167,8 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
selectedViewerPostIndex,
selectedViewerPosts,
]);
- const friendOrbitFor = (friend: FriendProfile, index: number) => {
- const placement = orbitPlacements[index]!;
+ const friendPostCircleFor = (friend: FriendProfile, index: number) => {
+ const placement = postCirclePlacements[index]!;
const posts = (
unseenPostsByFriendID.get(friend.spaceId ?? friend.id) ?? []
).filter(
@@ -1106,7 +1190,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
unavailablePostsByKey[postImageCacheKey(item)]),
);
return (
- <FriendOrbit
+ <FriendPostCircle
key={friend.id}
avatarUrl={avatarUrl}
friend={friend}
@@ -1279,8 +1363,8 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
"radial-gradient(ellipse 120% 95% at 50% 58%, rgba(38, 78, 52, 0.16), transparent 72%), #0C1014",
color: textBase,
display: "grid",
- height: "100svh",
- overflow: "hidden",
+ minHeight: "100svh",
+ overflowX: "hidden",
placeItems: { xs: "stretch", sm: "start center" },
position: "relative",
}}
@@ -1292,12 +1376,11 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
sx={{
bgcolor: "transparent",
boxSizing: "border-box",
- height: "100svh",
maxWidth: "100%",
+ minHeight: "100svh",
minWidth: 0,
mx: "auto",
- overflow: "hidden",
- position: "relative",
+ overflowX: "hidden",
width: "100%",
"@media (min-width: 600px)": { maxWidth: 390 },
}}
@@ -1515,16 +1598,22 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
</Box>
<Box
sx={{
- height: "100%",
- inset: 0,
- position: "absolute",
+ boxSizing: "border-box",
+ display: "flex",
+ flexDirection: "column",
+ height: `calc(100svh - ${headerHeight}px)`,
+ minWidth: 0,
+ pb: "calc(env(safe-area-inset-bottom) + 112px)",
+ px: homeHorizontalPadding,
+ pt: `calc(env(safe-area-inset-bottom) + 112px - ${headerHeight}px)`,
width: "100%",
}}
>
<Box
- ref={orbitCanvasRef}
+ ref={postCircleCanvasRef}
sx={{
- height: "100%",
+ flex: "1 1 auto",
+ minHeight: 0,
position: "relative",
width: "100%",
}}
@@ -1554,9 +1643,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
width: "100%",
}}
>
- {orbitPlacements.length ==
+ {postCirclePlacements.length ==
orderedFriends.length &&
- orderedFriends.map(friendOrbitFor)}
+ orderedFriends.map(friendPostCircleFor)}
</Box>
) : (
<Box
@@ -1582,46 +1671,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
)}
</Box>
</Box>
- <Box
- component="button"
- type="button"
- aria-label="Post photo"
+ <SpacePostFloatingActionButton
disabled={isPostPhotoButtonDisabled}
onClick={openPostPhotoPicker}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: green,
- border: 0,
- borderRadius: "50%",
- bottom: "calc(env(safe-area-inset-bottom) + 20px)",
- boxShadow: "0 8px 24px rgba(0, 0, 0, 0.36)",
- boxSizing: "border-box",
- color: "#FFF",
- cursor: isPostPhotoButtonDisabled
- ? "default"
- : "pointer",
- display: "flex",
- height: postButtonSize,
- justifyContent: "center",
- opacity: isPostPhotoButtonDisabled ? 0.72 : 1,
- p: 0,
- position: "fixed",
- right: "max(20px, calc((100vw - 390px) / 2 + 20px))",
- width: postButtonSize,
- zIndex: 5,
- "&:focus-visible": {
- outline: "3px solid #FFF",
- outlineOffset: 3,
- },
- }}
- >
- <HugeiconsIcon
- icon={Add01Icon}
- size={postButtonIconSize}
- strokeWidth={2.1}
- />
- </Box>
+ />
{selectedViewer && (
<SpaceFileViewer
focusReplyOnOpen={selectedViewer.focusReplyOnOpen}
diff --git a/web/apps/space/src/utils/home-circle-layout.ts b/web/apps/space/src/utils/home-circle-layout.ts
new file mode 100644
index 0000000000..f79fbdb908
--- /dev/null
+++ b/web/apps/space/src/utils/home-circle-layout.ts
@@ -0,0 +1,98 @@
+interface CircleSlot {
+ column: number;
+ row: number;
+}
+
+export interface HomeCirclePlacement {
+ size: number;
+ x: number;
+ y: number;
+}
+
+const homeCircleSizeScale = 0.94;
+
+export const homeCircleOrbitGap = (circleSize: number) =>
+ Math.max(3, Math.min(9, circleSize * 0.04));
+
+const circleSlotsForCount = (count: number) => {
+ if (count == 1) {
+ return { columns: 1, rows: 1, slots: [{ column: 0, row: 0 }] };
+ }
+ if (count == 2) {
+ return {
+ columns: 1,
+ rows: 2,
+ slots: [
+ { column: 0, row: 0 },
+ { column: 0, row: 1 },
+ ],
+ };
+ }
+ if (count == 3) {
+ return {
+ columns: 2,
+ rows: 2,
+ slots: [
+ { column: 0.5, row: 0 },
+ { column: 0, row: 1 },
+ { column: 1, row: 1 },
+ ],
+ };
+ }
+
+ const columns = 2;
+ const rows = Math.ceil(count / columns);
+ const singleCircleRow = count % columns ? (count == 5 ? 1 : rows - 1) : -1;
+ const slots: CircleSlot[] = [];
+ for (let row = 0; row < rows; row++) {
+ if (row == singleCircleRow) {
+ slots.push({ column: 0.5, row });
+ } else {
+ slots.push({ column: 0, row }, { column: 1, row });
+ }
+ }
+ return { columns, rows, slots };
+};
+
+export const homeCirclePlacements = (
+ count: number,
+ canvasWidth: number,
+ canvasHeight: number,
+): HomeCirclePlacement[] => {
+ if (count < 1 || canvasWidth <= 0 || canvasHeight <= 0) return [];
+
+ const { columns, rows, slots } = circleSlotsForCount(count);
+ const circleGapRatio = 0.1;
+ const slotsByRow = Array.from({ length: rows }, (_, row) =>
+ slots.filter((slot) => slot.row == row),
+ );
+ const rowOffsets = [0];
+ for (let row = 1; row < rows; row++) {
+ const rowsAreStaggered =
+ slotsByRow[row - 1]!.length != slotsByRow[row]!.length;
+ rowOffsets.push(rowOffsets[row - 1]! + (rowsAreStaggered ? 1 : 1.1));
+ }
+ const layoutWidth =
+ count == 1
+ ? 1 / 0.5
+ : count == 2
+ ? 1 / 0.48
+ : columns + (columns - 1) * circleGapRatio;
+ const layoutHeight = 1 + rowOffsets[rowOffsets.length - 1]!;
+ const slotSize = Math.min(
+ canvasWidth / layoutWidth,
+ canvasHeight / layoutHeight,
+ );
+ const size = slotSize * homeCircleSizeScale;
+ const circleInset = (slotSize - size) / 2;
+ const horizontalStep = slotSize * (1 + circleGapRatio);
+ const renderedWidth = slotSize + horizontalStep * (columns - 1);
+ const renderedHeight = slotSize * layoutHeight;
+ const originX = (canvasWidth - renderedWidth) / 2;
+ const originY = (canvasHeight - renderedHeight) / 2;
+ return slots.map(({ column, row }) => ({
+ size,
+ x: originX + column * horizontalStep + circleInset,
+ y: originY + rowOffsets[row]! * slotSize + circleInset,
+ }));
+};
diff --git a/web/apps/space/src/utils/home-orbit-layout.ts b/web/apps/space/src/utils/home-orbit-layout.ts
deleted file mode 100644
index 102c964691..0000000000
--- a/web/apps/space/src/utils/home-orbit-layout.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-export interface HomeOrbitPlacement {
- avatarSize: number;
- radius: number;
- top: number;
-}
-
-export const homeOrbitPlacements = (
- count: number,
- canvasWidth: number,
- canvasHeight: number,
-): HomeOrbitPlacement[] => {
- if (count < 1 || canvasWidth <= 0 || canvasHeight <= 0) return [];
-
- const radius = canvasWidth * 1.2;
- const verticalInset = Math.min(144, canvasHeight * 0.22);
- const availableSpan = Math.max(0, canvasHeight - verticalInset * 2);
- const preferredGap = Math.min(160, canvasHeight * 0.22);
- const orbitGap =
- count > 1 ? Math.min(preferredGap, availableSpan / (count - 1)) : 0;
- const baseSize = Math.min(canvasWidth * 0.34, canvasHeight * 0.2);
- const countSize = baseSize / (1 + (count - 1) * 0.06);
- const avatarSize =
- count > 1 ? Math.min(countSize, orbitGap * 0.82) : countSize;
- const stackHeight = orbitGap * (count - 1);
- const stackTop = (canvasHeight - stackHeight) / 2;
-
- return Array.from({ length: count }, (_, index) => ({
- avatarSize,
- radius,
- top: stackTop + orbitGap * index,
- }));
-};