Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add Space profile post FAB

Anand Baburajan2a6a491a48b9
diff --git a/web/apps/space/src/components/SpacePostFloatingActionButton.tsx b/web/apps/space/src/components/SpacePostFloatingActionButton.tsx
new file mode 100644
index 0000000000..ae08984e9c
--- /dev/null
+++ b/web/apps/space/src/components/SpacePostFloatingActionButton.tsx
@@ -0,0 +1,65 @@
+import { Add01Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Box } from "@mui/material";
+import React from "react";
+
+const green = "#08C225";
+const paleGreen = "#E7F6E9";
+const buttonSize = 64;
+const iconSize = 34;
+
+interface SpacePostFloatingActionButtonProps {
+ disabled?: boolean;
+ onClick?: () => void;
+}
+
+export const SpacePostFloatingActionButton: React.FC<
+ SpacePostFloatingActionButtonProps
+> = ({ disabled = false, onClick }) => (
+ <Box
+ className="green-bg"
+ component="button"
+ type="button"
+ aria-label="Post photo"
+ disabled={disabled}
+ onClick={onClick}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: green,
+ border: 0,
+ borderRadius: "50%",
+ bottom: "calc(env(safe-area-inset-bottom) + 20px)",
+ boxShadow: "0 10px 24px rgba(0, 0, 0, 0.22)",
+ color: "#FFFFFF",
+ cursor: disabled ? "default" : "pointer",
+ display: "flex",
+ fontSize: 0,
+ height: buttonSize,
+ justifyContent: "center",
+ lineHeight: 0,
+ opacity: disabled ? 0.72 : 1,
+ p: 0,
+ position: "fixed",
+ right: "max(20px, calc((100vw - 390px) / 2 + 20px))",
+ transition:
+ "background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease",
+ width: buttonSize,
+ zIndex: 5,
+ "& svg": { display: "block" },
+ "&:active": { transform: disabled ? "none" : "translateY(1px)" },
+ "&:focus-visible": {
+ outline: `3px solid ${paleGreen}`,
+ outlineOffset: 3,
+ },
+ "&:hover": {
+ bgcolor: disabled ? green : "#07B422",
+ boxShadow: disabled
+ ? "0 10px 24px rgba(0, 0, 0, 0.22)"
+ : "0 12px 28px rgba(0, 0, 0, 0.26)",
+ },
+ }}
+ >
+ <HugeiconsIcon icon={Add01Icon} size={iconSize} strokeWidth={2.1} />
+ </Box>
+);
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 60557240bd..18e85e5c75 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -1,5 +1,4 @@
import {
- Add01Icon,
BubbleChatIcon,
FavouriteIcon,
MultiplicationSignIcon,
@@ -14,6 +13,7 @@ import {
type SpaceViewerPhoto,
type SpaceViewerPostActionMode,
} from "components/SpaceFileViewer";
+import { SpacePostFloatingActionButton } from "components/SpacePostFloatingActionButton";
import {
spacePostLikeButtonPop,
spacePostLikeHeartPop,
@@ -61,8 +61,6 @@ const headerIconSize = 30;
const headerHideStartY = 96;
const headerScrollDelta = 4;
const headerSideWidth = 32;
-const floatingAddButtonSize = 64;
-const floatingAddIconSize = 34;
const feedLikeActionSize = spaceTouchTargetSize;
const feedActionIconSize = 20;
const feedReplyIconSize = 17;
@@ -2047,64 +2045,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
</Box>
)}
</Box>
- <Box
- className="green-bg"
- 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 10px 24px rgba(0, 0, 0, 0.22)",
- color: "#FFFFFF",
- cursor: isPostPhotoButtonDisabled
- ? "default"
- : "pointer",
- display: "flex",
- fontSize: 0,
- height: floatingAddButtonSize,
- justifyContent: "center",
- lineHeight: 0,
- opacity: isPostPhotoButtonDisabled ? 0.72 : 1,
- p: 0,
- position: "fixed",
- right: "max(20px, calc((100vw - 390px) / 2 + 20px))",
- transition:
- "background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease",
- width: floatingAddButtonSize,
- zIndex: 5,
- "& svg": { display: "block" },
- "&:active": {
- transform: isPostPhotoButtonDisabled
- ? "none"
- : "translateY(1px)",
- },
- "&:focus-visible": {
- outline: `3px solid ${paleGreen}`,
- outlineOffset: 3,
- },
- "&:hover": {
- bgcolor: isPostPhotoButtonDisabled
- ? green
- : "#07B422",
- boxShadow: isPostPhotoButtonDisabled
- ? "0 10px 24px rgba(0, 0, 0, 0.22)"
- : "0 12px 28px rgba(0, 0, 0, 0.26)",
- },
- }}
- >
- <HugeiconsIcon
- icon={Add01Icon}
- size={floatingAddIconSize}
- strokeWidth={2.1}
- />
- </Box>
+ />
{selectedViewer && (
<SpaceFileViewer
focusReplyOnOpen={selectedViewer.focusReplyOnOpen}
diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsx
index 96e4f54cf7..4f73e8ff2d 100644
--- a/web/apps/space/src/screens/ProfileScreen.tsx
+++ b/web/apps/space/src/screens/ProfileScreen.tsx
@@ -12,6 +12,7 @@ import {
type SpaceViewerPhoto,
type SpaceViewerPostActionMode,
} from "components/SpaceFileViewer";
+import { SpacePostFloatingActionButton } from "components/SpacePostFloatingActionButton";
import { EnteLogo } from "ente-base/components/EnteLogo";
import { useBrowserBackClose } from "hooks/useBrowserBackClose";
import React, { useState } from "react";
@@ -1564,6 +1565,12 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
</Box>
)}
</Box>
+ {isOwnerProfile && (
+ <SpacePostFloatingActionButton
+ disabled={isPostPhotoOpening}
+ onClick={openPostPhotoPicker}
+ />
+ )}
{selectedPost && (
<SpaceFileViewer
photo={selectedPost.photo}