Skip to content

Commit

Permalink
feat(MemberCount): display actual member count in a tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Dec 9, 2024
1 parent b805f99 commit e17a31b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/[guild]/RoleCard/components/MemberCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ const MemberCount = ({

type WithSyncProps = Props & {
roleId?: number
tooltipContent?: string // used only if sync status is not "STARTED"
}

const MemberCountWithSyncIndicator = ({
roleId,
tooltipContent,
...rest
}: PropsWithChildren<WithSyncProps>) => {
const { status, data } = useActiveStatusUpdates(roleId)
Expand Down Expand Up @@ -76,6 +78,19 @@ const MemberCountWithSyncIndicator = ({
</Tooltip>
)

if (!!tooltipContent)
return (
<Tooltip>
<TooltipTrigger>
<MemberCount {...rest} />
</TooltipTrigger>

<TooltipContent>
<p>{tooltipContent}</p>
</TooltipContent>
</Tooltip>
)

return <MemberCount {...rest} />
}

Expand All @@ -101,7 +116,9 @@ const RoleCardMemberCount = ({
memberCount,
roleId,
lastSyncedAt,
}: PropsWithChildren<WithSyncProps & { lastSyncedAt: string }>) => {
}: PropsWithChildren<
Omit<WithSyncProps, "tooltipContent"> & { lastSyncedAt: string }
>) => {
const { featureFlags } = useGuild()
const { isAdmin } = useGuildPermission()
const { isSuperAdmin } = useUser()
Expand All @@ -111,6 +128,9 @@ const RoleCardMemberCount = ({
memberCount={memberCount}
roleId={roleId}
className="!bg-transparent text-muted-foreground"
tooltipContent={new Intl.NumberFormat("en-US", {
notation: "standard",
}).format(memberCount)}
>
{isSuperAdmin ? (
<MemberCountLastSyncTooltip lastSyncedAt={lastSyncedAt}>
Expand Down

0 comments on commit e17a31b

Please sign in to comment.