Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cov 178 nft component loader needs skeleton not just the text #12

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,60 @@ export const NFTWalletTokenListView: React.FC<NFTWalletTokenListViewProps> = ({
</div>
</div>
</div>

<div className="flex flex-wrap gap-8">{body}</div>
</div>
);
},
});
</div>

<div className="flex flex-wrap gap-8">
{maybeResult.match({
None: () => [1,2,3,4,5,6,7,8].map((o,i) => {
return <Skeleton key={i} is_nft size={GRK_SIZES.EXTRA_EXTRA_SMALL} />;
}),
Some: (result: any) => {
if (error.error) {
return <>{error.error_message}</>;
} else if (!error.error && result.length === 0) {
return <>No results</>;
} else if (result.length > 0) {
return result.map((items: any) => {
return flatMap(items.nft_data, (it) => {
return (
<Card className="w-[230px] rounded border">
<CardContent>
<img
className={`block h-[10rem] w-full rounded-t ${it.external_data ? "object-cover" : "p-2"}`}
src={it.external_data ? it.external_data.image_512 : "https://www.datocms-assets.com/86369/1685489960-nft.svg"}
onError={(e) => {
e.currentTarget.classList.remove("object-cover");
e.currentTarget.classList.add("p-2");
e.currentTarget.src =
"https://www.datocms-assets.com/86369/1685489960-nft.svg";
}}
/>
</CardContent>
<div className="p-4">
<CardDescription>
{" "}
{items.contract_name}
</CardDescription>
<CardTitle className="truncate">
#{it.token_id?.toString()}
</CardTitle>
<div className="mt-2">
<small className="text-muted-foreground">
Est. Value
</small>
<p> {items.pretty_floor_price_quote ? items.pretty_floor_price_quote : <span>-</span>}</p>
</div>
</div>
</Card>
);
});
});
}
}
})}

</div>
</div>
);
};
5 changes: 3 additions & 2 deletions src/components/ui/skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { cn } from "../../utils/functions";

interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {
size: GRK_SIZES;
is_nft?: boolean;
}

function Skeleton({ size }: SkeletonProps) {
function Skeleton({ size, is_nft = false }: SkeletonProps) {
const sizeClass = (() => {
switch (size) {
case "lg":
Expand All @@ -27,7 +28,7 @@ function Skeleton({ size }: SkeletonProps) {
<div
className={cn(
"animate-pulse rounded bg-accent-foreground",
sizeClass
is_nft ? "w-[230px] h-[280px]" : sizeClass
)}
/>
);
Expand Down
Loading