Skip to content

Commit

Permalink
hearts update
Browse files Browse the repository at this point in the history
  • Loading branch information
wojnet committed Oct 20, 2023
1 parent f3e7b56 commit c40f82f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/assets/heart-icons/heart-icon-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/assets/heart-icons/heart-icon-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/assets/heart-icons/heart-icon-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/features/posts/ArticleHeartIcon.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import HeartIconBlack from "../../assets/heart-icons/heart-icon-black.svg";
import HeartIconWhite from "../../assets/heart-icons/heart-icon-white.svg";
import HeartIconRed from "../../assets/heart-icons/heart-icon-red.svg";
import { useState } from "react";
import { useEffect } from "react";
import { useSelector } from "react-redux";

const ArticleHeartIcon = ({ number, click, isLiked, addedLikes, hasChangedLikes }) => {
const theme = useSelector(state => state.global.theme);

const likedStyle = {
color: "var(--heartColor)"
}
Expand All @@ -10,7 +19,8 @@ const ArticleHeartIcon = ({ number, click, isLiked, addedLikes, hasChangedLikes

return(
<div style={{ WebkitUserSelect: "none", msUserSelect: "none", userSelect: "none" }} className="ArticleHeartIcon" onClick={click}>
<span style={isLiked ? hasChangedLikes ? defaultStyle : likedStyle : hasChangedLikes ? likedStyle : defaultStyle}></span>
{/* <span style={isLiked ? hasChangedLikes ? defaultStyle : likedStyle : hasChangedLikes ? likedStyle : defaultStyle}>❤</span> */}
<img src={isLiked ? hasChangedLikes ? theme === "dark" ? HeartIconWhite : HeartIconBlack : HeartIconRed : hasChangedLikes ? HeartIconRed : theme === "dark" ? HeartIconWhite : HeartIconBlack} alt="heart icon" />
<p style={{ pointerEvents: "none" }}>{number !== undefined ? number + addedLikes : "NaN"}</p>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions src/features/posts/postsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const postsSlice = createSlice({
tempPosts[postIndex].addedLikes = action.payload.number;

state.posts = tempPosts;
},
unlikePosts: (state) => {

}
},
extraReducers(builder) {
Expand Down
3 changes: 3 additions & 0 deletions src/features/profile/profileSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ const profileSlice = createSlice({
tempPosts[postIndex].addedLikes = action.payload.number;

state.posts = tempPosts;
},
unlikePosts: (state) => {

}
},
extraReducers(builder) {
Expand Down
8 changes: 8 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,20 @@ input, textarea {
padding: 1px 5px;
border-radius: 5px;
cursor: pointer;
align-items: center;
}

.ArticleHeartIcon > img {
height: 14px;
opacity: 0.6;
/* mix-blend-mode: color-dodge; */
}

.CommentsIcon {
color: var(--black);
margin-top: 15px;
display: flex;
align-items: center;
gap: 10px;
/* background: var(--lightGray); */
padding: 1px 5px;
Expand Down

0 comments on commit c40f82f

Please sign in to comment.