Skip to content

armgit / ente

Public Imported from GitHub
0

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

Simplify Space home rings

Anand Baburajan5f2e59beb69f
diff --git a/web/apps/space/src/components/CircleNameArc.tsx b/web/apps/space/src/components/CircleNameArc.tsx
deleted file mode 100644
index 8274f12571..0000000000
--- a/web/apps/space/src/components/CircleNameArc.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-import React from "react";
-
-export type SpaceCircleNameArcPosition = "upper-left" | "top" | "upper-right";
-
-interface SpaceCircleNameArcProps {
- id: string;
- name: string;
- nameInset: number;
- position: SpaceCircleNameArcPosition;
- ringColor: string;
- ringWidth: number;
- size: number;
-}
-
-export const SpaceCircleNameArc: React.FC<SpaceCircleNameArcProps> = ({
- id,
- name,
- nameInset,
- position,
- ringColor,
- ringWidth,
- size,
-}) => {
- const center = size / 2;
- const fontSize = Math.max(8, Math.min(11, size * 0.065));
- const radius = center - fontSize * 0.2 - nameInset;
- const arcCenterAngle =
- position == "upper-left"
- ? (Math.PI * 5) / 4
- : position == "upper-right"
- ? (Math.PI * 7) / 4
- : (Math.PI * 3) / 2;
- const arcStartAngle = arcCenterAngle - Math.PI / 4;
- const arcEndAngle = arcCenterAngle + Math.PI / 4;
- const path = `M ${center + radius * Math.cos(arcStartAngle)} ${center + radius * Math.sin(arcStartAngle)} A ${radius} ${radius} 0 0 1 ${center + radius * Math.cos(arcEndAngle)} ${center + radius * Math.sin(arcEndAngle)}`;
- const uppercaseName = name.toLocaleUpperCase();
- const arcLength = (Math.PI * radius) / 2;
- const labelWidth = Math.min(
- arcLength - fontSize,
- uppercaseName.length * fontSize * 0.68 + fontSize * 0.4,
- );
- const halfGapAngle = labelWidth / (2 * radius);
- const gapStartAngle = arcCenterAngle - halfGapAngle;
- const gapEndAngle = arcCenterAngle + halfGapAngle;
- const gapPath = `M ${center + radius * Math.cos(gapStartAngle)} ${center + radius * Math.sin(gapStartAngle)} A ${radius} ${radius} 0 0 1 ${center + radius * Math.cos(gapEndAngle)} ${center + radius * Math.sin(gapEndAngle)}`;
- const ringMaskID = `${id}-ring-mask`;
-
- return (
- <svg
- aria-hidden
- focusable="false"
- viewBox={`0 0 ${size} ${size}`}
- style={{
- height: "100%",
- inset: 0,
- overflow: "visible",
- pointerEvents: "none",
- position: "absolute",
- width: "100%",
- zIndex: 2,
- }}
- >
- <defs>
- <path id={id} d={path} />
- <mask
- id={ringMaskID}
- maskContentUnits="userSpaceOnUse"
- maskUnits="userSpaceOnUse"
- x={-size}
- y={-size}
- width={size * 3}
- height={size * 3}
- >
- <rect
- x={-size}
- y={-size}
- width={size * 3}
- height={size * 3}
- fill="#FFF"
- />
- <path
- d={gapPath}
- fill="none"
- stroke="#000"
- strokeLinecap="round"
- strokeWidth={fontSize + 4}
- />
- </mask>
- </defs>
- <circle
- cx={center}
- cy={center}
- r={center - ringWidth / 2}
- fill="none"
- mask={`url(#${ringMaskID})`}
- stroke={ringColor}
- strokeWidth={ringWidth}
- />
- <text
- fill="rgba(255, 255, 255, 0.86)"
- fontFamily='"Nunito", sans-serif'
- fontSize={fontSize}
- fontWeight={800}
- letterSpacing="0.04em"
- >
- <textPath href={`#${id}`} startOffset="50%" textAnchor="middle">
- {uppercaseName}
- </textPath>
- </text>
- </svg>
- );
-};
diff --git a/web/apps/space/src/pages/layout-demo.tsx b/web/apps/space/src/pages/layout-demo.tsx
index 4d4aa44e31..042dcc89bf 100644
--- a/web/apps/space/src/pages/layout-demo.tsx
+++ b/web/apps/space/src/pages/layout-demo.tsx
@@ -1,7 +1,6 @@
import { ArrowLeft02Icon, ArrowRight01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box } from "@mui/material";
-import { SpaceCircleNameArc } from "components/CircleNameArc";
import { SpacePostFloatingActionButton } from "components/PostFloatingActionButton";
import React from "react";
import { homeCirclePlacements } from "utils/home-circle-layout";
@@ -12,23 +11,6 @@ const headerHeight = 64;
const layoutVerticalInset =
"calc(112px + max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px)))";
const maximumFriendCount = 15;
-const sampleNames = [
- "Maya",
- "Noah",
- "Ari",
- "Zoya",
- "Leo",
- "Mina",
- "Ira",
- "Omar",
- "Nina",
- "Theo",
- "Rhea",
- "Eli",
- "Lina",
- "Jai",
- "Ada",
-];
interface CanvasSize {
height: number;
@@ -78,7 +60,7 @@ const LayoutDemoPage: React.FC = () => {
);
const circleSize = placements[0]?.size ?? 0;
const ringWidth = Math.max(1, Math.min(3, circleSize * 0.018));
- const circlePadding = Math.max(3, Math.min(7, circleSize * 0.04));
+ const circlePadding = Math.max(1.5, Math.min(4, circleSize * 0.025));
return (
<Box
@@ -229,11 +211,11 @@ const LayoutDemoPage: React.FC = () => {
<Box
sx={{
aspectRatio: "1",
- border: 0,
+ border: `${ringWidth}px solid #2A3430`,
borderRadius: "50%",
boxSizing: "border-box",
height: "100%",
- p: `${ringWidth + circlePadding}px`,
+ p: `${circlePadding}px`,
position: "relative",
width: "100%",
zIndex: 1,
@@ -248,26 +230,6 @@ const LayoutDemoPage: React.FC = () => {
}}
/>
</Box>
- <SpaceCircleNameArc
- id={`layout-name-arc-${index}`}
- name={sampleNames[index]!}
- nameInset={circlePadding * 0.45}
- position={
- Math.abs(
- x +
- size / 2 -
- canvasSize.width / 2,
- ) < 1
- ? "top"
- : x + size / 2 <
- canvasSize.width / 2
- ? "upper-left"
- : "upper-right"
- }
- ringColor="#2A3430"
- ringWidth={ringWidth}
- size={size}
- />
</Box>
))}
</Box>
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 45031a2b87..7935716858 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -6,10 +6,6 @@ import {
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Skeleton } from "@mui/material";
import { SpaceAvatarImage } from "components/AvatarImage";
-import {
- SpaceCircleNameArc,
- type SpaceCircleNameArcPosition,
-} from "components/CircleNameArc";
import {
SpaceFileViewer,
SpaceViewerFeedBackdrop,
@@ -223,7 +219,6 @@ interface FriendPostCircleProps {
isUnavailable: boolean;
onLoadAvatar?: () => Promise<string | null | undefined>;
onLoadImage?: () => Promise<string | undefined>;
- nameArcPosition: SpaceCircleNameArcPosition;
onOpenFriend?: (friendID: string, username?: string) => void;
onOpenPhoto: (photo: SpaceViewerPhoto) => void;
placement: HomeCirclePlacement;
@@ -237,7 +232,6 @@ const FriendPostCircle: React.FC<FriendPostCircleProps> = ({
isAvatarPending,
isLoading,
isUnavailable,
- nameArcPosition,
onLoadAvatar,
onLoadImage,
onOpenFriend,
@@ -245,7 +239,6 @@ const FriendPostCircle: React.FC<FriendPostCircleProps> = ({
placement,
post,
}) => {
- const nameArcID = React.useId();
const rootRef = React.useRef<HTMLLIElement | null>(null);
const [shouldLoadMedia, setShouldLoadMedia] = useState(Boolean(imageUrl));
const decodedPhoto = useDecodedImage(imageUrl, true);
@@ -278,7 +271,7 @@ const FriendPostCircle: React.FC<FriendPostCircleProps> = ({
const isCircleDisabled =
isLoading || Boolean(post && !postUnavailable && !isPhotoReady);
const circleBorderWidth = Math.max(1, Math.min(3, placement.size * 0.018));
- const circlePadding = Math.max(3, Math.min(7, placement.size * 0.04));
+ const circlePadding = Math.max(1.5, Math.min(4, placement.size * 0.025));
React.useEffect(() => {
if (isLoading || !post || postUnavailable || shouldLoadMedia) return;
@@ -364,11 +357,11 @@ const FriendPostCircle: React.FC<FriendPostCircleProps> = ({
<Box
sx={{
aspectRatio: "1",
- border: 0,
+ border: `${circleBorderWidth}px solid ${inactivePostCircleBorderColor}`,
borderRadius: "50%",
boxSizing: "border-box",
height: "100%",
- p: `${circleBorderWidth + circlePadding}px`,
+ p: `${circlePadding}px`,
position: "relative",
width: "100%",
zIndex: 1,
@@ -480,15 +473,6 @@ const FriendPostCircle: React.FC<FriendPostCircleProps> = ({
)}
</Box>
</Box>
- <SpaceCircleNameArc
- id={nameArcID}
- name={firstName}
- nameInset={circlePadding * 0.45}
- position={nameArcPosition}
- ringColor={inactivePostCircleBorderColor}
- ringWidth={circleBorderWidth}
- size={placement.size}
- />
</Box>
);
};
@@ -842,18 +826,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
isAvatarPending={isAvatarPending}
isLoading={isFriendsLoading || isLatestPostsLoading}
isUnavailable={isUnavailable}
- nameArcPosition={
- Math.abs(
- placement.x +
- placement.size / 2 -
- postCircleCanvasSize.width / 2,
- ) < 1
- ? "top"
- : placement.x + placement.size / 2 <
- postCircleCanvasSize.width / 2
- ? "upper-left"
- : "upper-right"
- }
onLoadAvatar={
item && isAvatarPending
? () => loadPostAvatar(item)