Skip to content

Commit

Permalink
component breakdown (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnani73 authored May 14, 2024
1 parent fa54040 commit 16d29d2
Show file tree
Hide file tree
Showing 149 changed files with 5,070 additions and 5,789 deletions.
4 changes: 1 addition & 3 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const config: StorybookConfig = {
typescript: {
reactDocgen: "react-docgen-typescript",
},
docs: {
autodocs: "tag",
},
docs: {},
staticDirs: ["../src/static"],
};
export default config;
1,172 changes: 657 additions & 515 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
"devDependencies": {
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "^9.0.0",
"@storybook/addon-essentials": "^8.0.8",
"@storybook/addon-interactions": "^8.0.8",
"@storybook/addon-links": "^8.0.8",
"@storybook/blocks": "^8.0.8",
"@storybook/manager-api": "^8.0.8",
"@storybook/react": "^8.0.8",
"@storybook/react-vite": "^8.0.8",
"@storybook/test": "^8.0.8",
"@storybook/theming": "^8.0.8",
"@storybook/addon-essentials": "^8.1.0",
"@storybook/addon-interactions": "^8.1.0",
"@storybook/addon-links": "^8.1.0",
"@storybook/blocks": "^8.1.0",
"@storybook/manager-api": "^8.1.0",
"@storybook/react": "^8.1.0",
"@storybook/react-vite": "^8.1.0",
"@storybook/test": "^8.1.0",
"@storybook/theming": "^8.1.0",
"@tanstack/react-table": "^8.15.3",
"@tremor/react": "^3.15.0",
"@types/node": "^20.12.7",
Expand All @@ -73,7 +73,7 @@
"prettier": "^3.1.0",
"prettier-plugin-tailwindcss": "^0.5.7",
"react-docgen-typescript": "^2.2.2",
"storybook": "^8.0.8",
"storybook": "^8.1.0",
"tailwind-merge": "^2.2.2",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
Expand Down
18 changes: 18 additions & 0 deletions src/components/Atoms/AddressCard/AddressCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type Meta, type StoryObj } from "@storybook/react";
import { AddressCard as AddressCardComponent } from "./AddressCard";

type Story = StoryObj<typeof AddressCardComponent>;

const meta: Meta<typeof AddressCardComponent> = {
title: "Atoms/Address Card",
component: AddressCardComponent,
};

export default meta;

export const AddressCard: Story = {
args: {
address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
type: "effigy",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { useToast } from "../../../utils/hooks";
import { AddressAvatar } from "../../Atoms";
import { IconWrapper } from "../../Shared";
import { GRK_SIZES } from "@/utils/constants/shared.constants";
import { type AccountCardProps } from "@/utils/types/molecules.types";
import { type AddressCardProps } from "@/utils/types/atoms.types";

export const AccountCard: React.FC<AccountCardProps> = ({
export const AddressCard: React.FC<AddressCardProps> = ({
address,
type = "effigy",
name = "Unnamed Wallet",
Expand Down
55 changes: 55 additions & 0 deletions src/components/Atoms/NFT/NFT.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { type Meta, type StoryObj } from "@storybook/react";
import { NFT as NFTComponent } from "./NFT";

const meta: Meta<typeof NFTComponent> = {
title: "Atoms/NFT",
component: NFTComponent,
};

export default meta;

type Story = StoryObj<typeof NFTComponent>;

export const NFT: Story = {
args: {
src: "https://nftassets.covalenthq.com/cdn-cgi/image/width=512,fit/bbf729c26915a469c16249db7c8af10e3db93765d26be4ec54426d0e5dc511d0.png",
attributes: [
{
trait_type: "Background",
value: "Purple Pink",
},
{
trait_type: "Skin Tone",
value: "Deep Neutral",
},
{
trait_type: "Eyes",
value: "Brown Straight",
},
{
trait_type: "Facial Features",
value: "Feline Eyes",
},
{
trait_type: "Hairstyle",
value: "Silver",
},
{
trait_type: "Clothes",
value: "Polka Dot Top",
},
{
trait_type: "Earrings",
value: "Flower Power",
},
{
trait_type: "Mouth",
value: "Slight Smile",
},
{
trait_type: "Lips Color",
value: "Passion Red",
},
],
},
};
84 changes: 84 additions & 0 deletions src/components/Atoms/NFT/NFT.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { type NFTProps } from "@/utils/types/atoms.types";
import { Card } from "@tremor/react";
import { CardContent, CardDescription } from "@/components/ui/card";
import { GRK_SIZES, defaultErrorNFT } from "@/utils/constants/shared.constants";
import { CardDetail } from "@/components/Shared";
import { TokenAvatar } from "../TokenAvatar/TokenAvatar";
import { useGoldRush } from "@/utils/store";
import { type ChainItem } from "@covalenthq/client-sdk";
import { useMemo } from "react";

export const NFT: React.FC<NFTProps> = ({
collection_name,
token_id,
attributes = [],
src,
children = null,
chain_name = null,
}) => {
const { chains } = useGoldRush();

const chain = useMemo<ChainItem | null>(
() => chains?.find((o) => o.name === chain_name) ?? null,
[chains, chain_name]
);

return (
<Card className="w-64 overflow-hidden break-all bg-background-light p-0 dark:bg-background-dark">
<CardContent className="relative rounded transition-all">
<img
className="block h-64 w-64 object-cover"
src={src || defaultErrorNFT}
onError={(e) => {
e.currentTarget.src = defaultErrorNFT;
}}
/>

{chain ? (
<div
className="absolute -bottom-4 right-2 flex h-9 w-9 items-center justify-center rounded-[100%] bg-background-light p-1 dark:bg-background-dark"
style={{
border: `2px solid `,
borderColor: `${chain.color_theme.hex}`,
}}
>
<TokenAvatar
is_chain_logo
size={GRK_SIZES.EXTRA_SMALL}
chain_color={chain.color_theme.hex}
token_url={chain?.logo_url}
/>
</div>
) : (
<></>
)}
</CardContent>

<CardDetail
heading={collection_name?.toUpperCase() ?? null}
content={token_id ? `#${token_id}` : null}
wrapperClassName="p-2"
/>

{children}

{attributes?.length ? (
<ul className="p-2 text-sm">
<CardDescription className="mb-1">
ATTRIBUTES
</CardDescription>

{attributes.map(({ trait_type, value }) => (
<li key={trait_type} className="flex justify-between">
<CardDescription>{trait_type}</CardDescription>

{value}
</li>
))}
</ul>
) : (
<></>
)}
</Card>
);
};
2 changes: 2 additions & 0 deletions src/components/Atoms/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { Address } from "./Address/Address";
export { AddressAvatar } from "./AddressAvatar/AddressAvatar";
export { AddressCard } from "./AddressCard/AddressCard";
export { NFT } from "./NFT/NFT";
export { TokenAvatar } from "./TokenAvatar/TokenAvatar";
18 changes: 0 additions & 18 deletions src/components/Molecules/AccountCard/AccountCard.stories.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type Meta, type StoryObj } from "@storybook/react";
import { AddressActivityDetails as AddressActivityDetailsComponent } from "./AddressActivityDetails";

type Story = StoryObj<typeof AddressActivityDetailsComponent>;

const meta: Meta<typeof AddressActivityDetailsComponent> = {
title: "Molecules/Address/Address Activity Details",
component: AddressActivityDetailsComponent,
};

export default meta;

export const AddressActivityDetails: Story = {
args: {
address: "ganeshswami.eth",
hide_no_activity: true,
},
};
Loading

0 comments on commit 16d29d2

Please sign in to comment.