Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add social profile screen

Anand Baburajanea452b88fd06
diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsx
index d0a0dd63a0..fc9409e487 100644
--- a/web/apps/social/src/pages/index.tsx
+++ b/web/apps/social/src/pages/index.tsx
@@ -15,6 +15,10 @@ import {
RecoveryKeyScreen,
recoveryKeyBackground,
} from "screens/RecoveryKeyScreen";
+import {
+ ProfileScreen,
+ profileBackground,
+} from "screens/ProfileScreen";
import {
SetupProfileScreen,
setupProfileBackground,
@@ -37,7 +41,8 @@ type Screen =
| "recovery-key"
| "setup-profile"
| "share-profile-link"
- | "home";
+ | "home"
+ | "profile";
type ProfileBackScreen = "login" | "recovery-key";
@@ -73,6 +78,8 @@ const Page: React.FC = () => {
? shareProfileLinkBackground
: screen == "home"
? homeBackground
+ : screen == "profile"
+ ? profileBackground
: createAccountBackground
}
/>
@@ -141,7 +148,18 @@ const Page: React.FC = () => {
onDone={() => setScreen("home")}
/>
)}
- {screen == "home" && profile && <HomeScreen profile={profile} />}
+ {screen == "home" && profile && (
+ <HomeScreen
+ profile={profile}
+ onOpenProfile={() => setScreen("profile")}
+ />
+ )}
+ {screen == "profile" && profile && (
+ <ProfileScreen
+ profile={profile}
+ onBack={() => setScreen("home")}
+ />
+ )}
</>
);
};
diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsx
index f2823cfe4c..ed2e95486b 100644
--- a/web/apps/social/src/screens/HomeScreen.tsx
+++ b/web/apps/social/src/screens/HomeScreen.tsx
@@ -50,6 +50,7 @@ const sampleFeedItems = [
];
interface HomeScreenProps {
+ onOpenProfile?: () => void;
profile: SetupProfile;
}
@@ -172,7 +173,10 @@ const FeedItem: React.FC<FeedItemProps> = ({
</Box>
);
-export const HomeScreen: React.FC<HomeScreenProps> = ({ profile }) => {
+export const HomeScreen: React.FC<HomeScreenProps> = ({
+ onOpenProfile,
+ profile,
+}) => {
const initialsSource = profile.fullName.trim() || profile.username.trim();
const initials = initialsSource
.split(/\s+/)
@@ -231,26 +235,37 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({ profile }) => {
justifySelf: "center",
lineHeight: 0,
overflow: "visible",
- width: 78,
+ width: 65,
"& svg": { display: "block", overflow: "visible" },
}}
>
- <EnteLogo height={24} />
+ <EnteLogo height={20} />
</Box>
<Box
+ component="button"
+ type="button"
+ aria-label="Open profile"
+ onClick={onOpenProfile}
sx={{
alignItems: "center",
bgcolor: profile.avatarUrl
? "transparent"
: paleGreen,
+ border: 0,
borderRadius: "50%",
color: green,
+ cursor: onOpenProfile ? "pointer" : "default",
display: "flex",
height: 24,
justifyContent: "center",
justifySelf: "flex-end",
overflow: "hidden",
+ p: 0,
width: 24,
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
}}
>
{profile.avatarUrl ? (
diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsx
new file mode 100644
index 0000000000..ed453b374a
--- /dev/null
+++ b/web/apps/social/src/screens/ProfileScreen.tsx
@@ -0,0 +1,376 @@
+import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
+import SettingsRoundedIcon from "@mui/icons-material/SettingsRounded";
+import { Box } from "@mui/material";
+import React from "react";
+import type { SetupProfile } from "screens/SetupProfileScreen";
+
+export const profileBackground = "#FFFFFF";
+
+const green = "#08C225";
+const paleGreen = "#E7F6E9";
+const textBase = "#000";
+const textStrong = "#303030";
+const textSoft = "#777777";
+const divider = "rgba(0, 0, 0, 0.08)";
+
+const samplePostItems = [
+ {
+ gridColumn: "1 / span 2",
+ gridRow: "1 / span 2",
+ imageUrl: "/images/sample-feed-1.jpg",
+ },
+ {
+ gridColumn: "3",
+ gridRow: "1",
+ imageUrl: "/images/sample-feed-2.jpg",
+ },
+ {
+ gridColumn: "3",
+ gridRow: "2",
+ imageUrl: "/images/sample-feed-3.jpg",
+ },
+ {
+ gridColumn: "1",
+ gridRow: "3",
+ imageUrl: "/images/sample-feed-4.jpg",
+ },
+ {
+ gridColumn: "2 / span 2",
+ gridRow: "3",
+ imageUrl: "/images/sample-feed-5.jpg",
+ },
+ {
+ gridColumn: "1",
+ gridRow: "4",
+ imageUrl: "/images/sample-feed-6.jpg",
+ },
+ {
+ gridColumn: "2",
+ gridRow: "4",
+ imageUrl: "/images/sample-feed-2.jpg",
+ },
+ {
+ gridColumn: "3",
+ gridRow: "4",
+ imageUrl: "/images/sample-feed-4.jpg",
+ },
+ {
+ gridColumn: "1 / span 2",
+ gridRow: "5",
+ imageUrl: "/images/sample-feed-3.jpg",
+ },
+ {
+ gridColumn: "3",
+ gridRow: "5",
+ imageUrl: "/images/sample-feed-6.jpg",
+ },
+ {
+ gridColumn: "1",
+ gridRow: "6",
+ imageUrl: "/images/sample-feed-5.jpg",
+ },
+ {
+ gridColumn: "2 / span 2",
+ gridRow: "6",
+ imageUrl: "/images/sample-feed-1.jpg",
+ },
+];
+
+interface ProfileScreenProps {
+ onBack: () => void;
+ profile: SetupProfile;
+}
+
+interface StatProps {
+ label: string;
+ value: string;
+}
+
+const Stat: React.FC<StatProps> = ({ label, value }) => (
+ <Box sx={{ minWidth: 0 }}>
+ <Box
+ sx={{
+ color: textStrong,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 15,
+ fontWeight: 800,
+ lineHeight: "19px",
+ }}
+ >
+ {value}
+ </Box>
+ <Box
+ sx={{
+ color: textSoft,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 650,
+ lineHeight: "17px",
+ mt: "1px",
+ }}
+ >
+ {label}
+ </Box>
+ </Box>
+);
+
+export const ProfileScreen: React.FC<ProfileScreenProps> = ({
+ onBack,
+ profile,
+}) => {
+ const displayName = profile.fullName.trim() || profile.username.trim();
+ const initialsSource = displayName || profile.username.trim();
+ const initials = initialsSource
+ .split(/\s+/)
+ .slice(0, 2)
+ .map((part) => part[0]?.toUpperCase())
+ .join("");
+
+ return (
+ <Box
+ component="main"
+ sx={{
+ bgcolor: profileBackground,
+ color: textBase,
+ display: "grid",
+ minHeight: "100svh",
+ overflowX: "hidden",
+ placeItems: { xs: "stretch", sm: "start center" },
+ }}
+ >
+ <Box
+ sx={{
+ bgcolor: profileBackground,
+ boxSizing: "border-box",
+ minHeight: "100svh",
+ mx: "auto",
+ width: "100%",
+ "@media (min-width: 600px)": { maxWidth: 375 },
+ }}
+ >
+ <Box
+ component="header"
+ sx={{
+ alignItems: "center",
+ display: "grid",
+ gridTemplateColumns: "24px 1fr 24px",
+ p: 2,
+ width: "100%",
+ }}
+ >
+ <Box
+ component="button"
+ type="button"
+ aria-label="Back to home"
+ onClick={onBack}
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ cursor: "pointer",
+ display: "flex",
+ height: 24,
+ justifyContent: "flex-start",
+ p: 0,
+ width: 24,
+ "&:focus-visible": {
+ borderRadius: "50%",
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <ArrowBackRoundedIcon sx={{ fontSize: 24 }} />
+ </Box>
+ <Box
+ component="h1"
+ sx={{
+ color: textBase,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 18,
+ fontWeight: 700,
+ justifySelf: "center",
+ lineHeight: "24px",
+ m: 0,
+ maxWidth: "100%",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {profile.username}
+ </Box>
+ <Box
+ component="button"
+ type="button"
+ aria-label="Settings"
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ cursor: "pointer",
+ display: "flex",
+ height: 24,
+ justifyContent: "flex-end",
+ p: 0,
+ width: 24,
+ "&:focus-visible": {
+ borderRadius: "50%",
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <SettingsRoundedIcon sx={{ fontSize: 22 }} />
+ </Box>
+ </Box>
+ <Box sx={{ bgcolor: divider, height: "1px", width: "100%" }} />
+
+ <Box
+ sx={{
+ alignItems: "center",
+ display: "flex",
+ gap: "22px",
+ px: "14px",
+ pt: "24px",
+ width: "100%",
+ }}
+ >
+ <Box
+ sx={{
+ alignItems: "center",
+ aspectRatio: "1 / 1",
+ bgcolor: profile.avatarUrl
+ ? "transparent"
+ : paleGreen,
+ borderRadius: "50%",
+ color: green,
+ display: "flex",
+ flexShrink: 0,
+ height: 86,
+ justifyContent: "center",
+ overflow: "hidden",
+ width: 86,
+ }}
+ >
+ {profile.avatarUrl ? (
+ <Box
+ component="img"
+ alt=""
+ src={profile.avatarUrl}
+ sx={{
+ display: "block",
+ height: "100%",
+ objectFit: "cover",
+ objectPosition: "center",
+ width: "100%",
+ }}
+ />
+ ) : (
+ <Box
+ sx={{
+ color: green,
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 27,
+ fontWeight: 800,
+ lineHeight: 1,
+ }}
+ >
+ {initials}
+ </Box>
+ )}
+ </Box>
+ <Box
+ sx={{
+ display: "flex",
+ flex: "1 1 0",
+ flexDirection: "column",
+ minWidth: 0,
+ }}
+ >
+ <Box
+ sx={{
+ color: textStrong,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 15,
+ fontWeight: 750,
+ lineHeight: "19px",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {displayName}
+ </Box>
+ <Box
+ sx={{
+ alignItems: "flex-start",
+ display: "grid",
+ gap: "12px",
+ gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
+ mt: "16px",
+ width: "100%",
+ }}
+ >
+ <Stat label="posts" value="12" />
+ <Stat label="followers" value="7" />
+ <Stat label="following" value="10" />
+ </Box>
+ </Box>
+ </Box>
+
+ <Box
+ component="section"
+ sx={{
+ mt: "24px",
+ pb: 0,
+ px: 0,
+ width: "100%",
+ }}
+ >
+ <Box
+ sx={{
+ aspectRatio: "1 / 2",
+ display: "grid",
+ gap: "1px",
+ gridTemplateColumns: "repeat(3, 1fr)",
+ gridTemplateRows: "repeat(6, 1fr)",
+ width: "100%",
+ }}
+ >
+ {samplePostItems.map((item, index) => (
+ <Box
+ key={`${item.imageUrl}-${index}`}
+ sx={{
+ bgcolor: paleGreen,
+ display: "block",
+ gridColumn: item.gridColumn,
+ gridRow: item.gridRow,
+ height: "100%",
+ overflow: "hidden",
+ width: "100%",
+ }}
+ >
+ <Box
+ component="img"
+ alt={`My post ${index + 1}`}
+ src={item.imageUrl}
+ sx={{
+ display: "block",
+ height: "100%",
+ objectFit: "cover",
+ objectPosition: "center",
+ width: "100%",
+ }}
+ />
+ </Box>
+ ))}
+ </Box>
+ </Box>
+ </Box>
+ </Box>
+ );
+};