-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contribution collection to
/profile
, improve card (#1454)
* feat: add collection and checkmark * chore: add extended collection * fix: add line clamp to edit contribution select * feat: add point image to contribution * fix: show cards if no point is received * feat: add points text and leaderboard ranking * chore: copy static folder to public * chore: render contribution card if no collection is present * feat: add nft to collection * feat: add pins * refactor: cleanup collection * fix: remove checkmark, allow longer label * feat: add tooltip to collection * fix: prevent wrap on points text * chore: remove NFT from tooltip * chore: remove src/static dir duplication * chore: polish borders
- Loading branch information
1 parent
ec9987f
commit 83a34be
Showing
8 changed files
with
163 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/app/(marketing)/profile/_components/ContributionCollection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/Avatar" | ||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/Tooltip" | ||
import { GuildReward, Schemas } from "@guildxyz/types" | ||
import { Ranking } from "@phosphor-icons/react" | ||
import { GuildAction } from "components/[guild]/Requirements/components/GuildCheckout/MintGuildPinContext" | ||
import { env } from "env" | ||
import Star from "static/icons/star.svg" | ||
import useSWRImmutable from "swr/immutable" | ||
|
||
export const ContributionCollection = ({ | ||
collection, | ||
guildId, | ||
}: { collection: Schemas["ContributionCollection"]; guildId: number }) => { | ||
const collectionPoint = collection.points.at(0) | ||
const collectionNft = collection.NFTs.at(0) | ||
const collectionPin = collection.pins.at(0) | ||
const { data: pinHash } = useSWRImmutable<string>( | ||
collectionPin | ||
? `/v2/guilds/${guildId}/pin?guildAction=${GuildAction[collectionPin.action]}` | ||
: null | ||
) | ||
const pin = pinHash ? new URL(pinHash, env.NEXT_PUBLIC_IPFS_GATEWAY) : undefined | ||
const { data: point } = useSWRImmutable<GuildReward>( | ||
collectionPoint | ||
? `/v2/guilds/${collectionPoint.guildId}/guild-platforms/${collectionPoint.guildPlatformId}` | ||
: null | ||
) | ||
|
||
return ( | ||
<> | ||
{pin && ( | ||
<Tooltip> | ||
<TooltipTrigger> | ||
<Avatar size="lg" className="-ml-3 border-2 border-card"> | ||
<AvatarImage src={pin.href} alt="avatar" width={32} height={32} /> | ||
<AvatarFallback /> | ||
</Avatar> | ||
</TooltipTrigger> | ||
<TooltipContent>Minted Guild Pin</TooltipContent> | ||
</Tooltip> | ||
)} | ||
{collectionNft?.data.imageUrl && ( | ||
<Tooltip> | ||
<TooltipTrigger> | ||
<Avatar size="lg" className="-ml-3 border-2 border-card"> | ||
<AvatarImage | ||
src={collectionNft.data.imageUrl} | ||
alt="avatar" | ||
width={32} | ||
height={32} | ||
/> | ||
<AvatarFallback /> | ||
</Avatar> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
Minted <strong>{collectionNft.data.name}</strong> | ||
</TooltipContent> | ||
</Tooltip> | ||
)} | ||
{point && collectionPoint && ( | ||
<> | ||
<Avatar size="lg" className="-ml-3 border-2 border-card"> | ||
{point.platformGuildData.imageUrl ? ( | ||
<> | ||
<AvatarImage | ||
src={point.platformGuildData.imageUrl} | ||
alt="avatar" | ||
width={32} | ||
height={32} | ||
/> | ||
<AvatarFallback /> | ||
</> | ||
) : ( | ||
<Star className="size-6" /> | ||
)} | ||
</Avatar> | ||
<div className="-ml-3 self-center whitespace-nowrap rounded-r-lg border bg-card-secondary py-0.5 pr-2 pl-5"> | ||
<div className="text-sm"> | ||
{collectionPoint.totalPoints} | ||
<span className="font-extrabold">{point.platformGuildData.name}</span> | ||
</div> | ||
<div className="flex items-center gap-1 text-muted-foreground text-xs"> | ||
<Ranking weight="bold" />#{collectionPoint.rank} | ||
</div> | ||
</div> | ||
</> | ||
)} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters