Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refine Space captions and remove translucent background seams

Anand Baburajand7e9765f07b1
diff --git a/web/apps/space/src/components/CaptionText.tsx b/web/apps/space/src/components/CaptionText.tsx
new file mode 100644
index 0000000000..c8e529480a
--- /dev/null
+++ b/web/apps/space/src/components/CaptionText.tsx
@@ -0,0 +1,48 @@
+import { Box } from "@mui/material";
+import React from "react";
+
+const captionBubbleSx = {
+ borderRadius: "5px",
+ boxDecorationBreak: "clone",
+ px: "10px",
+ py: "4px",
+ WebkitBoxDecorationBreak: "clone",
+} as const;
+
+export const SpaceCaptionText: React.FC<{
+ caption: string;
+ lineClamp?: number;
+}> = ({ caption, lineClamp }) => {
+ const layerSx = {
+ display: "-webkit-box",
+ gridArea: "1 / 1",
+ minWidth: 0,
+ overflow: lineClamp ? "hidden" : undefined,
+ WebkitBoxOrient: "vertical",
+ WebkitLineClamp: lineClamp,
+ } as const;
+
+ return (
+ <Box component="span" sx={{ display: "grid" }}>
+ <Box
+ component="span"
+ aria-hidden
+ sx={{ ...layerSx, color: "transparent", opacity: 0.85 }}
+ >
+ <Box
+ component="span"
+ sx={{ ...captionBubbleSx, bgcolor: "#202020" }}
+ >
+ <Box component="span" sx={{ opacity: 0 }}>
+ {caption}
+ </Box>
+ </Box>
+ </Box>
+ <Box component="span" sx={{ ...layerSx, zIndex: 1 }}>
+ <Box component="span" sx={captionBubbleSx}>
+ {caption}
+ </Box>
+ </Box>
+ </Box>
+ );
+};
diff --git a/web/apps/space/src/components/FileViewer.tsx b/web/apps/space/src/components/FileViewer.tsx
index 40e72ee0ca..7b2147d59c 100644
--- a/web/apps/space/src/components/FileViewer.tsx
+++ b/web/apps/space/src/components/FileViewer.tsx
@@ -14,6 +14,7 @@ import {
type SpaceActionPhase,
} from "components/ActionFeedback";
import { SpaceAvatarImage } from "components/AvatarImage";
+import { SpaceCaptionText } from "components/CaptionText";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
import { spacePostLikePopDurationMs } from "components/post-like-animation";
import { SpacePostReplyControls } from "components/PostReplyControls";
@@ -272,23 +273,15 @@ const resizeCaptionInput = (
};
const viewerCaptionTextSx = {
- color: "#FFFFFF",
+ color: "#E6E6E6",
fontFamily: '"Inter Variable", Inter, sans-serif',
fontSize: 14,
- fontWeight: 650,
- lineHeight: "21px",
+ fontWeight: 600,
+ lineHeight: "23px",
textAlign: "center",
textWrap: "balance",
whiteSpace: "pre-wrap",
} as const;
-const viewerCaptionBubbleSx = {
- bgcolor: "rgba(48, 48, 48, 0.79)",
- borderRadius: "5px",
- boxDecorationBreak: "clone",
- px: "7px",
- py: "2px",
- WebkitBoxDecorationBreak: "clone",
-} as const;
const SpaceViewerCaption: React.FC<{ caption: string }> = ({ caption }) => {
return (
@@ -305,15 +298,12 @@ const SpaceViewerCaption: React.FC<{ caption: string }> = ({ caption }) => {
minWidth: 0,
overflowWrap: "break-word",
position: "fixed",
- textShadow: "0 1px 10px rgba(0, 0, 0, 0.74)",
transform: "translateX(-50%)",
width: "78vw",
zIndex: 2,
}}
>
- <Box component="span" sx={viewerCaptionBubbleSx}>
- {caption}
- </Box>
+ <SpaceCaptionText caption={caption} />
</Box>
);
};
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 5d36afefe5..da7ecf6352 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Skeleton } from "@mui/material";
import { SpaceActionToast } from "components/ActionToast";
import { SpaceAvatarImage } from "components/AvatarImage";
+import { SpaceCaptionText } from "components/CaptionText";
import { SpaceFeedPostButton } from "components/FeedPostButton";
import {
SpaceFileViewer,
@@ -79,22 +80,14 @@ const avatarFadeSx = {
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
} as const;
const feedPhotoCaptionTextSx = {
- color: "#FFFFFF",
+ color: "#E6E6E6",
fontFamily: '"Inter Variable", Inter, sans-serif',
fontSize: 13,
- fontWeight: 650,
- lineHeight: "19px",
+ fontWeight: 600,
+ lineHeight: "21px",
textAlign: "center",
textWrap: "balance",
} as const;
-const feedPhotoCaptionBubbleSx = {
- bgcolor: "rgba(48, 48, 48, 0.79)",
- borderRadius: "5px",
- boxDecorationBreak: "clone",
- px: "7px",
- py: "2px",
- WebkitBoxDecorationBreak: "clone",
-} as const;
interface HomeScreenProps {
feedItems: SpacePost[];
friendRequestSentToastName?: string;
@@ -608,23 +601,16 @@ const FeedPhotoCaption: React.FC<{ caption: string }> = ({ caption }) => {
sx={{
...feedPhotoCaptionTextSx,
bottom: 20,
- display: "-webkit-box",
left: "50%",
maxWidth: "78%",
- overflow: "hidden",
pointerEvents: "none",
position: "absolute",
- textShadow: "0 1px 10px rgba(0, 0, 0, 0.74)",
transform: "translateX(-50%)",
- WebkitBoxOrient: "vertical",
- WebkitLineClamp: 2,
width: "max-content",
zIndex: 2,
}}
>
- <Box component="span" sx={feedPhotoCaptionBubbleSx}>
- {caption}
- </Box>
+ <SpaceCaptionText caption={caption} lineClamp={2} />
</Box>
);
};