Skip to content

Commit

Permalink
prettified props
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Jan 21, 2024
1 parent dc03e36 commit 3fda7af
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
20 changes: 10 additions & 10 deletions packages/nextjs/components/example-ui/ContractData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
mainCardRenderProps,
mainCardWithNumberOverlayPropertiesClasses,
navBarPropertiesClasses,
navBarRenderProps, // prettifyLoadingProps,
navBarRenderProps,
prettifyLoadingProps,
} from "./tokens/token-group-card/TokenGroupCardConfig";
import { useAccount } from "wagmi";

Expand All @@ -19,18 +20,17 @@ export const ContractData = () => {
tokens[i].image = tokens[i].image?.replace("ipfs://", "https://ipfs.io/ipfs/");
}

const navBarCardImageProperties0 = new ImageProperties("Token 0", 64, 64);
const mainCardImageProperties0 = new ImageProperties("Token 0", 256, 256);
const navBarCardImageProperties = new ImageProperties("Token 0", 64, 64);
const mainCardImageProperties = new ImageProperties("Token 0", 256, 256);

return (
<>
<div className="flex flex-col justify-center items-center bg-primary bg-[length:100%_100%] py-1 px-5 sm:px-0 lg:py-auto max-w-[100vw] ">
<div>
<DefaultTokenGroupCard
tokens={tokens}
imageProperties={navBarCardImageProperties0}
// imageProperties1={navBarCardImageProperties1}
// prettifyLoadingProps={prettifyLoadingProps}
imageProperties={navBarCardImageProperties}
prettifyLoadingProps={prettifyLoadingProps}
propertiesClasses={navBarPropertiesClasses}
renderProps={navBarRenderProps}
/>
Expand All @@ -41,8 +41,8 @@ export const ContractData = () => {
<div>
<DefaultTokenGroupCard
tokens={tokens}
imageProperties={mainCardImageProperties0}
// prettifyLoadingProps={prettifyLoadingProps}
imageProperties={mainCardImageProperties}
prettifyLoadingProps={prettifyLoadingProps}
propertiesClasses={mainCardPropertiesClasses}
renderProps={mainCardRenderProps}
/>
Expand All @@ -53,8 +53,8 @@ export const ContractData = () => {
<div>
<DefaultTokenGroupCard
tokens={tokens}
imageProperties={mainCardImageProperties0}
// prettifyLoadingProps={prettifyLoadingProps}
imageProperties={mainCardImageProperties}
prettifyLoadingProps={prettifyLoadingProps}
propertiesClasses={mainCardWithNumberOverlayPropertiesClasses}
renderProps={mainCardRenderProps}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type Token = {
name: string;
description: string;
id: number;
properties: any;
};

export interface Nft {
Expand Down Expand Up @@ -170,7 +171,7 @@ export const useRepTokens = (address?: string) => {
description: responses[i]?.description,
image: responses[i]?.image,
properties: tokensProperties[i],
};
} as Token;
tokens.push(token);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type TTokenGroupCardProps = {
tokens: Token[];
imageProperties: ImageProperties;
propertiesClasses?: TTokenCardGroupPropertiesClasses;
// prettifyLoadingProps?: TTokenGroupCardPrettifyLoadingProps;
prettifyLoadingProps?: TTokenGroupCardPrettifyLoadingProps;
renderProps?: TBaseTokenCardBooleanSet;
};

Expand All @@ -27,7 +27,7 @@ export const DefaultTokenGroupCard = ({
tokens,
imageProperties,
propertiesClasses,
// prettifyLoadingProps,
prettifyLoadingProps,
renderProps,
}: TTokenGroupCardProps) => {
const components = tokens.map((token, index) => (
Expand All @@ -36,16 +36,50 @@ export const DefaultTokenGroupCard = ({
token={token}
imageProperties={imageProperties}
propertiesClasses={propertiesClasses?.tokenCardPropertyClasses}
// prettifyLoadingProps={prettifyLoadingProps?.tokenCardPrettifyLoadingProps}
prettifyLoadingProps={prettifyLoadingProps?.tokenCardPrettifyLoadingProps}
renderProps={renderProps}
></DefaultTokenCard>
));

let output;

if (prettifyLoadingProps) {
if (prettifyLoadingProps?.card) {
let isLoaded = true;
for (let i = 0; i < tokens.length; i++) {
if (
tokens[i].balance === undefined &&
tokens[i].name === undefined &&
tokens[i].description === undefined &&
tokens[i].image === undefined &&
tokens[i].properties === undefined
) {
isLoaded = false;
break;
}
}

if (tokens.length === 0) isLoaded = !isLoaded;

if (!isLoaded) {
output = <>Loading Reputation Tokens...</>;
console.log("output set");
} else output = components;
} else {
output = components;
}
} else {
output = components;
}

return (
<div className={propertiesClasses?.card}>
<div className={propertiesClasses?.container}>{components}</div>
<div className={propertiesClasses?.container}>{output}</div>
</div>
// <div className={propertiesClasses?.card}>
// <div className={propertiesClasses?.container}>{components}</div>
// </div>
// <div className={propertiesClasses?.card}>
// {prettifyLoadingProps?.card ? (
// tokenGroup.token0.balance !== undefined &&
// tokenGroup.token0.name !== undefined &&
Expand Down

0 comments on commit 3fda7af

Please sign in to comment.