6
6
MenuButton ,
7
7
MenuItem ,
8
8
MenuList ,
9
+ Skeleton ,
9
10
Text ,
10
11
} from "@chakra-ui/react" ;
11
12
import React , { Fragment , useEffect , useState } from "react" ;
@@ -32,9 +33,11 @@ const TrendingItem = ({
32
33
savePost,
33
34
auth,
34
35
getSavedPosts,
36
+ forComp,
35
37
} ) => {
36
38
const [ loadingUNI , setLoadingUNI ] = useState ( true ) ;
37
39
const [ styleForHeading , setStyleForHeading ] = useState ( { } ) ;
40
+ const [ imageLoaded , setImageLoaded ] = useState ( false ) ;
38
41
39
42
useEffect ( ( ) => {
40
43
if ( status === "" && auth . isAuthenticated ) {
@@ -102,23 +105,38 @@ const TrendingItem = ({
102
105
cursor = "pointer"
103
106
rounded = "md"
104
107
border = "2px solid #a6a6a690"
105
- w = " 100%"
108
+ w = { forComp === "user-post" ? " 100%" : "350px" }
106
109
maxWidth = "350px"
107
110
>
108
- < Flex onClick = { post !== undefined ? openPost : null } >
111
+ < Flex
112
+ onClick = { post !== undefined ? openPost : null }
113
+ w = { forComp === "user-post" ? "100%" : "350px" }
114
+ h = "170px"
115
+ maxWidth = "350px"
116
+ >
117
+ { ! imageLoaded && (
118
+ < Skeleton
119
+ w = { forComp === "user-post" ? "100%" : "350px" }
120
+ h = "170px"
121
+ maxW = "346px"
122
+ > </ Skeleton >
123
+ ) }
109
124
< Image
110
125
src = { post && post . image }
111
126
fallbackSrc = "https://i.ibb.co/RBT25fY/default-fallback-image.png"
112
- w = " 100%"
127
+ w = { forComp === "user-post" ? " 100%" : "346px" }
113
128
h = "170px"
114
129
objectFit = "cover"
115
130
alt = "post"
116
131
borderTopLeftRadius = "5px"
117
132
borderTopRightRadius = "5px"
133
+ onLoad = { ( ) => setImageLoaded ( true ) }
134
+ display = { imageLoaded ? "" : "none" }
135
+ maxWidth = "346px"
118
136
/>
119
137
</ Flex >
120
138
{ loadingUNI && < PostPlaceHolder /> }
121
- { post !== undefined && (
139
+ { post !== undefined ? (
122
140
< Flex
123
141
style = { styleForHeading }
124
142
justifyContent = "space-between"
@@ -134,16 +152,20 @@ const TrendingItem = ({
134
152
</ Text >
135
153
< Flex alignItems = "center" mt = "10px" >
136
154
< Text > { post . name } </ Text >
137
- < span
138
- style = { {
139
- width : "5px" ,
140
- height : "5px" ,
141
- borderRadius : "100%" ,
142
- backgroundColor : "#eee" ,
143
- margin : "0 4px 0 4px" ,
144
- } }
145
- > </ span >
146
- < Text > 7 min</ Text >
155
+ { forComp !== "saved" && (
156
+ < Fragment >
157
+ < span
158
+ style = { {
159
+ width : "5px" ,
160
+ height : "5px" ,
161
+ borderRadius : "100%" ,
162
+ backgroundColor : "#eee" ,
163
+ margin : "0 4px 0 4px" ,
164
+ } }
165
+ > </ span >
166
+ < Text > 7 min</ Text >
167
+ </ Fragment >
168
+ ) }
147
169
</ Flex >
148
170
</ Flex >
149
171
< Flex flexDir = "column" alignItems = "center" alignSelf = "center" >
@@ -154,7 +176,7 @@ const TrendingItem = ({
154
176
{ adminPrivilages . postAccessibility && (
155
177
< Fragment >
156
178
< Flex mt = "10px" className = "admin-post-drop" >
157
- < Menu >
179
+ < Menu isLazy >
158
180
< MenuButton
159
181
as = { Flex }
160
182
w = "20px"
@@ -176,6 +198,18 @@ const TrendingItem = ({
176
198
) }
177
199
</ Flex >
178
200
</ Flex >
201
+ ) : (
202
+ < Flex
203
+ style = { styleForHeading }
204
+ justifyContent = "space-between"
205
+ px = "10px"
206
+ py = "5px"
207
+ bg = "#2a2c33"
208
+ flexDir = "column"
209
+ >
210
+ < Skeleton my = "0.2rem" h = "25px" w = "240px" > </ Skeleton >
211
+ < Skeleton my = "0.2rem" h = "20px" w = "100px" > </ Skeleton >
212
+ </ Flex >
179
213
) }
180
214
</ Flex >
181
215
) ;
0 commit comments