Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update public album CTAs and primary button padding

Anand Baburajane8437c4bac4a
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index d4f4ad742f..c7b09ce8b9 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -477,6 +477,8 @@ export default function PublicCollectionGallery() {
const commentsEnabled =
publicCollection?.publicURLs[0]?.enableComment ?? false;
+ const joinEnabled = publicCollection?.publicURLs[0]?.enableJoin ?? false;
+ const addPhotosEnabled = !!onAddPhotos;
const hasSelection = selected.count > 0;
@@ -605,15 +607,19 @@ export default function PublicCollectionGallery() {
<EnteLogo height={15} />
</EnteLogoLink>
<Stack direction="row" spacing={2}>
- {onAddPhotos && (
- <AddPhotosButton
- onClick={onAddPhotos}
- />
- )}
+ <SecondaryActionButton
+ onAddPhotos={onAddPhotos}
+ enableJoin={joinEnabled}
+ publicCollection={publicCollection}
+ accessToken={
+ credentials.current.accessToken
+ }
+ collectionKey={collectionKey.current}
+ credentials={credentials}
+ />
<PrimaryActionButton
- enableJoin={
- publicCollection?.publicURLs[0]
- ?.enableJoin
+ showJoinAsPrimary={
+ addPhotosEnabled && joinEnabled
}
publicCollection={publicCollection}
accessToken={
@@ -702,6 +708,7 @@ const EnteLogoLink = styled("a")(({ theme }) => ({
const GreenButton = styled(Button)(() => ({
backgroundColor: "#08C225",
borderRadius: "16px",
+ paddingInline: "20px",
"&:hover": { backgroundColor: "#07A820" },
}));
@@ -730,9 +737,9 @@ const AddPhotosButton: React.FC<ButtonishProps> = ({ onClick }) => {
};
interface PrimaryActionButtonProps {
- /** If true, shows "Join Album" button instead of "Sign Up" */
- enableJoin?: boolean;
- /** Collection to join (required if enableJoin is true) */
+ /** If true, shows "Join Album" as the primary action */
+ showJoinAsPrimary?: boolean;
+ /** Collection to join (required if showJoinAsPrimary is true) */
publicCollection?: Collection;
/** Access token for the public link */
accessToken?: string;
@@ -743,7 +750,7 @@ interface PrimaryActionButtonProps {
}
const PrimaryActionButton: React.FC<PrimaryActionButtonProps> = ({
- enableJoin,
+ showJoinAsPrimary,
publicCollection,
accessToken,
collectionKey,
@@ -757,7 +764,7 @@ const PrimaryActionButton: React.FC<PrimaryActionButtonProps> = ({
credentials,
});
- if (enableJoin) {
+ if (showJoinAsPrimary) {
return (
<GreenButton color="accent" onClick={handleJoinAlbum}>
{t("join_album")}
@@ -776,6 +783,49 @@ const PrimaryActionButton: React.FC<PrimaryActionButtonProps> = ({
);
};
+interface SecondaryActionButtonProps {
+ onAddPhotos?: () => void;
+ enableJoin?: boolean;
+ publicCollection?: Collection;
+ accessToken?: string;
+ collectionKey?: string;
+ credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
+}
+
+const SecondaryActionButton: React.FC<SecondaryActionButtonProps> = ({
+ onAddPhotos,
+ enableJoin,
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+}) => {
+ const { handleJoinAlbum } = useJoinAlbum({
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+ });
+
+ if (onAddPhotos) {
+ return <AddPhotosButton onClick={onAddPhotos} />;
+ }
+
+ if (enableJoin) {
+ return (
+ <FocusVisibleButton
+ color="secondary"
+ sx={{ borderRadius: "16px" }}
+ onClick={handleJoinAlbum}
+ >
+ {t("join_album")}
+ </FocusVisibleButton>
+ );
+ }
+
+ return null;
+};
+
interface SelectedFileOptionsProps {
count: number;
clearSelection: () => void;