Skip to content

Commit f1405dd

Browse files
committed
feat: add 'details' button to Profile -> Communities tab
1 parent c640fa1 commit f1405dd

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
import type { Community } from '@pubkey-link/sdk'
22
import { RoleUiList } from '@pubkey-link/web-role-ui'
3-
import { UiInfo } from '@pubkey-ui/core'
4-
import { CommunityUiGridItem } from './community-ui-grid-item'
3+
import { UiDebugModal, UiGroup, UiInfo, UiStack } from '@pubkey-ui/core'
4+
import { Button, Paper } from '@mantine/core'
5+
import { CommunityUiItem } from './community-ui-item'
6+
import { CommunityUiSocials } from './community-ui-socials'
7+
import { useState } from 'react'
58

69
export function CommunityUiList({ communities }: { communities: Community[] }) {
7-
return communities.map((item) => (
8-
<CommunityUiGridItem key={item.id} community={item} to={`/c/${item.id}`}>
9-
{item?.roles?.length ? <RoleUiList mt="xs" roles={item.roles ?? []} /> : <UiInfo message="No roles." />}
10-
</CommunityUiGridItem>
11-
))
10+
return communities.map((item) => <CommunityUiListItem key={item.id} item={item} to={`/c/${item.id}`} />)
11+
}
12+
13+
export function CommunityUiListItem({ item, to }: { item: Community; to?: string }) {
14+
const [showDetails, setShowDetails] = useState(false)
15+
return (
16+
<Paper withBorder p="md">
17+
<UiStack>
18+
<UiGroup>
19+
<CommunityUiItem community={item} to={to} />
20+
<UiStack align="end">
21+
<CommunityUiSocials community={item}>
22+
<UiDebugModal data={item} />
23+
</CommunityUiSocials>
24+
<Button
25+
disabled={!item?.roles?.length}
26+
variant="subtle"
27+
size="xs"
28+
onClick={() => setShowDetails(!showDetails)}
29+
>
30+
{showDetails ? 'Hide' : 'Show'} Details
31+
</Button>
32+
</UiStack>
33+
</UiGroup>
34+
{item?.roles?.length ? (
35+
showDetails ? (
36+
<RoleUiList mt="xs" roles={item.roles ?? []} />
37+
) : null
38+
) : (
39+
<UiInfo message="No roles." />
40+
)}
41+
</UiStack>
42+
</Paper>
43+
)
1244
}

0 commit comments

Comments
 (0)