-
Notifications
You must be signed in to change notification settings - Fork 16
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
3fa7513
commit 142aeac
Showing
13 changed files
with
190 additions
and
194 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
2 changes: 1 addition & 1 deletion
2
packages/nextjs/components/rep-tokens-demo/tokens/token-card/BalanceCard.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
82 changes: 0 additions & 82 deletions
82
packages/nextjs/components/rep-tokens-demo/tokens/token-card/BaseTokenCard.tsx
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/nextjs/components/rep-tokens-demo/tokens/token-card/ImageCard.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
2 changes: 1 addition & 1 deletion
2
packages/nextjs/components/rep-tokens-demo/tokens/token-card/StringCard.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
116 changes: 67 additions & 49 deletions
116
packages/nextjs/components/rep-tokens-demo/tokens/token-card/TokenCard.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,70 +1,88 @@ | ||
import { Token } from "../Hooks"; | ||
import { | ||
BaseTokenCard, | ||
TBaseTokenCardBooleanSet, // TBaseTokenCardRenderSettings, // TBaseTokenCardPrettifyLoadingProps, | ||
TBaseTokenCardPropertiesClasses, | ||
} from "./BaseTokenCard"; | ||
import { BalanceCard } from "./BalanceCard"; | ||
import { ImageCard } from "./ImageCard"; | ||
import { ImageProperties } from "./ImageCard"; | ||
import { StringCard } from "./StringCard"; | ||
import { Address } from "~~/components/scaffold-eth"; | ||
|
||
export interface TTokenCardPropss { | ||
token: Token; | ||
imageProperties?: ImageProperties; | ||
propertiesClasses?: TTokenCardPropertiesClasses; | ||
prettifyLoadingProps?: TTokenCardPrettifyLoadingProps; | ||
renderProps?: TBaseTokenCardBooleanSet; | ||
} | ||
export type TContainerAndValuePair = { | ||
container: string; | ||
value: string; | ||
}; | ||
|
||
export type TTokenCardProps = { | ||
type TTokenProps = { | ||
token: Token; | ||
address?: string; | ||
imageProperties?: ImageProperties; | ||
propertiesClasses?: TTokenCardPropertiesClasses; | ||
prettifyLoadingProps?: TTokenCardPrettifyLoadingProps; | ||
propertiesClasses?: TBaseTokenCardPropertiesClasses; | ||
prettifyLoadingProps?: TBaseTokenCardBooleanSet; | ||
renderProps?: TBaseTokenCardBooleanSet; | ||
}; | ||
|
||
export type TTokenCardPropertiesClasses = { | ||
card: string; | ||
baseTokenCardPropertyClasses?: TBaseTokenCardPropertiesClasses; | ||
export type TBaseTokenCardPropertiesClasses = { | ||
balance: TContainerAndValuePair; | ||
name: TContainerAndValuePair; | ||
description: TContainerAndValuePair; | ||
image: TContainerAndValuePair; | ||
address: TContainerAndValuePair; | ||
}; | ||
|
||
export type TTokenCardPrettifyLoadingProps = { | ||
card: boolean; | ||
baseTokenCardPrettifyLoadingProps: TBaseTokenCardBooleanSet; | ||
export type TBaseTokenCardBooleanSet = { | ||
balance: boolean; | ||
name: boolean; | ||
description: boolean; | ||
image: boolean; | ||
address: boolean; | ||
}; | ||
|
||
export const DefaultTokenCard = ({ | ||
export const BaseTokenCard = ({ | ||
token, | ||
address, | ||
imageProperties, | ||
prettifyLoadingProps, | ||
propertiesClasses, | ||
renderProps, | ||
}: TTokenCardProps) => { | ||
const output = ( | ||
<> | ||
<BaseTokenCard | ||
token={token} | ||
imageProperties={imageProperties} | ||
propertiesClasses={propertiesClasses?.baseTokenCardPropertyClasses} | ||
prettifyLoadingProps={prettifyLoadingProps?.baseTokenCardPrettifyLoadingProps} | ||
renderProps={renderProps} | ||
/> | ||
</> | ||
); | ||
|
||
prettifyLoadingProps, | ||
renderProps = { balance: true, image: true, name: true, description: true, address: true }, | ||
}: TTokenProps) => { | ||
return ( | ||
<div className={propertiesClasses?.card}> | ||
{prettifyLoadingProps?.card ? ( | ||
token?.image !== undefined && | ||
token?.balance !== undefined && | ||
token?.name !== undefined && | ||
token?.description !== undefined ? ( | ||
<div>{output}</div> | ||
) : ( | ||
<>Loading Token...</> | ||
) | ||
<> | ||
{renderProps.balance ? ( | ||
<BalanceCard | ||
value={token.balance} | ||
propertyClasses={propertiesClasses?.balance} | ||
prettifyLoading={prettifyLoadingProps?.balance} | ||
></BalanceCard> | ||
) : ( | ||
<div>{output}</div> | ||
<></> | ||
)} | ||
</div> | ||
{renderProps.image ? ( | ||
<ImageCard | ||
value={token.image} | ||
imageProperties={imageProperties} | ||
propertyClasses={propertiesClasses?.image} | ||
prettifyLoading={prettifyLoadingProps?.image} | ||
></ImageCard> | ||
) : ( | ||
<></> | ||
)} | ||
{renderProps.name ? ( | ||
<StringCard | ||
value={token.name} | ||
propertyClasses={propertiesClasses?.name} | ||
prettifyLoading={prettifyLoadingProps?.name} | ||
></StringCard> | ||
) : ( | ||
<></> | ||
)} | ||
{renderProps.description ? ( | ||
<StringCard | ||
value={token.description} | ||
propertyClasses={propertiesClasses?.description} | ||
prettifyLoading={prettifyLoadingProps?.description} | ||
></StringCard> | ||
) : ( | ||
<></> | ||
)} | ||
{renderProps.address ? <Address address={address} propertyClasses={propertiesClasses?.address}></Address> : <></>} | ||
</> | ||
); | ||
}; |
62 changes: 62 additions & 0 deletions
62
packages/nextjs/components/rep-tokens-demo/tokens/token-card/TokenCardWithContainer.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,62 @@ | ||
import { Token } from "../Hooks"; | ||
import { ImageProperties } from "./ImageCard"; | ||
import { BaseTokenCard, TBaseTokenCardBooleanSet, TBaseTokenCardPropertiesClasses } from "./TokenCard"; | ||
|
||
export interface TTokenCardProps { | ||
token: Token; | ||
address?: string; | ||
imageProperties?: ImageProperties; | ||
propertiesClasses?: TTokenCardPropertiesClasses; | ||
prettifyLoadingProps?: TTokenCardPrettifyLoadingProps; | ||
renderProps?: TBaseTokenCardBooleanSet; | ||
} | ||
|
||
export type TTokenCardPropertiesClasses = { | ||
card: string; | ||
baseTokenCardPropertyClasses?: TBaseTokenCardPropertiesClasses; | ||
}; | ||
|
||
export type TTokenCardPrettifyLoadingProps = { | ||
card: boolean; | ||
baseTokenCardPrettifyLoadingProps: TBaseTokenCardBooleanSet; | ||
}; | ||
|
||
export const DefaultTokenCard = ({ | ||
token, | ||
address, | ||
imageProperties, | ||
prettifyLoadingProps, | ||
propertiesClasses, | ||
renderProps, | ||
}: TTokenCardProps) => { | ||
const output = ( | ||
<> | ||
<BaseTokenCard | ||
token={token} | ||
address={address} | ||
imageProperties={imageProperties} | ||
propertiesClasses={propertiesClasses?.baseTokenCardPropertyClasses} | ||
prettifyLoadingProps={prettifyLoadingProps?.baseTokenCardPrettifyLoadingProps} | ||
renderProps={renderProps} | ||
/> | ||
</> | ||
); | ||
|
||
return ( | ||
<div className={propertiesClasses?.card}> | ||
{prettifyLoadingProps?.card ? ( | ||
token?.image !== undefined && | ||
token?.balance !== undefined && | ||
token?.name !== undefined && | ||
token?.description !== undefined && | ||
address !== undefined ? ( | ||
<div>{output}</div> | ||
) : ( | ||
<>Loading Token...</> | ||
) | ||
) : ( | ||
<div>{output}</div> | ||
)} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.