-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdates.jsx
More file actions
238 lines (234 loc) · 7.28 KB
/
Copy pathupdates.jsx
File metadata and controls
238 lines (234 loc) · 7.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import Image from "next/image";
import { useState, useEffect } from "react";
import UpdatesData from "../../db/updates.json";
import Link from "next/link";
import Follow from "../../db/follow.json";
export default function Updates() {
const [HideUpdates, setHideUpdates] = useState(false);
const displayCard = [
"flex justify-center",
"hidden lg:block",
"hidden xl:block",
"hidden 2xl:block",
"hidden md:block",
];
return (
<>
<button
className={`mb-5 bg-blue-400 font-semibold text-white py-1 px-3 rounded-xl hover:bg-blue-500 hover:motion-safe:duration-500 hover:shadow-lg ${
HideUpdates ? "block" : "hidden"
}`}
onClick={() => {
setHideUpdates(false);
}}
>
Show Updates
</button>
<div
className={`font-semibold mb-10 ${HideUpdates ? "hidden" : "block"}`}
>
<div className="flex justify-between">
<h1>People Updates</h1>
<a
className="font-normal cursor-pointer"
onClick={() => {
setHideUpdates(true);
}}
>
Hide
</a>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6 mt-3">
{UpdatesData.data.map((e) => (
<div key={e.index} className={`${displayCard[e.index]}`}>
{e.index == 4 ? (
<div className="absolute z-20 translate-x-20 h-32 w-52 flex justify-center items-center bg-gradient-to-r from-transparent to-white">
<a className="bg-white px-4 py-1 rounded-full text-gray-600 cursor-pointer">
see more
</a>
</div>
) : (
""
)}
<UpdatesCard
username={e.username}
fullname={e.fullname}
profile_img={e.profil_img}
post1={e.post_img[0]}
post2={e.post_img[1]}
post3={e.post_img[2]}
/>
</div>
))}
</div>
</div>
</>
);
}
const UpdatesCard = ({
username,
fullname,
profile_img,
post1,
post2,
post3,
}) => {
const [Following, setFollowing] = useState(false);
const [Followers, setFollowers] = useState(false);
const [FollowState, setFollowState] = useState(null);
useEffect(() => {
setFollowState(Follow.followings.some((e) => e.username === username));
}, []);
return (
<div className="content pt-2 max-w-max scale-up-hor-left">
<div className="absolute translate-y-2 h-16 w-16 overflow-hidden border-2 border-white rounded-full z-10">
<Link href={`/${username}`}>
<a>
<Image
src={profile_img}
alt={`${username}_profile`}
height={100}
width={100}
blurDataURL="/cdn/webassets/loading.webp"
placeholder="blur"
layout="responsive"
className="object-cover"
/>
</a>
</Link>
</div>
<div className="flex gap-1 pl-8 mb-2">
<div className="h-20 w-20 rounded-md overflow-hidden">
<Link href={`/${username}/${post1.id}`}>
<a>
<Image
src={post1.cdn_img}
alt={`${username}_post1`}
height={100}
width={100}
blurDataURL="/cdn/webassets/loading.webp"
placeholder="blur"
layout="responsive"
className="object-cover"
/>
</a>
</Link>
</div>
<div className="h-20 w-20 rounded-md overflow-hidden">
<Link href={`/${username}/${post2.id}`}>
<a>
<Image
src={post2.cdn_img}
alt={`${username}_post2`}
height={100}
width={100}
blurDataURL="/cdn/webassets/loading.webp"
placeholder="blur"
layout="responsive"
className="object-cover"
/>
</a>
</Link>
</div>
<div className="h-20 w-20 rounded-md overflow-hidden">
<Link href={`/${username}/${post3.id}`}>
<a>
<Image
src={post3.cdn_img}
alt={`${username}_post3`}
height={100}
width={100}
blurDataURL="/cdn/webassets/loading.webp"
placeholder="blur"
layout="responsive"
className="object-cover"
/>
</a>
</Link>
</div>
</div>
<div className="flex justify-between pl-8 text-sm">
<Link href={`/${username}`}>
<a>{fullname}</a>
</Link>
{FollowState ? (
<div className="flex flex-col items-end">
<a
className="text-gray-400 cursor-pointer"
onClick={() => {
setFollowing(Following ? false : true);
}}
>
Following
</a>
<div
className={`${
Following ? "flex" : "hidden"
} absolute translate-y-6 rounded-lg border p-2 bg-white flex-col gap-1 items-center`}
>
<span>Unfollow ?</span>
<div className="flex gap-2">
<button
className="py-1 px-4 rounded-full bg-gray-200 font-semibold"
onClick={() => {
setFollowState(false);
setFollowers(false);
setFollowing(false);
}}
>
Yes
</button>
<button
className="py-1 px-4 rounded-full bg-red-200 font-semibold"
onClick={() => {
setFollowing(false);
}}
>
No
</button>
</div>
</div>
</div>
) : (
<div className="flex flex-col items-end">
<a
className="text-blue-500 cursor-pointer"
onClick={() => {
setFollowers(Followers ? false : true);
}}
>
Follow
</a>
<div
className={`${
Followers ? "flex" : "hidden"
} absolute translate-y-6 rounded-lg border p-2 bg-white flex-col gap-1 items-center`}
>
<span>Follow ?</span>
<div className="flex gap-2">
<button
className="py-1 px-4 rounded-full bg-gray-200 font-semibold"
onClick={() => {
setFollowState(true);
setFollowers(false);
setFollowing(false);
}}
>
Yes
</button>
<button
className="py-1 px-4 rounded-full bg-red-200 font-semibold"
onClick={() => {
setFollowers(false);
}}
>
No
</button>
</div>
</div>
</div>
)}
</div>
</div>
);
};