@@ -11,7 +11,7 @@ import { saveBookmarkToStore } from "@/redux/reducers/bookmarkReducer";
11
11
import { toastify } from "@/helper/toastify" ;
12
12
import { addComment } from "@/backend/posts.api" ;
13
13
import { getUserDetails } from "@/backend/auth.api" ;
14
- import { useCallback , useEffect , useState , MouseEvent } from "react" ;
14
+ import { useCallback , useEffect , useState , MouseEvent } from "react" ;
15
15
import { UserBookMarkType , FormatOnType } from "@/types/index" ;
16
16
import isCtrlEnter from "@/helper/isCtrlEnter" ;
17
17
@@ -148,35 +148,38 @@ export default function SinglePost({
148
148
fetchUserDetails ( ) ;
149
149
} , [ fetchUserDetails ] ) ;
150
150
151
- const handleClick = ( e :MouseEvent < HTMLDivElement | HTMLSpanElement > ) => {
151
+ const handleClick = ( e : MouseEvent < HTMLDivElement | HTMLSpanElement > ) => {
152
152
const element = e . target as HTMLDivElement | HTMLSpanElement ;
153
- const spanElement = element . querySelector ( ' span' ) ;
154
- let currentSelectedElement :HTMLSpanElement | HTMLDivElement | null = null ;
155
- if ( spanElement ) {
153
+ const spanElement = element . querySelector ( " span" ) ;
154
+ let currentSelectedElement : HTMLSpanElement | HTMLDivElement | null = null ;
155
+ if ( spanElement ) {
156
156
currentSelectedElement = spanElement ;
157
- } else {
157
+ } else {
158
158
currentSelectedElement = element ;
159
159
}
160
- if ( currentSelectedElement && currentSelectedElement . textContent ) {
160
+ if ( currentSelectedElement && currentSelectedElement . textContent ) {
161
161
const prevValue = currentSelectedElement . textContent ;
162
- navigator . clipboard . writeText ( currentSelectedElement . textContent ) . then ( ( ) => {
163
- if ( currentSelectedElement ) {
164
- currentSelectedElement . textContent = 'Copied' ;
165
- currentSelectedElement . classList . remove ( 'bg-slate-950/[0.4]' ) ;
166
- currentSelectedElement . classList . add ( 'bg-black' ) ;
167
- setTimeout ( ( ) => {
168
- if ( currentSelectedElement ) {
169
- currentSelectedElement . textContent = prevValue ;
170
- currentSelectedElement . classList . remove ( 'bg-black' ) ;
171
- currentSelectedElement . classList . add ( 'bg-slate-950/[0.4]' ) ;
172
- }
173
- } , 1000 ) ;
174
- }
175
- } ) . catch ( console . log )
162
+ navigator . clipboard
163
+ . writeText ( currentSelectedElement . textContent )
164
+ . then ( ( ) => {
165
+ if ( currentSelectedElement ) {
166
+ currentSelectedElement . textContent = "Copied" ;
167
+ currentSelectedElement . classList . remove ( "bg-slate-950/[0.4]" ) ;
168
+ currentSelectedElement . classList . add ( "bg-black" ) ;
169
+ setTimeout ( ( ) => {
170
+ if ( currentSelectedElement ) {
171
+ currentSelectedElement . textContent = prevValue ;
172
+ currentSelectedElement . classList . remove ( "bg-black" ) ;
173
+ currentSelectedElement . classList . add ( "bg-slate-950/[0.4]" ) ;
174
+ }
175
+ } , 1000 ) ;
176
+ }
177
+ } )
178
+ . catch ( console . log ) ;
176
179
}
177
-
178
- }
179
- const colors = singlePost ?. colors && typeof singlePost ?. colors === ' string' && JSON . parse ( singlePost . colors )
180
+ } ;
181
+ const colors =
182
+ singlePost ?. colors && typeof singlePost ?. colors === " string" && JSON . parse ( singlePost . colors ) ;
180
183
181
184
return (
182
185
< div
@@ -224,7 +227,7 @@ export default function SinglePost({
224
227
) : null }
225
228
</ Link >
226
229
227
- { colors && Object . keys ( colors ) . length > 0 ? (
230
+ { colors && Object . keys ( colors ) . length > 0 ? (
228
231
< div className = "my-2 flex flex-row justify-between items-center w-full" >
229
232
{ /* {JSON.parse(singlePost.colors).map((color: string, index: number) => {
230
233
return (
@@ -240,32 +243,51 @@ export default function SinglePost({
240
243
}) } */ }
241
244
< div className = "w-full h-[200px] bg-tranparent mx-auto flex mb-3.5 gap-1" >
242
245
< div
243
- className = "cursor-pointer w-full flex justify-center items-center group"
244
- style = { { backgroundColor :typeof colors . color01 === 'string' && colors . color01 || '' } }
245
- onClick = { handleClick }
246
+ className = "cursor-pointer w-full flex justify-center items-center group"
247
+ style = { {
248
+ backgroundColor : ( typeof colors . color01 === "string" && colors . color01 ) || "" ,
249
+ } }
250
+ onClick = { handleClick }
246
251
>
247
- < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" onClick = { handleClick } > { colors . color01 } </ span >
252
+ < span
253
+ className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110"
254
+ onClick = { handleClick }
255
+ >
256
+ { colors . color01 }
257
+ </ span >
248
258
</ div >
249
259
< div
250
- className = "cursor-pointer w-full flex justify-center items-center group "
251
- style = { { backgroundColor :typeof colors . color02 === 'string' && colors . color02 || '' } }
252
- onClick = { handleClick }
260
+ className = "cursor-pointer w-full flex justify-center items-center group "
261
+ style = { {
262
+ backgroundColor : ( typeof colors . color02 === "string" && colors . color02 ) || "" ,
263
+ } }
264
+ onClick = { handleClick }
253
265
>
254
- < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" > { colors . color02 } </ span >
266
+ < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" >
267
+ { colors . color02 }
268
+ </ span >
255
269
</ div >
256
270
< div
257
- className = "cursor-pointer w-full flex justify-center items-center group gap-2"
258
- style = { { backgroundColor :typeof colors . color03 === 'string' && colors . color03 || '' } }
259
- onClick = { handleClick }
271
+ className = "cursor-pointer w-full flex justify-center items-center group gap-2"
272
+ style = { {
273
+ backgroundColor : ( typeof colors . color03 === "string" && colors . color03 ) || "" ,
274
+ } }
275
+ onClick = { handleClick }
260
276
>
261
- < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" > { colors . color03 } </ span >
277
+ < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" >
278
+ { colors . color03 }
279
+ </ span >
262
280
</ div >
263
281
< div
264
- className = "cursor-pointer w-full flex justify-center items-center group"
265
- style = { { backgroundColor :typeof colors . color04 === 'string' && colors . color04 || '' } }
266
- onClick = { handleClick }
282
+ className = "cursor-pointer w-full flex justify-center items-center group"
283
+ style = { {
284
+ backgroundColor : ( typeof colors . color04 === "string" && colors . color04 ) || "" ,
285
+ } }
286
+ onClick = { handleClick }
267
287
>
268
- < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" > { colors . color04 } </ span >
288
+ < span className = "bg-slate-950/[0.4] text-xs px-0.5 opacity-0 transition ease-out duration-300 group-hover:opacity-100 group-hover:ease-in group-hover:scale-110" >
289
+ { colors . color04 }
290
+ </ span >
269
291
</ div >
270
292
</ div >
271
293
</ div >
0 commit comments