11import { Library , Framework , frameworkOptions } from '~/libraries'
2- import { getRoleInLibrary , Maintainer } from '~/libraries/maintainers'
2+ import {
3+ getRoleInLibrary ,
4+ Maintainer ,
5+ getPersonsMaintainerOf ,
6+ } from '~/libraries/maintainers'
7+ import { useState } from 'react'
38
4- function RoleBadge ( { role, libraryId } : { role : string ; libraryId : string } ) {
9+ function RoleBadge ( { role } : { role : string } ) {
510 const isCreator = role . toLowerCase ( ) . includes ( 'creator' )
611 const isMaintainer = role . toLowerCase ( ) . includes ( 'maintainer' )
712
@@ -37,12 +42,27 @@ function FrameworkChip({ framework }: { framework: Framework }) {
3742 )
3843}
3944
45+ function LibraryBadge ( { library } : { library : Library } ) {
46+ return (
47+ < span
48+ className = { `inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium text-gray-700 dark:text-gray-300 ${
49+ library . bgStyle ?? 'bg-gray-500'
50+ } bg-opacity-20 dark:bg-opacity-20`}
51+ >
52+ { library . name }
53+ </ span >
54+ )
55+ }
56+
4057interface MaintainerCardProps {
4158 maintainer : Maintainer
42- libraryId : Library [ 'id' ]
59+ libraryId ? : Library [ 'id' ]
4360}
4461
4562export function MaintainerCard ( { maintainer, libraryId } : MaintainerCardProps ) {
63+ const libraries = getPersonsMaintainerOf ( maintainer )
64+ const [ showAllLibraries , setShowAllLibraries ] = useState ( false )
65+
4666 return (
4767 < a
4868 href = { `https://github.com/${ maintainer . github } ` }
@@ -55,6 +75,8 @@ export function MaintainerCard({ maintainer, libraryId }: MaintainerCardProps) {
5575 alt = { `${ maintainer . name } 's avatar` }
5676 className = "w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
5777 src = { maintainer . avatar }
78+ loading = "lazy"
79+ decoding = "async"
5880 style = { {
5981 aspectRatio : '1/1' ,
6082 objectFit : 'cover' ,
@@ -88,47 +110,78 @@ export function MaintainerCard({ maintainer, libraryId }: MaintainerCardProps) {
88110 </ div >
89111 </ div >
90112 < div className = "p-3 space-y-2" >
113+ { ! libraryId && libraries . length > 0 && (
114+ < div className = "flex flex-wrap gap-1.5" >
115+ { libraries
116+ . slice ( 0 , showAllLibraries ? undefined : 2 )
117+ . map ( ( library ) => (
118+ < LibraryBadge key = { library . id } library = { library } />
119+ ) ) }
120+ { ! showAllLibraries && libraries . length > 2 && (
121+ < button
122+ onClick = { ( e ) => {
123+ e . preventDefault ( )
124+ e . stopPropagation ( )
125+ setShowAllLibraries ( true )
126+ } }
127+ className = "inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors"
128+ >
129+ +{ libraries . length - 3 } more
130+ </ button >
131+ ) }
132+ </ div >
133+ ) }
91134 < div className = "flex items-center justify-between" >
92135 < h3 className = "text-base font-bold" > { maintainer . name } </ h3 >
93- < RoleBadge
94- role = { getRoleInLibrary ( maintainer , libraryId ) }
95- libraryId = { libraryId }
96- />
136+ { libraryId && (
137+ < RoleBadge role = { getRoleInLibrary ( maintainer , libraryId ) } />
138+ ) }
97139 </ div >
98- < div className = "flex items-center space-x-3 text-gray-500 dark:text-gray-400 " >
140+ < div className = "flex items-center space-x-4 text-gray-400 dark:text-gray-500 [&>*]:grayscale " >
99141 < a
100142 href = { `https://github.com/${ maintainer . github } ` }
101- className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors"
143+ className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors p-2 -m-2 hover:grayscale-0 "
102144 target = "_blank"
103145 rel = "noopener noreferrer"
104146 onClick = { ( e ) => e . stopPropagation ( ) }
105147 >
106- < svg viewBox = "0 0 16 16" className = "w-4 h-4 " fill = "currentColor" >
148+ < svg viewBox = "0 0 16 16" className = "w-5 h-5 " fill = "currentColor" >
107149 < path d = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" > </ path >
108150 </ svg >
109151 </ a >
110152 { maintainer . social ?. twitter && (
111153 < a
112154 href = { maintainer . social . twitter }
113- className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors"
155+ className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors p-2 -m-2 hover:grayscale-0 "
114156 target = "_blank"
115157 rel = "noopener noreferrer"
116158 onClick = { ( e ) => e . stopPropagation ( ) }
117159 >
118- < svg viewBox = "0 0 24 24" className = "w-4 h-4 " fill = "currentColor" >
119- < path d = "M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z " />
160+ < svg viewBox = "0 0 24 24" className = "w-5 h-5 " fill = "currentColor" >
161+ < path d = "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z " />
120162 </ svg >
121163 </ a >
122164 ) }
165+ { maintainer . social ?. bluesky && (
166+ < a
167+ href = { maintainer . social . bluesky }
168+ className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors p-2 -m-2 hover:grayscale-0"
169+ target = "_blank"
170+ rel = "noopener noreferrer"
171+ onClick = { ( e ) => e . stopPropagation ( ) }
172+ >
173+ < span className = "text-lg" > 🦋</ span >
174+ </ a >
175+ ) }
123176 { maintainer . social ?. website && (
124177 < a
125178 href = { maintainer . social . website }
126- className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors"
179+ className = "hover:text-gray-700 dark:hover:text-gray-200 transition-colors p-2 -m-2 hover:grayscale-0 "
127180 target = "_blank"
128181 rel = "noopener noreferrer"
129182 onClick = { ( e ) => e . stopPropagation ( ) }
130183 >
131- < svg viewBox = "0 0 24 24" className = "w-4 h-4 " fill = "currentColor" >
184+ < svg viewBox = "0 0 24 24" className = "w-5 h-5 " fill = "currentColor" >
132185 < path d = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" />
133186 </ svg >
134187 </ a >
0 commit comments