Skip to content

Commit

Permalink
feat: ChainIndicator component
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Nov 28, 2024
1 parent 9da305d commit 1a8cc14
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions public/chainLogos/eth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/components/requirements/ChainIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Badge } from "@/components/ui/Badge";
import { CHAINS } from "@/config/chains";
import type { Register } from "wagmi";

export const ChainIndicator = ({
chain,
}: { chain: Register["config"]["chains"][number]["id"] }) => (
<Badge size="sm">
<img
src={CHAINS[chain].icon}
alt={CHAINS[chain].name}
className="size-3.5"
/>
<span>{CHAINS[chain].name}</span>
</Badge>
);
4 changes: 1 addition & 3 deletions src/components/requirements/DataBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Props = {
error?: string;
};

const DataBlock = ({
export const DataBlock = ({
isLoading,
error,
children,
Expand All @@ -38,5 +38,3 @@ const DataBlock = ({
</Tooltip>
);
};

export { DataBlock };
2 changes: 1 addition & 1 deletion src/components/ui/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const badgeVariants = cva(
{
variants: {
size: {
sm: "text-xs h-5",
sm: "text-xs h-5 gap-1",
md: "text-sm h-6",
lg: "text-base h-8",
},
Expand Down
19 changes: 19 additions & 0 deletions src/config/chains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { mainnet, sepolia } from "viem/chains";
import type { Register } from "wagmi";

export const CHAINS = {
[mainnet.id]: {
name: mainnet.name,
icon: "/chainLogos/eth.svg",
},
[sepolia.id]: {
name: sepolia.name,
icon: "/chainLogos/eth.svg",
},
} satisfies Record<
Register["config"]["chains"][number]["id"],
{
name: string;
icon: string;
}
>;
17 changes: 17 additions & 0 deletions src/stories/requirements/ChainIndicator.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ChainIndicator } from "@/components/requirements/ChainIndicator";
import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof ChainIndicator> = {
title: "Requirement building blocks/ChainIndicator",
component: ChainIndicator,
};

export default meta;

type Story = StoryObj<typeof ChainIndicator>;

export const Default: Story = {
args: {
chain: 1,
},
};

0 comments on commit 1a8cc14

Please sign in to comment.