Skip to content

Commit

Permalink
redirect + notifications state handle
Browse files Browse the repository at this point in the history
  • Loading branch information
JW-Rami committed Aug 20, 2023
1 parent a112305 commit db0ea1a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 27 deletions.
2 changes: 1 addition & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function App() {
function handleClickOutside(e) {
// Navbar
if (e.target.id === "navbar-user-profile-img") {
setIsProfileClicked(true);
setIsProfileClicked(!isProfileClicked);
} else {
setIsProfileClicked(false);
}
Expand Down
10 changes: 10 additions & 0 deletions client/src/Components/Navbar/NavIcon/NavIcon.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
padding-left: 10px;
padding-right: 10px;
/* padding: 8px; */
position: relative;
}
.navbar-icon-container:hover {
background-color: #00000015;
Expand All @@ -14,3 +15,12 @@
width: 20px;
cursor: pointer;
}
.navbar-icon-notifications-red-round{
background-color: red;
border-radius: 50%;
width: 7px;
height: 7px;
position: absolute;
top: 20%;
right: 25%;
}
7 changes: 6 additions & 1 deletion client/src/Components/Navbar/NavIcon/NavIcon.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import React from "react";
import "./NavIcon.css";

const NavIcon = ({ src, handleNotificationPopup }) => {
const NavIcon = ({ src, handleNotificationPopup, isNotificationsRead }) => {
return (
<div onClick={handleNotificationPopup} className="navbar-icon-container">
<img
className="navbar-icon"
src={src}
alt={`${src.split("/").pop().split(".")[0]}`}
/>
{!isNotificationsRead && (
<>
<div className="navbar-icon-notifications-red-round"></div>
</>
)}
</div>
);
};
Expand Down
21 changes: 9 additions & 12 deletions client/src/Components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Navbar = ({
const handlePixelScrolledAthleteProfilePage = () => {
setPixelScrolledAthleteProfilePage(window.scrollY);
};
const [isNotificationsRead, setIsNotificationsRead] = useState(false);
const navigate = useNavigate();

function handleSignInButtonClick() {
Expand All @@ -52,19 +53,14 @@ const Navbar = ({
handlePixelScrolledAthleteProfilePage,
false
);


}, [])
}, []);
useEffect(() => {

if (isSignInButtonClicked || isSignUpButtonClicked) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}

}, [isSignInButtonClicked, isSignUpButtonClicked])

if (isSignInButtonClicked || isSignUpButtonClicked) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "auto";
}
}, [isSignInButtonClicked, isSignUpButtonClicked]);

const handlePopoUpSignInSignUpClick = () => {
setIsSignInButtonClicked(false);
Expand Down Expand Up @@ -113,6 +109,7 @@ const Navbar = ({
<div className="navbar-wrap-2-navicon-wrap">
<div className="navbar-vertical"></div>
<NavIcon
isNotificationsRead={isNotificationsRead}
handleNotificationPopup={handleNotificationPopup}
src={notification}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
max-width: 30px;
max-height: 30px;
border-radius: 30px;
border: solid 2px white;
}
.posts-comments-component-profile-pic-container img:hover {
border: solid 2px rgba(0, 0, 0, 0.466);
cursor: pointer;
transition-duration: 500ms;
}
.posts-comments-component-right-container {
width: 100%;
Expand All @@ -26,6 +32,10 @@
font-size: 16px;
font-family: "britanica-heavy";
}
.posts-comments-component-username:hover {
text-decoration: underline;
cursor: pointer;
}
.posts-comments-component-comments {
font-size: 14px;
margin-top: 5px;
Expand Down Expand Up @@ -80,17 +90,17 @@
height: 20px;
/* background-color: burlywood; */
}
@media (max-height:900px) {
.posts-comments-component-comments-like-and-timestamp{
@media (max-height: 900px) {
.posts-comments-component-comments-like-and-timestamp {
padding-top: 5px;
}
}
@media (max-width: 1450px) {
.posts-comments-component-comments{
.posts-comments-component-comments {
font-size: 12px;
margin-top: 2px;
}
.posts-comments-component-username{
.posts-comments-component-username {
font-size: 14px;
}
.posts-comments-component-comments-like-and-timestamp {
Expand All @@ -99,30 +109,29 @@
height: 12px;
}
}
@media (max-width:900px) {
@media (max-width: 900px) {
.posts-comments-component-container {
/* background-color: RED; */
/* min-height: 68px; */
/* height: 68px !important; */
/* max-height: 68px !important; */
}
.posts-comments-component-profile-pic-container{
.posts-comments-component-profile-pic-container {
/* background-color: darkblue; */
height: 61px;
}
.posts-comments-component-profile-pic-container img{

.posts-comments-component-profile-pic-container img {
width: 25px;
height: 25px;
max-width: 25px;
max-height: 25px;
}
.posts-comments-component-comments{

.posts-comments-component-comments {
font-size: 10px;
margin-top: 2px;
}
.posts-comments-component-username{
.posts-comments-component-username {
font-size: 12px;
}
.posts-comments-component-comments-like-and-timestamp {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState } from "react";
import "./PostsComments.css";
import "./PostsCommentsNoMediaQueries.css"
import "./PostsCommentsNoMediaQueries.css";
import profilePicFan from "../../../Assets/Image/profilepicmbappecomments.svg";
import LikeButton from "../LikeButton/LikeButton";
import DropDownButtonMenu from "../DropDownButtonMenu/DropDownButtonMenu";
import dropDownImage from "../../../Assets/Image/dropdown.svg";
import DropDownMenu from "../DropDownMenu/DropDownMenu";
import { useNavigate } from "react-router-dom";
function PostsComments({
likeButtonSizePollPost,
postId,
Expand All @@ -26,6 +27,7 @@ function PostsComments({
const [isAthleteLogged, setIsAthleteLogged] = useState();
const [isCommentsOwnerLogged, setisCommentsOwnerLogged] = useState(true);
const [isCommentLiked, setIsCommentLiked] = useState(false);
const navigate = useNavigate();
function handleCommentLike() {
setIsCommentLiked(!isCommentLiked);
}
Expand All @@ -50,7 +52,10 @@ function PostsComments({
}));
console.log(dropdownStates);
}

function redirectToProfileFromComment(e) {
// mettre une condition si le commentaire viens d'un utilisateur ou d'un athlete il faut changer le path
navigate(`/userprofile/`);
}
return (
<>
<div
Expand All @@ -66,6 +71,7 @@ function PostsComments({
? "posts-comments-component-profile-pic-container-no-media-queries"
: "posts-comments-component-profile-pic-container"
}
onClick={redirectToProfileFromComment}
>
<img src={profilePicFan} alt="" />
</div>
Expand All @@ -89,6 +95,7 @@ function PostsComments({
? "posts-comments-component-username-no-media-queries"
: "posts-comments-component-username"
}
onClick={redirectToProfileFromComment}
>
DonOfSomething
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
max-width: 30px;
max-height: 30px;
border-radius: 30px;
border: solid 2px white;
}
.posts-comments-component-profile-pic-container-no-media-queries img:hover {
border: solid 2px rgba(0, 0, 0, 0.466);
cursor: pointer;
transition-duration: 500ms;
}
.posts-comments-component-right-container-no-media-queries {
width: 100%;
Expand All @@ -30,6 +36,10 @@
font-size: 16px;
font-family: "britanica-heavy";
}
.posts-comments-component-username-no-media-queries:hover {
text-decoration: underline;
cursor: pointer;
}
.posts-comments-component-comments-no-media-queries {
font-size: 14px;
margin-top: 5px;
Expand Down

0 comments on commit db0ea1a

Please sign in to comment.