Skip to content

Commit

Permalink
renamed property-cards to value-cards
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Jan 28, 2024
1 parent dd2bfc7 commit 0c0de67
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 66 deletions.
24 changes: 12 additions & 12 deletions packages/nextjs/components/rep-tokens-demo/MainTokensCardConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ImageProps } from "../rep-tokens/cards/property-cards/ImageCard";
import { ImageProps } from "../rep-tokens/cards/value-cards/ImageCard";
import {
BaseElementConfigProp,
ImageElementConfigProp,
ImageValueCardConfigProp,
TokenCardConfigProps,
TokenElementsConfigProps,
TokenCardValuesConfigProps,
ValueCardConfigProps,
} from "../rep-tokens/types/Types";
import { TokenGroupCardConfigProps } from "../rep-tokens/types/Types";

Expand All @@ -14,7 +14,7 @@ export const balanceProps = {
value: "text-4xl mx-auto text-center",
},
isPrettyLoading: true,
} as BaseElementConfigProp;
} as ValueCardConfigProps;

export const imageProps = {
isRendering: true,
Expand All @@ -24,7 +24,7 @@ export const imageProps = {
},
imageProperties: new ImageProps("Token", 256, 256),
isPrettyLoading: true,
} as ImageElementConfigProp;
} as ImageValueCardConfigProp;

export const nameProps = {
isRendering: true,
Expand All @@ -33,7 +33,7 @@ export const nameProps = {
value: "text-1xl text-center object-center mx-auto font-bold break-all",
},
isPrettyLoading: true,
} as BaseElementConfigProp;
} as ValueCardConfigProps;

export const descriptionProps = {
isRendering: true,
Expand All @@ -42,7 +42,7 @@ export const descriptionProps = {
value: "text-1xl mx-auto text-center break-words",
},
isPrettyLoading: true,
} as BaseElementConfigProp;
} as ValueCardConfigProps;

export const addressProps = {
isRendering: true,
Expand All @@ -51,20 +51,20 @@ export const addressProps = {
value: "rounded mx-auto",
},
isPrettyLoading: true,
} as BaseElementConfigProp;
} as ValueCardConfigProps;

export const elementsProps = {
export const tokenCardValuesProps = {
balanceProps,
imageProps,
nameProps,
descriptionProps,
addressProps,
} as TokenElementsConfigProps;
} as TokenCardValuesConfigProps;

export const tokenCardProps = {
isRendering: true,
cardClasses: "bg-slate-600 p-5 m-4 w-64",
elementsProps,
valuesProps: tokenCardValuesProps,
} as TokenCardConfigProps;

export const tokenGroupCardConfigProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BalanceCard, BigIntCardProps } from "../property-cards/BalanceCard";
import { ImageCard, ImageCardProps } from "../property-cards/ImageCard";
import { StringCard, StringCardProps } from "../property-cards/StringCard";
import { BalanceCard, BigIntCardProps } from "../value-cards/BalanceCard";
import { ImageCard, ImageCardProps } from "../value-cards/ImageCard";
import { StringCard, StringCardProps } from "../value-cards/StringCard";
import { Address } from "~~/components/scaffold-eth";

export interface ComponentsProps {
export interface ValuesProps {
balanceProps?: BigIntCardProps;
nameProps?: StringCardProps;
descriptionProps?: StringCardProps;
Expand All @@ -14,7 +14,7 @@ export interface ComponentsProps {
export interface TokenCardProps {
cardClasses?: string;
isPrettyLoading?: boolean;
componentsProps: ComponentsProps;
valuesProps: ValuesProps;
}

export interface TokenCardInternalProps {
Expand All @@ -24,28 +24,23 @@ export interface TokenCardInternalProps {
export const TokenCard = ({ props }: TokenCardInternalProps) => {
const output = (
<>
{props?.componentsProps?.balanceProps ? <BalanceCard props={props?.componentsProps?.balanceProps} /> : <></>}
{props?.componentsProps?.imageProps ? <ImageCard props={props?.componentsProps?.imageProps} /> : <></>}
{props?.componentsProps?.nameProps ? <StringCard props={props?.componentsProps?.nameProps} /> : <></>}
{props?.componentsProps?.descriptionProps ? (
<StringCard props={props?.componentsProps?.descriptionProps} />
) : (
<></>
)}
{props?.componentsProps?.addressProps ? <Address props={props?.componentsProps?.addressProps} /> : <></>}
{/* <BaseTokenCard props={props?.baseComponentsProps} /> */}
{props?.valuesProps?.balanceProps ? <BalanceCard props={props?.valuesProps?.balanceProps} /> : <></>}
{props?.valuesProps?.imageProps ? <ImageCard props={props?.valuesProps?.imageProps} /> : <></>}
{props?.valuesProps?.nameProps ? <StringCard props={props?.valuesProps?.nameProps} /> : <></>}
{props?.valuesProps?.descriptionProps ? <StringCard props={props?.valuesProps?.descriptionProps} /> : <></>}
{props?.valuesProps?.addressProps ? <Address props={props?.valuesProps?.addressProps} /> : <></>}
</>
);

return (
<>
<div className={props?.cardClasses}>
{props?.isPrettyLoading ? (
props?.componentsProps?.imageProps?.value !== undefined &&
props?.componentsProps?.balanceProps?.value !== undefined &&
props?.componentsProps?.nameProps?.value !== undefined &&
props?.componentsProps?.descriptionProps?.value !== undefined &&
props?.componentsProps?.addressProps?.value !== undefined ? (
props?.valuesProps?.imageProps?.value !== undefined &&
props?.valuesProps?.balanceProps?.value !== undefined &&
props?.valuesProps?.nameProps?.value !== undefined &&
props?.valuesProps?.descriptionProps?.value !== undefined &&
props?.valuesProps?.addressProps?.value !== undefined ? (
<div>{output}</div>
) : (
<>Loading Token...</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CardClasses } from "../../types/Types";
import { StringCardProps } from "../property-cards/StringCard";
import { TokenCard } from "../token-card/TokenCard";
import { TokenCardProps } from "../token-card/TokenCard";
import { StringCardProps } from "../value-cards/StringCard";
import { Address } from "~~/components/scaffold-eth";

export interface TokenGroupProps {
Expand Down Expand Up @@ -37,10 +37,10 @@ export const TokenGroupCard = ({ props }: TokenGroupCardInternalProps) => {
let isLoaded = true;
for (let i = 0; i < props?.tokenCardsProps.length; i++) {
if (
props?.tokenCardsProps[i].componentsProps?.balanceProps?.value === undefined &&
props?.tokenCardsProps[i].componentsProps?.nameProps?.value === undefined &&
props?.tokenCardsProps[i].componentsProps?.descriptionProps?.value === undefined &&
props?.tokenCardsProps[i].componentsProps?.imageProps?.value === undefined
props?.tokenCardsProps[i].valuesProps?.balanceProps?.value === undefined &&
props?.tokenCardsProps[i].valuesProps?.nameProps?.value === undefined &&
props?.tokenCardsProps[i].valuesProps?.descriptionProps?.value === undefined &&
props?.tokenCardsProps[i].valuesProps?.imageProps?.value === undefined
) {
isLoaded = false;
break;
Expand Down
22 changes: 11 additions & 11 deletions packages/nextjs/components/rep-tokens/types/Types.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { ImageProps } from "../cards/property-cards/ImageCard";
import { StringCardProps } from "../cards/property-cards/StringCard";
import { ImageProps } from "../cards/value-cards/ImageCard";
import { StringCardProps } from "../cards/value-cards/StringCard";

export interface CardClasses {
card?: string;
value?: string;
}

export interface BaseElementConfigProp {
export interface ValueCardConfigProps {
isRendering?: boolean;
classes?: CardClasses;
isPrettyLoading?: boolean;
}

export interface ImageElementConfigProp extends BaseElementConfigProp {
export interface ImageValueCardConfigProp extends ValueCardConfigProps {
imageProperties: ImageProps;
}

export interface TokenElementsConfigProps {
balanceProps?: BaseElementConfigProp;
imageProps?: ImageElementConfigProp;
nameProps?: BaseElementConfigProp;
descriptionProps?: BaseElementConfigProp;
addressProps?: BaseElementConfigProp;
export interface TokenCardValuesConfigProps {
balanceProps?: ValueCardConfigProps;
imageProps?: ImageValueCardConfigProp;
nameProps?: ValueCardConfigProps;
descriptionProps?: ValueCardConfigProps;
addressProps?: ValueCardConfigProps;
}

export interface TokenCardConfigProps {
isRendering: true;
cardClasses: string;
elementsProps: TokenElementsConfigProps;
valuesProps: TokenCardValuesConfigProps;
isPrettyLoading: true;
}

Expand Down
34 changes: 17 additions & 17 deletions packages/nextjs/components/rep-tokens/utils/buildTokensCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,41 @@ export function buildTokenCards(tokens: Token[], address?: string, tokenCardProp
const tokenCardProp: TokenCardProps = {
isPrettyLoading: tokenCardProps?.isPrettyLoading,
cardClasses: tokenCardProps?.cardClasses,
componentsProps: {
balanceProps: tokenCardProps?.elementsProps?.balanceProps?.isRendering
valuesProps: {
balanceProps: tokenCardProps?.valuesProps?.balanceProps?.isRendering
? {
value: tokens[i].balance,
classes: tokenCardProps?.elementsProps?.balanceProps?.classes,
isPrettyLoading: tokenCardProps?.elementsProps?.balanceProps?.isPrettyLoading,
classes: tokenCardProps?.valuesProps?.balanceProps?.classes,
isPrettyLoading: tokenCardProps?.valuesProps?.balanceProps?.isPrettyLoading,
}
: undefined,
nameProps: tokenCardProps?.elementsProps?.nameProps?.isRendering
nameProps: tokenCardProps?.valuesProps?.nameProps?.isRendering
? {
value: tokens[i].name,
classes: tokenCardProps?.elementsProps?.nameProps?.classes,
isPrettyLoading: tokenCardProps?.elementsProps?.nameProps?.isPrettyLoading,
classes: tokenCardProps?.valuesProps?.nameProps?.classes,
isPrettyLoading: tokenCardProps?.valuesProps?.nameProps?.isPrettyLoading,
}
: undefined,
descriptionProps: tokenCardProps?.elementsProps?.descriptionProps?.isRendering
descriptionProps: tokenCardProps?.valuesProps?.descriptionProps?.isRendering
? {
value: tokens[i].description,
classes: tokenCardProps?.elementsProps?.descriptionProps?.classes,
isPrettyLoading: tokenCardProps?.elementsProps?.descriptionProps?.isPrettyLoading,
classes: tokenCardProps?.valuesProps?.descriptionProps?.classes,
isPrettyLoading: tokenCardProps?.valuesProps?.descriptionProps?.isPrettyLoading,
}
: undefined,
imageProps: tokenCardProps?.elementsProps?.imageProps?.isRendering
imageProps: tokenCardProps?.valuesProps?.imageProps?.isRendering
? {
value: tokens[i].image,
properties: tokenCardProps?.elementsProps?.imageProps?.imageProperties,
classes: tokenCardProps?.elementsProps?.imageProps?.classes,
isPrettyLoading: tokenCardProps?.elementsProps?.imageProps?.isPrettyLoading,
properties: tokenCardProps?.valuesProps?.imageProps?.imageProperties,
classes: tokenCardProps?.valuesProps?.imageProps?.classes,
isPrettyLoading: tokenCardProps?.valuesProps?.imageProps?.isPrettyLoading,
}
: undefined,
addressProps: tokenCardProps?.elementsProps?.addressProps?.isRendering
addressProps: tokenCardProps?.valuesProps?.addressProps?.isRendering
? {
value: address,
classes: tokenCardProps?.elementsProps?.addressProps?.classes,
isPrettyLoading: tokenCardProps?.elementsProps?.addressProps?.isPrettyLoading,
classes: tokenCardProps?.valuesProps?.addressProps?.classes,
isPrettyLoading: tokenCardProps?.valuesProps?.addressProps?.isPrettyLoading,
}
: undefined,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/scaffold-eth/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import Link from "next/link";
import { StringCardProps } from "../rep-tokens/cards/property-cards/StringCard";
import { StringCardProps } from "../rep-tokens/cards/value-cards/StringCard";
// import { ElementClasses } from "../rep-tokens/types/Types";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { isAddress } from "viem";
Expand Down

0 comments on commit 0c0de67

Please sign in to comment.