1
1
"use client" ;
2
2
3
- import React , { useEffect , useRef , useState } from "react" ;
3
+ import React from "react" ;
4
4
import { ScrollArea } from "@/components/ui/scroll-area" ;
5
5
import { Avatar , AvatarImage } from "@/components/ui/avatar" ;
6
6
import { BanIcon } from "lucide-react" ;
7
7
import { Achievement as PrsimaAchievement } from "@prisma/client" ;
8
8
import { Achievement } from "@/types/achievement" ;
9
- import "../timeline.css" ;
10
9
11
10
interface Props {
12
11
userAchievements : PrsimaAchievement [ ] ;
@@ -34,36 +33,8 @@ export default function AchievementProgress({
34
33
return (
35
34
< ScrollArea className = "rounded-md h-[300px] border-2 border-primary p-4 mt-10" >
36
35
< h3 className = "text-primary font-special" > Achievement Progress</ h3 >
37
- < div className = "timeline " >
36
+ < div className = "relative my-[20px] flex flex-col justify-center items-center " >
38
37
{ updatedAllAch . map ( ( achievement ) => {
39
- const timelineItemRef = useRef < HTMLDivElement > ( null ) ;
40
-
41
- const [ isVisible , setIsVisible ] = useState < boolean > ( false ) ;
42
-
43
- useEffect ( ( ) => {
44
- const observer = new IntersectionObserver (
45
- ( entries ) => {
46
- const [ entry ] = entries ;
47
- setIsVisible ( entry . isIntersecting ) ;
48
- } ,
49
- {
50
- root : null ,
51
- rootMargin : "-20px" ,
52
- threshold : 0.1 , // Adjust this threshold as per your needs
53
- }
54
- ) ;
55
-
56
- if ( timelineItemRef . current ) {
57
- observer . observe ( timelineItemRef . current ) ;
58
- }
59
-
60
- return ( ) => {
61
- if ( timelineItemRef . current ) {
62
- observer . unobserve ( timelineItemRef . current ) ;
63
- }
64
- } ;
65
- } , [ timelineItemRef ] ) ;
66
-
67
38
const isUnlocked = userAchievements . some (
68
39
( userAchievement ) =>
69
40
userAchievement . achievementType === achievement . type
@@ -73,22 +44,28 @@ export default function AchievementProgress({
73
44
74
45
return (
75
46
< div
76
- ref = { timelineItemRef }
77
47
key = { achievement . type }
78
48
id = { itemId }
79
- className = { `timeline-item ${ isUnlocked ? "unlocked" : "locked" } ${
80
- isVisible && "animate-fade"
81
- } shadow-lg shadow-accent opacity-100 `}
49
+ style = {
50
+ isUnlocked
51
+ ? {
52
+ backgroundImage : "var(--achievement-progress-gradient)" ,
53
+ }
54
+ : { }
55
+ }
56
+ className = { `relative h-[62px] p-[3px] mb-[20px] rounded-sm cursor-pointer w-1/2 lg:w-1/4 ${
57
+ isUnlocked ? "animate-gradient bg-achievement" : "bg-red-500"
58
+ } shadow-lg shadow-accent even:ml-[50%] odd:mr-[50%]`}
82
59
>
83
- < div className = "timeline-content " >
60
+ < div className = "flex items-center justify-center text-center w-full h-full bg-accent rounded-md " >
84
61
{ isUnlocked ? (
85
62
< Avatar >
86
63
< AvatarImage src = { achievement . image } />
87
64
</ Avatar >
88
65
) : (
89
66
< BanIcon className = "text-primary" />
90
67
) }
91
- < p > { achievement . name } </ p >
68
+ < p className = "m-0 pl-[3px]" > { achievement . name } </ p >
92
69
</ div >
93
70
</ div >
94
71
) ;
0 commit comments