1
1
import { env } from 'env.mjs' ;
2
2
import { CldImage , getCldImageUrl } from 'next-cloudinary' ;
3
+ import { useRouter } from 'next/router' ;
4
+ import { useEffect , useRef } from 'react' ;
3
5
import { IoLogoGithub } from 'react-icons/io' ;
4
6
5
7
interface Contributor {
@@ -15,6 +17,9 @@ interface Props {
15
17
}
16
18
17
19
export default function ContributorCard ( { contributor } : Props ) {
20
+ const router = useRouter ( ) ;
21
+ const cardRef = useRef < HTMLButtonElement > ( null ) ;
22
+ const hash = router . asPath . split ( '#' ) [ 1 ] ;
18
23
const url = env . NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
19
24
? getCldImageUrl ( {
20
25
src : contributor . avatar_url ,
@@ -24,37 +29,50 @@ export default function ContributorCard({ contributor }: Props) {
24
29
} )
25
30
: contributor . avatar_url ;
26
31
32
+ useEffect ( ( ) => {
33
+ if ( hash . toLowerCase ( ) === contributor . login . toLowerCase ( ) ) {
34
+ cardRef . current ?. scrollIntoView ( {
35
+ behavior : 'smooth' ,
36
+ block : 'center'
37
+ } ) ;
38
+ cardRef . current ?. focus ( ) ;
39
+ }
40
+ } , [ hash , contributor . login ] ) ;
41
+
27
42
return (
28
- < div className = "text-center shadow-2xl card" >
29
- < a
30
- href = { `https://github.com/${ contributor . login } ` }
31
- target = "_blank"
32
- rel = "noreferrer"
33
- >
34
- < figure className = "px-10 pt-10 h-[351px] md:h-[336px] lg:h-[204px] xl:h-[268px]" >
43
+ < button
44
+ className = "text-center shadow-2xl card min-w-full justify-center focus-within:outline-sky-300"
45
+ id = { contributor . login }
46
+ onClick = { ( ) => router . replace ( { hash : contributor . login } ) }
47
+ ref = { cardRef }
48
+ >
49
+ < div className = "w-full mx-auto pt-5" >
50
+ < figure className = "h-full w-full" >
35
51
< img src = { url } alt = { contributor . name } className = "rounded-xl" />
36
52
</ figure >
37
- </ a >
38
- < div className = "card-body items-center text-center" >
39
- < h2 className = "card-title text-neutral-100" > { contributor . name } </ h2 >
53
+ </ div >
54
+ < div className = "card-body gap-3 text-center w-full" >
55
+ < h2 className = "text-center text-2xl font-bold text-2023-bavarian-blue-1" >
56
+ { contributor . name }
57
+ </ h2 >
40
58
< a
41
59
href = { contributor . profile }
42
- className = "link text-neutral-100 hover:text-[#dbe8d9] "
60
+ className = "link text-2023-bavarian-blue-1 hover:text-2023-bavarian-blue-2 "
43
61
>
44
62
{ contributor . profile }
45
63
</ a >
46
64
< div className = "justify-center card-actions mt-auto" >
47
65
< a
48
- className = "text-white btn border-[#dbe8d9] hover:border-[#dbe8d9] btn-outline border-2 hover:bg-[#dbe8d9] hover:text-slate-900 "
66
+ className = "text-2023-bavarian-blue-1 btn border-2023-bavarian-blue-2 hover:border-2023-bavarian-blue-2 btn-outline border-2 hover:bg-2023-bavarian-blue-2 hover:text-2023-bavarian-blue-4 "
49
67
href = { `https://github.com/${ contributor . login } ` }
50
68
target = "_blank"
51
69
rel = "noreferrer"
52
70
>
53
- < IoLogoGithub />
71
+ < IoLogoGithub className = "w-5 h-5" />
54
72
Profile
55
73
</ a >
56
74
</ div >
57
75
</ div >
58
- </ div >
76
+ </ button >
59
77
) ;
60
78
}
0 commit comments