@@ -11,7 +11,7 @@ import { saveBookmarkToStore } from "@/redux/reducers/bookmarkReducer";
1111import { toastify } from "@/helper/toastify" ;
1212import { addComment } from "@/backend/posts.api" ;
1313import { getUserDetails } from "@/backend/auth.api" ;
14- import { useCallback , useEffect , useState , MouseEvent } from "react" ;
14+ import { useCallback , useEffect , useState , MouseEvent } from "react" ;
1515import { UserBookMarkType , FormatOnType } from "@/types/index" ;
1616import isCtrlEnter from "@/helper/isCtrlEnter" ;
1717
@@ -148,35 +148,38 @@ export default function SinglePost({
148148 fetchUserDetails ( ) ;
149149 } , [ fetchUserDetails ] ) ;
150150
151- const handleClick = ( e :MouseEvent < HTMLDivElement | HTMLSpanElement > ) => {
151+ const handleClick = ( e : MouseEvent < HTMLDivElement | HTMLSpanElement > ) => {
152152 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 ) {
156156 currentSelectedElement = spanElement ;
157- } else {
157+ } else {
158158 currentSelectedElement = element ;
159159 }
160- if ( currentSelectedElement && currentSelectedElement . textContent ) {
160+ if ( currentSelectedElement && currentSelectedElement . textContent ) {
161161 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 ) ;
176179 }
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 ) ;
180183
181184 return (
182185 < div
@@ -224,7 +227,7 @@ export default function SinglePost({
224227 ) : null }
225228 </ Link >
226229
227- { colors && Object . keys ( colors ) . length > 0 ? (
230+ { colors && Object . keys ( colors ) . length > 0 ? (
228231 < div className = "my-2 flex flex-row justify-between items-center w-full" >
229232 { /* {JSON.parse(singlePost.colors).map((color: string, index: number) => {
230233 return (
@@ -240,32 +243,51 @@ export default function SinglePost({
240243 }) } */ }
241244 < div className = "w-full h-[200px] bg-tranparent mx-auto flex mb-3.5 gap-1" >
242245 < 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 }
246251 >
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 >
248258 </ div >
249259 < 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 }
253265 >
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 >
255269 </ div >
256270 < 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 }
260276 >
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 >
262280 </ div >
263281 < 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 }
267287 >
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 >
269291 </ div >
270292 </ div >
271293 </ div >
0 commit comments