-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fe6afd
commit 3f9c2d7
Showing
4 changed files
with
56 additions
and
15 deletions.
There are no files selected for viewing
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
52 changes: 48 additions & 4 deletions
52
apps/nextjs/src/app/(app)/collection/[id]/(list)/RealmResources.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 |
---|---|---|
@@ -1,25 +1,69 @@ | ||
import { ResourceIcon } from "@realms-world/ui/components/ui/resource-icon"; | ||
import { Badge } from "@realms-world/ui/components/ui/badge"; | ||
import Image from "next/image"; | ||
import { TokenMetadataAttribute } from "@/types/ark"; | ||
import { useState } from "react"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "@realms-world/ui/components/ui/tooltip"; // Assuming you're using a tooltip library | ||
|
||
export default function RealmResources({ | ||
traits, | ||
}: { | ||
traits: TokenMetadataAttribute[]; | ||
}) { | ||
const resources = traits.filter((trait) => trait.trait_type === "Resource"); | ||
const [showMore, setShowMore] = useState(false); | ||
const hiddenCount = resources.length - 4; | ||
|
||
return ( | ||
<div className="flex flex-wrap gap-4"> | ||
{resources.map((resource, index) => ( | ||
<div className="flex items-center gap-2"> | ||
{resources.slice(0, 4).map((resource, index) => ( | ||
<div | ||
key={index} | ||
className="flex items-center gap-2 rounded-lg bg-secondary p-2" | ||
> | ||
<ResourceIcon size="md" resource={resource.value} /> | ||
</div> | ||
))} | ||
{resources.length > 4 && ( | ||
<> | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<button | ||
//onClick={() => setShowMore(!showMore)} | ||
className="text-sm underline" | ||
> | ||
{`+(${hiddenCount})`} | ||
</button> | ||
</TooltipTrigger> | ||
|
||
<TooltipContent | ||
className="h-16 max-w-48 p-2" | ||
id="resource-tooltip" | ||
side="top" | ||
> | ||
<div className="flex items-center gap-2"> | ||
{resources.slice(4).map((resource, index) => ( | ||
<div key={index} className="flex items-center gap-2"> | ||
<div> | ||
<span className="text-xs">{resource.value}</span> | ||
<ResourceIcon | ||
size="md" | ||
withTooltip={false} | ||
resource={resource.value} | ||
/> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |