Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refine Space home tile layout and controls

Anand Baburajan026b87fef0be
diff --git a/web/apps/space/src/components/HomeHeader.tsx b/web/apps/space/src/components/HomeHeader.tsx
index 4c5813f209..b362e6b564 100644
--- a/web/apps/space/src/components/HomeHeader.tsx
+++ b/web/apps/space/src/components/HomeHeader.tsx
@@ -29,6 +29,7 @@ export const spaceHomeHeaderHeight = 64;
interface SpaceHomeHeaderProps {
children?: React.ReactNode;
+ logoActions?: React.ReactNode;
onOpenMessages?: () => void;
onOpenProfile?: () => void;
profile: SetupProfile | null;
@@ -37,6 +38,7 @@ interface SpaceHomeHeaderProps {
export const SpaceHomeHeader: React.FC<SpaceHomeHeaderProps> = ({
children,
+ logoActions,
onOpenMessages,
onOpenProfile,
profile,
@@ -143,12 +145,26 @@ export const SpaceHomeHeader: React.FC<SpaceHomeHeaderProps> = ({
zIndex: 1,
}}
>
- <Box
- component="img"
- alt="Space"
- src="/images/space.svg"
- sx={{ display: "block", height: 19, width: "auto" }}
- />
+ <Box sx={{ position: "relative" }}>
+ <Box
+ component="img"
+ alt="Space"
+ src="/images/space.svg"
+ sx={{ display: "block", height: 19, width: "auto" }}
+ />
+ {logoActions && (
+ <Box
+ sx={{
+ left: "calc(100% + 4px)",
+ position: "absolute",
+ top: "50%",
+ transform: "translateY(-50%)",
+ }}
+ >
+ {logoActions}
+ </Box>
+ )}
+ </Box>
</Box>
<Box
component="button"
diff --git a/web/apps/space/src/components/OwnPostTile.tsx b/web/apps/space/src/components/OwnPostTile.tsx
index 22ee31541c..a9ecf3d8dd 100644
--- a/web/apps/space/src/components/OwnPostTile.tsx
+++ b/web/apps/space/src/components/OwnPostTile.tsx
@@ -17,6 +17,7 @@ import {
spaceTileCircleInset,
spaceTileCornerStyles,
} from "styles/tiles";
+import { homeTileGap } from "utils/home-tile-layout";
import { spaceDefaultCoverImagePath } from "utils/post-image";
import { thumbHashDataURLFromBase64 } from "utils/thumbhash";
@@ -77,13 +78,14 @@ const PostStatus: React.FC<{
display: "inline-flex",
fontSize: 12,
fontWeight: 500,
- left: "var(--space-tile-padding)",
lineHeight: "16px",
pointerEvents: "none",
position: "absolute",
px: "10px",
py: "4px",
- top: "var(--space-tile-padding)",
+ right: "var(--space-tile-padding)",
+ top: "50%",
+ transform: "translateY(-50%)",
whiteSpace: "nowrap",
}}
>
@@ -175,157 +177,123 @@ export const SpaceOwnPostTile: React.FC<SpaceOwnPostTileProps> = ({
}, [onLoadPostImage, post]);
return (
- <Box
- ref={tileRef}
- component="section"
- aria-label="Your latest post"
- sx={{
- ...spaceTileCornerStyles(spacePostTileRadius),
- aspectRatio: "1.7",
- bgcolor: unavailable ? spaceSurface : "transparent",
- flexShrink: 0,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- overflow: "hidden",
- position: "relative",
- width: "100%",
- "& button:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: -4,
- },
- }}
- >
+ <Box sx={{ display: "flex", flexShrink: 0, gap: `${homeTileGap}px` }}>
<Box
- component="button"
- type="button"
- aria-label="Open your posts"
- disabled={!canOpenPost}
- onClick={onOpenPost}
+ ref={tileRef}
+ component="section"
+ aria-label="Your latest post"
sx={{
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "inherit",
- color: spaceTextMuted,
- cursor: canOpenPost ? "pointer" : "default",
- font: "inherit",
- inset: 0,
- p: 0,
- position: "absolute",
- width: "100%",
+ ...spaceTileCornerStyles(spacePostTileRadius),
+ bgcolor: unavailable ? spaceSurface : "transparent",
+ flex: 1,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ height: actionSize,
+ minWidth: 0,
+ overflow: "hidden",
+ position: "relative",
+ "& button:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: -4,
+ },
}}
>
- {(coverUrl || thumbHashDataURL) && !unavailable ? (
- <>
- {thumbHashDataURL && (
- <Box
- component="img"
- alt=""
- aria-hidden
- src={thumbHashDataURL}
- sx={{
- filter: "blur(14px)",
- height: "100%",
- inset: 0,
- objectFit: "cover",
- position: "absolute",
- transform: "scale(1.08)",
- width: "100%",
- }}
- />
- )}
- {coverUrl && (
- <Box
- component="img"
- alt={
- isEmpty
- ? ""
- : post?.caption || "Your latest post"
- }
- src={coverUrl}
- onError={() =>
- post &&
- setLoadedImage({ post, failed: true })
- }
- sx={{
- display: "block",
- height: "100%",
- objectFit: "cover",
- position: "relative",
- width: "100%",
- }}
- />
- )}
- </>
- ) : !loading ? (
- <Box
- sx={{
- fontSize: 15,
- pb: "56px",
- px: "var(--space-tile-padding)",
- }}
- >
- Couldn&apos;t load your latest post
- </Box>
- ) : null}
- {isEmpty && (
- <Box
- sx={{
- alignItems: "center",
- bgcolor: "rgba(0, 0, 0, 0.18)",
- display: "flex",
- flexDirection: "column",
- gap: "6px",
- inset: 0,
- justifyContent: "center",
- position: "absolute",
- px: "var(--space-tile-padding)",
- textAlign: "center",
- }}
- >
+ <Box
+ component="button"
+ type="button"
+ aria-label="Open your posts"
+ disabled={!canOpenPost}
+ onClick={onOpenPost}
+ sx={{
+ appearance: "none",
+ bgcolor: "transparent",
+ border: 0,
+ borderRadius: "inherit",
+ color: spaceTextMuted,
+ cursor: canOpenPost ? "pointer" : "default",
+ font: "inherit",
+ inset: 0,
+ p: 0,
+ position: "absolute",
+ width: "100%",
+ }}
+ >
+ {(coverUrl || thumbHashDataURL) && !unavailable ? (
+ <>
+ {thumbHashDataURL && (
+ <Box
+ component="img"
+ alt=""
+ aria-hidden
+ src={thumbHashDataURL}
+ sx={{
+ filter: "blur(14px)",
+ height: "100%",
+ inset: 0,
+ objectFit: "cover",
+ position: "absolute",
+ transform: "scale(1.08)",
+ width: "100%",
+ }}
+ />
+ )}
+ {coverUrl && (
+ <Box
+ component="img"
+ alt={
+ isEmpty
+ ? ""
+ : post?.caption ||
+ "Your latest post"
+ }
+ src={coverUrl}
+ onError={() =>
+ post &&
+ setLoadedImage({ post, failed: true })
+ }
+ sx={{
+ display: "block",
+ height: "100%",
+ objectFit: "cover",
+ position: "relative",
+ width: "100%",
+ }}
+ />
+ )}
+ </>
+ ) : !loading ? (
<Box
- component="span"
sx={{
- bgcolor: "rgba(249, 252, 239, 0.94)",
- borderRadius: "999px",
- color: "#24351B",
fontSize: 12,
- fontWeight: 600,
lineHeight: "18px",
- px: "12px",
- py: "3px",
+ pl: `calc(var(--space-tile-padding) * 2 + ${avatarSize}px)`,
+ pr: "var(--space-tile-padding)",
+ textAlign: "left",
}}
>
- Your latest post will show up here
+ Couldn&apos;t load your latest post
</Box>
+ ) : null}
+ {isEmpty && (
<Box
- component="span"
sx={{
- backdropFilter: "blur(12px)",
- bgcolor: "rgba(28, 28, 30, 0.48)",
- borderRadius: "999px",
- color: "#E3E7DA",
+ alignItems: "center",
+ bgcolor: "rgba(0, 0, 0, 0.4)",
+ color: "#FFFFFF",
+ display: "flex",
fontSize: 12,
fontWeight: 500,
+ inset: 0,
lineHeight: "18px",
- px: "10px",
- py: "3px",
+ pl: `calc(var(--space-tile-padding) * 2 + ${avatarSize}px)`,
+ position: "absolute",
+ pr: "var(--space-tile-padding)",
+ textAlign: "left",
}}
>
- Share a little moment from your day!
+ Your latest post will show up here
</Box>
- </Box>
- )}
- </Box>
- <Box
- sx={{
- bottom: 0,
- height: "50%",
- left: 0,
- pointerEvents: "none",
- position: "absolute",
- right: 0,
- }}
- >
+ )}
+ </Box>
<Box
component="button"
type="button"
@@ -337,15 +305,15 @@ export const SpaceOwnPostTile: React.FC<SpaceOwnPostTileProps> = ({
bgcolor: "transparent",
border: 0,
borderRadius: "50%",
- bottom: spaceTileCircleInset(avatarSize),
cursor: onOpenProfile ? "pointer" : "default",
display: "flex",
height: avatarSize,
justifyContent: "center",
left: spaceTileCircleInset(avatarSize),
p: 0,
- pointerEvents: "auto",
position: "absolute",
+ top: "50%",
+ transform: "translateY(-50%)",
width: avatarSize,
}}
>
@@ -376,45 +344,45 @@ export const SpaceOwnPostTile: React.FC<SpaceOwnPostTileProps> = ({
)}
</Box>
</Box>
- <Box
- className="green-bg"
- component="button"
- type="button"
- aria-label="New post"
- disabled={isNewPostDisabled}
- onClick={onNewPost}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: green,
- border: 0,
- borderRadius: "50%",
- bottom: spaceTileCircleInset(actionSize),
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.32)",
- color: "#FFFFFF",
- cursor: isNewPostDisabled ? "default" : "pointer",
- display: "flex",
- height: actionSize,
- justifyContent: "center",
- opacity: isNewPostDisabled ? 0.6 : 1,
- p: 0,
- pointerEvents: "auto",
- position: "absolute",
- right: spaceTileCircleInset(actionSize),
- width: actionSize,
- "&:hover": { bgcolor: "#07B422" },
- "&:focus-visible": { outlineColor: "#FFFFFF" },
- }}
- >
- <HugeiconsIcon icon={Add01Icon} size={32} strokeWidth={2} />
- </Box>
+ {publishPhase && (
+ <PostStatus
+ phase={publishPhase}
+ expiresAtMs={postPublication?.statusExpiresAtMs}
+ />
+ )}
+ </Box>
+ <Box
+ className="green-bg"
+ component="button"
+ type="button"
+ aria-label="New post"
+ disabled={isNewPostDisabled}
+ onClick={onNewPost}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: green,
+ border: 0,
+ borderRadius: "50%",
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.32)",
+ color: "#FFFFFF",
+ cursor: isNewPostDisabled ? "default" : "pointer",
+ display: "flex",
+ flexShrink: 0,
+ height: actionSize,
+ justifyContent: "center",
+ opacity: isNewPostDisabled ? 0.6 : 1,
+ p: 0,
+ width: actionSize,
+ "&:hover": { bgcolor: "#07B422" },
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 3,
+ },
+ }}
+ >
+ <HugeiconsIcon icon={Add01Icon} size={32} strokeWidth={2} />
</Box>
- {publishPhase && (
- <PostStatus
- phase={publishPhase}
- expiresAtMs={postPublication?.statusExpiresAtMs}
- />
- )}
</Box>
);
};
diff --git a/web/apps/space/src/pages/layout-demo.tsx b/web/apps/space/src/pages/layout-demo.tsx
index d64fff66e7..89b29074d5 100644
--- a/web/apps/space/src/pages/layout-demo.tsx
+++ b/web/apps/space/src/pages/layout-demo.tsx
@@ -12,12 +12,7 @@ import { FriendPostTile } from "screens/HomeScreen";
import type { SetupProfile } from "screens/SetupProfileScreen";
import { spaceInviteURL } from "services/invite";
import type { SpacePost } from "services/space";
-import { spaceAppBackground, spaceSurface, spaceText } from "styles/colors";
-import {
- spacePostTileRadius,
- spaceTileCircleInset,
- spaceTileCornerStyles,
-} from "styles/tiles";
+import { spaceAppBackground, spaceText } from "styles/colors";
import {
homeTileGap,
homeTileLayout,
@@ -29,7 +24,6 @@ import { spaceDefaultCoverImagePath } from "utils/post-image";
import { useSpaceRouter } from "utils/route-transitions";
import { spaceRoutes } from "utils/routes";
-const controlButtonColor = spaceSurface;
const demoProfile: SetupProfile = {
avatarUrl: null,
fullName: "Alex Morgan",
@@ -137,6 +131,7 @@ const LayoutDemoPost: React.FC<LayoutDemoPostProps> = ({
friendRequestDirection ? () => undefined : undefined
}
onOpenPosts={() => undefined}
+ isNineTileLayout={count == maximumHomeTileCount}
isTwoTileLayout={count == 2}
placement={placement}
posts={post ? [post] : []}
@@ -246,95 +241,8 @@ const LayoutDemoPage: React.FC = () => {
}}
>
<SpaceHomeHeader
- profile={demoProfile}
- onOpenProfile={() => void router.push(spaceRoutes.profile)}
- />
- <Box
- sx={{
- boxSizing: "border-box",
- display: "flex",
- flexDirection: "column",
- gap: `${homeTileGap}px`,
- minHeight: `calc(100svh - ${spaceHomeHeaderHeight}px)`,
- minWidth: 0,
- pb: "calc(env(safe-area-inset-bottom) + 16px)",
- px: "16px",
- pt: "4px",
- width: "100%",
- }}
- >
- <Box
- ref={canvasRef}
- component="ul"
- aria-label="Friends and friend requests"
- sx={{
- flex: "1 1 auto",
- m: 0,
- minHeight: minimumHomeTileCanvasHeight(friendCount),
- p: 0,
- position: "relative",
- width: "100%",
- }}
- >
- {layout && (
- <>
- {layout.friends.map((placement, index) => (
- <LayoutDemoPost
- key={index}
- count={friendCount}
- index={index}
- placement={placement}
- />
- ))}
- {layout.addFriend && (
- <SpaceAddFriendTile
- placement={layout.addFriend}
- variant={layout.addFriendVariant}
- onClick={() => {
- setProfileLink(
- spaceInviteURL({
- spaceUsername:
- demoProfile.username,
- }),
- );
- setIsAddFriendOpen(true);
- }}
- />
- )}
- </>
- )}
- </Box>
- <Box
- sx={{
- ...spaceTileCornerStyles(spacePostTileRadius),
- flexShrink: 0,
- position: "relative",
- }}
- >
- <SpaceOwnPostTile
- profile={demoProfile}
- post={ownPosts[0]}
- onNewPost={() =>
- setDemo((current) => ({
- ...current,
- ownPosts: demoOwnPosts,
- }))
- }
- onOpenPost={() => {
- setOwnViewerPosts(ownPosts);
- setOwnPostIndex(0);
- }}
- />
- <Box
- sx={{
- display: "flex",
- gap: "8px",
- position: "absolute",
- right: spaceTileCircleInset(36),
- top: spaceTileCircleInset(36),
- zIndex: 5,
- }}
- >
+ logoActions={
+ <Box sx={{ display: "flex" }}>
<Box
component="button"
type="button"
@@ -344,7 +252,7 @@ const LayoutDemoPage: React.FC = () => {
sx={{
alignItems: "center",
appearance: "none",
- bgcolor: controlButtonColor,
+ bgcolor: "transparent",
border: 0,
borderRadius: "50%",
color: spaceText,
@@ -353,16 +261,16 @@ const LayoutDemoPage: React.FC = () => {
? "default"
: "pointer",
display: "flex",
- height: 36,
+ height: 24,
justifyContent: "center",
opacity: friendCount == 0 ? 0.3 : 1,
p: 0,
- width: 36,
+ width: 24,
}}
>
<HugeiconsIcon
icon={ArrowLeft02Icon}
- size={22}
+ size={16}
strokeWidth={2.2}
/>
</Box>
@@ -375,7 +283,7 @@ const LayoutDemoPage: React.FC = () => {
sx={{
alignItems: "center",
appearance: "none",
- bgcolor: controlButtonColor,
+ bgcolor: "transparent",
border: 0,
borderRadius: "50%",
color: spaceText,
@@ -384,24 +292,96 @@ const LayoutDemoPage: React.FC = () => {
? "default"
: "pointer",
display: "flex",
- height: 36,
+ height: 24,
justifyContent: "center",
opacity:
friendCount == maximumHomeTileCount
? 0.3
: 1,
p: 0,
- width: 36,
+ width: 24,
}}
>
<HugeiconsIcon
icon={ArrowRight02Icon}
- size={22}
+ size={16}
strokeWidth={2.2}
/>
</Box>
</Box>
+ }
+ profile={demoProfile}
+ onOpenProfile={() => void router.push(spaceRoutes.profile)}
+ />
+ <Box
+ sx={{
+ boxSizing: "border-box",
+ display: "flex",
+ flexDirection: "column",
+ gap: `${homeTileGap}px`,
+ minHeight: `calc(100svh - ${spaceHomeHeaderHeight}px)`,
+ minWidth: 0,
+ pb: "calc(env(safe-area-inset-bottom) + 16px)",
+ px: "16px",
+ pt: "4px",
+ width: "100%",
+ }}
+ >
+ <Box
+ ref={canvasRef}
+ component="ul"
+ aria-label="Friends and friend requests"
+ sx={{
+ flex: "1 1 auto",
+ m: 0,
+ minHeight: minimumHomeTileCanvasHeight(friendCount),
+ p: 0,
+ position: "relative",
+ width: "100%",
+ }}
+ >
+ {layout && (
+ <>
+ {layout.friends.map((placement, index) => (
+ <LayoutDemoPost
+ key={index}
+ count={friendCount}
+ index={index}
+ placement={placement}
+ />
+ ))}
+ {layout.addFriend && (
+ <SpaceAddFriendTile
+ placement={layout.addFriend}
+ variant={layout.addFriendVariant}
+ onClick={() => {
+ setProfileLink(
+ spaceInviteURL({
+ spaceUsername:
+ demoProfile.username,
+ }),
+ );
+ setIsAddFriendOpen(true);
+ }}
+ />
+ )}
+ </>
+ )}
</Box>
+ <SpaceOwnPostTile
+ profile={demoProfile}
+ post={ownPosts[0]}
+ onNewPost={() =>
+ setDemo((current) => ({
+ ...current,
+ ownPosts: demoOwnPosts,
+ }))
+ }
+ onOpenPost={() => {
+ setOwnViewerPosts(ownPosts);
+ setOwnPostIndex(0);
+ }}
+ />
</Box>
<SpaceAddFriendDialog
friendRequests={[]}
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index ec729605f4..4d3c1ca2a3 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -282,6 +282,7 @@ interface FriendPostTileProps {
posts: SpacePost[],
photo: SpaceViewerPhoto,
) => void;
+ isNineTileLayout?: boolean;
isTwoTileLayout?: boolean;
placement: HomeTilePlacement;
posts: SpacePost[];
@@ -305,6 +306,7 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
onOpenAvatar,
onOpenFriendRequest,
onOpenPosts,
+ isNineTileLayout = false,
isTwoTileLayout = false,
placement,
posts,
@@ -352,7 +354,7 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
Boolean(post && !isRead && !postUnavailable && !isPhotoReady);
const tileSize = Math.min(placement.width, placement.height);
const tileRadius = Math.min(spacePostTileRadius, tileSize * 0.2);
- const avatarSize = spaceTileAvatarSize(placement);
+ const avatarSize = spaceTileAvatarSize(placement, isNineTileLayout);
const requestActionSize = showFriendRequestDetails
? Math.min(44, Math.max(40, tileSize * 0.13))
: Math.min(40, Math.max(26, tileSize * 0.14));
@@ -943,8 +945,8 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
p: 0,
pointerEvents: "auto",
position: "absolute",
- right: spaceTileCircleInset(requestActionSize),
- top: spaceTileCircleInset(requestActionSize),
+ right: "calc(var(--space-tile-padding) / 2)",
+ top: "calc(var(--space-tile-padding) / 2)",
width: requestActionSize,
"&:disabled": { opacity: 0.55 },
"&:focus-visible": {
@@ -1477,6 +1479,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
setSelectedContact({ anchorRect, friend, avatarUrl })
}
onOpenPosts={openPostPhotos}
+ isNineTileLayout={
+ orderedHomeItems.length == maximumHomeTileCount
+ }
placement={placement}
posts={posts}
/>
@@ -1526,6 +1531,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
: undefined
}
onOpenPosts={openPostPhotos}
+ isNineTileLayout={
+ orderedHomeItems.length == maximumHomeTileCount
+ }
isTwoTileLayout={orderedHomeItems.length == 2}
placement={postLayout!.friends[index]!}
posts={[]}
@@ -1771,7 +1779,11 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
post={ownLatestPost}
avatarSize={
firstFriendTile
- ? spaceTileAvatarSize(firstFriendTile)
+ ? spaceTileAvatarSize(
+ firstFriendTile,
+ orderedHomeItems.length ==
+ maximumHomeTileCount,
+ )
: undefined
}
isLoading={isOwnLatestPostLoading}
diff --git a/web/apps/space/src/styles/tiles.ts b/web/apps/space/src/styles/tiles.ts
index 39bf5e2eb7..0b4e692ece 100644
--- a/web/apps/space/src/styles/tiles.ts
+++ b/web/apps/space/src/styles/tiles.ts
@@ -1,8 +1,14 @@
export const spacePostTileRadius = 28;
export const spaceProfilePostRadius = 16;
-export const spaceTileAvatarSize = (tile: { width: number; height: number }) =>
- Math.min(36, Math.min(tile.width, tile.height) * 0.22);
+export const spaceTileAvatarSize = (
+ tile: { width: number; height: number },
+ isNineTileLayout = false,
+) =>
+ Math.max(
+ isNineTileLayout ? 28 : 0,
+ Math.min(36, Math.min(tile.width, tile.height) * 0.22),
+ );
export const spaceTileCornerStyles = (radius: number) => ({
"--space-tile-radius": `${radius}px`,