@@ -3,10 +3,11 @@ import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'
33import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
44import { Button } from '@heroui/button'
55import Image from 'next/image'
6- import { useRouter } from 'next/navigation '
6+ import Link from 'next/link '
77import { useState } from 'react'
88import { TopContributorsTypeGraphql } from 'types/contributor'
99import { capitalize } from 'utils/capitalize'
10+ import { getMemberUrl , getProjectUrl } from 'utils/urlFormatter'
1011import SecondaryCard from './SecondaryCard'
1112
1213const TopContributors = ( {
@@ -22,7 +23,6 @@ const TopContributors = ({
2223 type : string
2324 icon ?: IconProp
2425} ) => {
25- const router = useRouter ( )
2626 const [ showAllContributors , setShowAllContributors ] = useState ( false )
2727
2828 const toggleContributors = ( ) => setShowAllContributors ( ! showAllContributors )
@@ -34,14 +34,15 @@ const TopContributors = ({
3434 if ( contributors . length === 0 ) {
3535 return
3636 }
37+ const isContributor = type === 'contributor'
38+
3739 return (
3840 < SecondaryCard icon = { icon } title = { label } >
3941 < div className = "grid gap-4 sm:grid-cols-1 md:grid-cols-3" >
4042 { displayContributors . map ( ( item , index ) => (
4143 < button
4244 key = { index }
43- onClick = { ( ) => router . push ( `/members/${ item . login } ` ) }
44- className = "overflow-hidden rounded-lg bg-gray-200 p-4 dark:bg-gray-700"
45+ className = "cursor-default overflow-hidden rounded-lg bg-gray-200 p-4 dark:bg-gray-700"
4546 >
4647 < div className = "flex w-full flex-col justify-between" >
4748 < div className = "flex w-full items-center gap-2" >
@@ -52,17 +53,23 @@ const TopContributors = ({
5253 alt = { item ?. name || '' }
5354 className = "rounded-full"
5455 />
55- < h3 className = "overflow-hidden text-ellipsis whitespace-nowrap font-semibold text-blue-400" >
56+ < Link
57+ className = "cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap font-semibold text-blue-400 hover:underline"
58+ href = { getMemberUrl ( item ?. login ) }
59+ >
5660 { capitalize ( item . name ) || capitalize ( item . login ) }
57- </ h3 >
61+ </ Link >
5862 </ div >
5963 < div className = "ml-0.5 w-full" >
6064 < div className = "mt-2 flex flex-shrink-0 items-center text-sm text-gray-600 dark:text-gray-400" >
61- < span className = "overflow-hidden text-ellipsis whitespace-nowrap" >
62- { type === 'contributor'
65+ < Link
66+ className = { `overflow-hidden text-ellipsis whitespace-nowrap text-gray-600 dark:text-gray-400 ${ ! isContributor ? 'cursor-pointer hover:underline' : 'cursor-default' } ` }
67+ href = { ! isContributor ? getProjectUrl ( item ?. projectUrl ) : '' }
68+ >
69+ { isContributor
6370 ? `${ item . contributionsCount ?? 0 } contributions`
6471 : item . projectName }
65- </ span >
72+ </ Link >
6673 </ div >
6774 </ div >
6875 </ div >
0 commit comments