diff --git a/src/pages/Profile/feed/index.css b/src/pages/Profile/feed/index.css index ec8389e78..2ee6cb31c 100644 --- a/src/pages/Profile/feed/index.css +++ b/src/pages/Profile/feed/index.css @@ -22,9 +22,19 @@ aspect-ratio: 1; padding: 8px; cursor: pointer; + display: flex; + align-items: center; transition: 0.4s ease-in-out; } +.profile_post_sub_container { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + .post_sub_container { width: 100%; height: 100%; @@ -36,6 +46,38 @@ object-fit: cover; } +.profile_post_hover_container { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background: rgba(0,0,0,0.5); + width: 100%; + height: 100%; + display: flex; + justify-content: space-evenly; + align-items: center; +} + +.profile_post_hover_icon{ + transform: scale(1.8); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + transition: 0.2s ease-in-out; + background-color: transparent; + border: none; + color: white !important; + cursor: pointer; +} + +.profile_post_hover_icon:hover { + background: rgba(255, 255, 255, 0.25); + padding: 10px; +} + + @media screen and (min-width: 800px) and (max-width: 1200px) { .profile-feed-main-container { margin-left: 5px; diff --git a/src/pages/Profile/feed/index.jsx b/src/pages/Profile/feed/index.jsx index 61a0220a5..03f741a6d 100644 --- a/src/pages/Profile/feed/index.jsx +++ b/src/pages/Profile/feed/index.jsx @@ -1,59 +1,27 @@ import "./index.css"; +import { useState } from "react"; +import { Link, useNavigate } from "react-router-dom"; import { Box, useMediaQuery } from "@mui/material"; +import { doc, updateDoc } from "firebase/firestore"; +import { + ChatBubbleOutlineRounded, + FavoriteOutlined, + FavoriteBorderOutlined, + ShareOutlined, +} from "@mui/icons-material"; +import { auth, db } from "../../../lib/firebase"; import ErrorBoundary from "../../../reusableComponents/ErrorBoundary"; -import postBg from "../../../assets/postbg.webp"; -import { useNavigate } from "react-router-dom"; +import { ShareModal } from "../../../reusableComponents"; const ProfieFeed = ({ feed }) => { - const navigate = useNavigate(); - const isMobileScreen = useMediaQuery("(max-width: 600px)"); - const isTabScreen = useMediaQuery("(max-width: 950px)"); - return (
{feed.map(({ post, id }) => ( -
navigate(`/dummygram/posts/${id}`)} - > - {post.imageUrl == "" ? ( -
- {post.displayName} - {isMobileScreen ? ( -

- {post.caption.length > 50 - ? post.caption.slice(0, 50) + "..." - : post.caption} -

- ) : isTabScreen ? ( -

- {post.caption.length > 110 - ? post.caption.slice(0, 110) + "..." - : post.caption} -

- ) : ( -

{post.caption}

- )} -
- ) : ( -
- {post.username} -
- )} -
+ ))}
@@ -62,3 +30,128 @@ const ProfieFeed = ({ feed }) => { }; export default ProfieFeed; + +function FeedPostDisplay({ post, id }) { + const navigate = useNavigate(); + const [hover, setHover] = useState(false); + const [openShareModal, setOpenShareModal] = useState(false); + const [tempLikeCount, setTempLikeCount] = useState(post.likecount || []); + const userUid = auth?.currentUser?.uid; + + const isMobileScreen = useMediaQuery("(max-width: 600px)"); + const isTabScreen = useMediaQuery("(max-width: 950px)"); + const defaultBg = `linear-gradient(130deg, #dee2ed, #dee2ed, #9aa9d1, #b6c8e3, #b6afd0, #d3c0d8)`; + + async function likesHandler() { + if (userUid && post.likecount !== undefined) { + let ind = post.likecount.indexOf(userUid); + const tempArr = tempLikeCount; + + if (ind !== -1) { + tempArr.splice(ind, 1); + setTempLikeCount(tempArr); + } else { + tempArr.push(userUid); + setTempLikeCount(tempArr); + } + + const data = { + likecount: tempArr, + }; + const docRef = doc(db, "posts", id); + await updateDoc(docRef, data).catch((error) => { + console.error("Error", error); + }); + } + } + + return ( +
navigate(`/dummygram/posts/${id}`)} + onMouseEnter={() => setHover(true)} + onMouseLeave={() => setHover(false)} + > + {post.imageUrl == "" ? ( +
+ {isMobileScreen ? ( +

+ {post.caption.length > 50 + ? post.caption.slice(0, 50) + "..." + : post.caption} +

+ ) : isTabScreen ? ( +

+ {post.caption.length > 110 + ? post.caption.slice(0, 110) + "..." + : post.caption} +

+ ) : ( +

{post.caption}

+ )} +
+ ) : ( +
+ {post.username} +
+ )} + + {hover && ( +
+ + + + + +
+ )} + + {openShareModal && ( + + )} +
+ ); +}