Skip to content

Commit

Permalink
like animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashishjain04 committed May 21, 2021
1 parent 05c555a commit 419887a
Show file tree
Hide file tree
Showing 80 changed files with 78 additions and 61 deletions.
Empty file modified .firebaserc
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified craco.config.js
100644 → 100755
Empty file.
Empty file modified firebase.json
100644 → 100755
Empty file.
Empty file modified firestore.indexes.json
100644 → 100755
Empty file.
Empty file modified firestore.rules
100644 → 100755
Empty file.
Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified public/images/apple-icon-180.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1125-2436.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1136-640.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1170-2532.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1242-2208.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1242-2688.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1284-2778.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1334-750.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1536-2048.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1620-2160.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1668-2224.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1668-2388.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-1792-828.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2048-1536.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2048-2732.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2160-1620.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2208-1242.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2224-1668.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2388-1668.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2436-1125.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2532-1170.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2688-1242.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2732-2048.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-2778-1284.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-640-1136.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/images/apple-splash-750-1334.jpg
100644 → 100755
Empty file modified public/images/apple-splash-828-1792.jpg
100644 → 100755
Empty file modified public/images/logo-text.png
100644 → 100755
Empty file modified public/images/logo.png
100644 → 100755
Empty file modified public/images/manifest-icon-192.png
100644 → 100755
Empty file modified public/images/manifest-icon-512.png
100644 → 100755
Empty file modified public/index.html
100644 → 100755
Empty file.
Empty file modified public/manifest.json
100644 → 100755
Empty file.
Empty file modified public/robots.txt
100644 → 100755
Empty file.
Empty file modified public/screenshots/ss1.png
100644 → 100755
Empty file modified public/screenshots/ss2.png
100644 → 100755
Empty file modified public/screenshots/ss3.png
100644 → 100755
Empty file modified src/App.js
100644 → 100755
Empty file.
Empty file modified src/components/ChatForm.js
100644 → 100755
Empty file.
Empty file modified src/components/ChatMessages.js
100644 → 100755
Empty file.
Empty file modified src/components/Loading/Nav.js
100644 → 100755
Empty file.
Empty file modified src/components/Loading/NewPost.js
100644 → 100755
Empty file.
Empty file modified src/components/Loading/PostCard.js
100644 → 100755
Empty file.
Empty file modified src/components/Loading/Stories.js
100644 → 100755
Empty file.
Empty file modified src/components/Nav.js
100644 → 100755
Empty file.
Empty file modified src/components/NewPost.js
100644 → 100755
Empty file.
Empty file modified src/components/NewStory.js
100644 → 100755
Empty file.
56 changes: 39 additions & 17 deletions src/components/PostCard.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ const db = firebase.firestore;
const PostCard = ({ post, id }) => {
const user = useSelector(selectUser),
[comment, setComment] = useState(""),
[imgLoaded, setImgLoaded] = useState(post.image === "");
[imgLoaded, setImgLoaded] = useState(post.image === ""),
[likeAnimate, setLikeAnimate] = useState(false);

const likeHandler = () => {
db()
.doc(`posts/${id}`)
.update({
likes: db.FieldValue.arrayUnion(user.email),
})
.then(() => {
setLikeAnimate(true);
setTimeout(() => {
setLikeAnimate(false);
}, 1000);
});
};
const unlikeHandler = () => {
Expand Down Expand Up @@ -58,12 +65,16 @@ const PostCard = ({ post, id }) => {

useEffect(() => {
post.image && loadImage(post.image);
return () => {
setLikeAnimate(false);
};
}, [post]);

return !imgLoaded ? (
<LoadingPostCard />
) : (
<div className="bg-white my-2 sm:border sm:border-gray-300 rounded-md">
<div className="bg-white my-2 sm:border sm:border-gray-300 rounded-md relative">
{/* header */}
<div className="flex items-center px-4 py-2">
<Link
to={
Expand All @@ -80,21 +91,28 @@ const PostCard = ({ post, id }) => {
</Link>
<p className="text-lg font-semibold">{post.user?.name}</p>
</div>
{post.image ? (
<img
onDoubleClick={likeHandler}
src={post.image}
alt="post"
className="w-full border-t border-b cursor-pointer"
/>
) : (
<p
onDoubleClick={likeHandler}
className="p-4 border-t border-b cursor-pointer"
>
{post.text}
</p>
)}
{/* main content */}
<div className="border-t border-b cursot-pointer relative">
{/* heart */}
{likeAnimate && (
<div className="heart-container absolute top-0 left-0 z-10 w-full h-full grid place-items-center">
<i className="bx bxs-heart text-white text-9xl instagram-heart" />
</div>
)}
{post.image ? (
<img
onDoubleClick={likeHandler}
src={post.image}
alt="post"
className="w-full"
/>
) : (
<p onDoubleClick={likeHandler} className="p-4">
{post.text}
</p>
)}
</div>
{/* like btn */}
<div className="flex space-x-4 px-4 mt-1">
{post.likes.includes(user.email) ? (
<i
Expand All @@ -107,18 +125,21 @@ const PostCard = ({ post, id }) => {
onClick={likeHandler}
/>
)}
{/* other action btns */}
<i className="bx bx-comment post-action-btn" />
<i className="bx bx-share post-action-btn" />
</div>
<p className="px-4 mb-2 font-semibold text-sm">
{post.likes?.length} likes
</p>
{/* if image post: caption */}
{post.image && (
<p className="px-4 mb-2 -mt-2 line-clamp-1">
<span className="font-semibold">{post.user.name}: </span>
<span className="break-all">{post.text}</span>
</p>
)}
{/* comments */}
{post.comments?.length !== 0 && (
<p className="px-4 -mt-2 mb-2 text-sm text-gray-500">Comments</p>
)}
Expand All @@ -128,6 +149,7 @@ const PostCard = ({ post, id }) => {
<span className="break-all">{comment.comment}</span>
</p>
))}
{/* add comment */}
<form className="border-t flex" onSubmit={commentHandler}>
<input
type="text"
Expand Down
Empty file modified src/components/Posts.js
100644 → 100755
Empty file.
Empty file modified src/components/ProfileHeader.js
100644 → 100755
Empty file.
Empty file modified src/components/ProfilePosts.js
100644 → 100755
Empty file.
58 changes: 14 additions & 44 deletions src/components/Stories.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,55 +1,25 @@
import React from "react";
import { useSelector } from "react-redux";
import { selectUser } from "../redux/userSlice";
import NewStory from "./NewStory";
import StoryCard from "./StoryCard";

const Stories = () => {
const user = useSelector(selectUser);
return (
<ul className="stories">
<NewStory />
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard
image="https://lh3.googleusercontent.com/a-/AOh14GhfgSuVig-RNSusuO5_kYuCKLZEBIbxvssam3e8ng=s96-c"
userName="Kashish_jain04"
/>
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
<StoryCard image={user.photoURL} userName="Kashish_jain04" />
</ul>
);
};
Expand Down
Empty file modified src/components/StoryCard.js
100644 → 100755
Empty file.
Empty file modified src/components/StoryImage.js
100644 → 100755
Empty file.
Empty file modified src/components/UserHeader.js
100644 → 100755
Empty file.
Empty file modified src/hooks/OutsideAlerter.js
100644 → 100755
Empty file.
25 changes: 25 additions & 0 deletions src/index.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,28 @@
* {
-webkit-tap-highlight-color: transparent;
}

.instagram-heart {
animation-duration: 1000ms;
animation-name: like-heart-animation;
animation-timing-function: ease-in-out;
}

@keyframes like-heart-animation {
0% {
opacity: 0;
transform: scale(0);
}
15% {
opacity: 0.9;
transform: scale(1.2);
}
30% {
transform: scale(0.95);
}
45%,
80% {
opacity: 0.9;
transform: scale(1);
}
}
Empty file modified src/index.js
100644 → 100755
Empty file.
Empty file modified src/pages/Chat.js
100644 → 100755
Empty file.
Empty file modified src/pages/Chats.js
100644 → 100755
Empty file.
Empty file modified src/pages/Home.js
100644 → 100755
Empty file.
Empty file modified src/pages/LoadingHome.js
100644 → 100755
Empty file.
Empty file modified src/pages/Login.js
100644 → 100755
Empty file.
Empty file modified src/pages/Profile.js
100644 → 100755
Empty file.
Empty file modified src/pages/User.js
100644 → 100755
Empty file.
Empty file modified src/redux/store.js
100644 → 100755
Empty file.
Empty file modified src/redux/userSlice.js
100644 → 100755
Empty file.
Empty file modified src/service-worker.js
100644 → 100755
Empty file.
Empty file modified src/serviceWorkerRegistration.js
100644 → 100755
Empty file.
Empty file modified storage.rules
100644 → 100755
Empty file.
Empty file modified tailwind.config.js
100644 → 100755
Empty file.
Empty file modified yarn.lock
100644 → 100755
Empty file.

0 comments on commit 419887a

Please sign in to comment.