-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathindex.tsx
More file actions
82 lines (76 loc) · 2.45 KB
/
index.tsx
File metadata and controls
82 lines (76 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import type { Address } from 'viem'
import { cn } from '#/lib/utilities'
import type { ENSProfile } from '#/types/requests'
import type { ProfileStatsType } from '#/types/common'
import LoadingRow from './components/list-item/loading-list-item'
import ProfileListItem from './components/list-item/profile-list-item'
import type { InitialFollowingState } from '@encrypteddegen/identity-kit'
export interface ProfileListProfile {
address: Address
ens?: ENSProfile
tags: string[]
counts?: ProfileStatsType
}
interface ProfileListProps {
className?: string
profiles?: ProfileListProfile[]
showFollowsYouBadges?: boolean // Handle showing "Follows you" badges in the ProfileList
showTags?: boolean
loadingRows?: number
isLoading: boolean
isLoadingMore?: boolean
canEditTags?: boolean
isBlockedList?: boolean // If the list is displaying blocked and blocked by profiles
isBlockedBy?: boolean // Used to handle the "Block Back" on FollowButton
isTopEight?: boolean
initialFollowState?: InitialFollowingState
}
const ProfileList: React.FC<ProfileListProps> = ({
className,
profiles,
showFollowsYouBadges,
showTags,
loadingRows = 7,
isLoading,
isLoadingMore,
canEditTags,
isBlockedList,
isBlockedBy,
isTopEight,
initialFollowState,
}) => {
const displayLoadingRows = isLoadingMore || isLoading
const isShortList = (profiles?.length || 0) <= 3
const isEmpty = !isLoading && (profiles?.length || 0) === 0
return (
<div
className={cn(
'flex w-full flex-col gap-0',
!isEmpty && isShortList && showTags && canEditTags ? 'pb-32' : 'pb-0',
className
)}
>
{profiles?.map(({ address, tags, ens, counts }, index) => (
<ProfileListItem
key={address + tags.join(',')}
address={address}
ensProfile={ens}
showFollowsYouBadges={showFollowsYouBadges}
showTags={showTags}
tags={tags}
counts={counts}
canEditTags={canEditTags}
isBlockedList={isBlockedList}
isBlockedBy={isBlockedBy}
isTopEight={isTopEight}
initialFollowState={initialFollowState}
tagsDropdownPosition={
(index === profiles.length - 1 || index === profiles.length - 2) && index >= 2 ? 'top' : 'bottom'
}
/>
))}
{displayLoadingRows && new Array(loadingRows).fill(1).map((_, i) => <LoadingRow key={i} showTags={showTags} />)}
</div>
)
}
export default ProfileList