From 1a8cc142da6e60bfa97b5333f4dda8ace0762769 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Thu, 28 Nov 2024 09:33:48 +0100 Subject: [PATCH] feat: ChainIndicator component --- public/chainLogos/eth.svg | 1 + .../requirements/ChainIndicator.tsx | 16 ++++++++++++++++ src/components/requirements/DataBlock.tsx | 4 +--- src/components/ui/Badge.tsx | 2 +- src/config/chains.ts | 19 +++++++++++++++++++ .../requirements/ChainIndicator.stories.tsx | 17 +++++++++++++++++ 6 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 public/chainLogos/eth.svg create mode 100644 src/components/requirements/ChainIndicator.tsx create mode 100644 src/config/chains.ts create mode 100644 src/stories/requirements/ChainIndicator.stories.tsx diff --git a/public/chainLogos/eth.svg b/public/chainLogos/eth.svg new file mode 100644 index 0000000000..1f9ad00f9f --- /dev/null +++ b/public/chainLogos/eth.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/requirements/ChainIndicator.tsx b/src/components/requirements/ChainIndicator.tsx new file mode 100644 index 0000000000..bcc6d464da --- /dev/null +++ b/src/components/requirements/ChainIndicator.tsx @@ -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"] }) => ( + + {CHAINS[chain].name} + {CHAINS[chain].name} + +); diff --git a/src/components/requirements/DataBlock.tsx b/src/components/requirements/DataBlock.tsx index a752611585..6411a06eaf 100644 --- a/src/components/requirements/DataBlock.tsx +++ b/src/components/requirements/DataBlock.tsx @@ -12,7 +12,7 @@ type Props = { error?: string; }; -const DataBlock = ({ +export const DataBlock = ({ isLoading, error, children, @@ -38,5 +38,3 @@ const DataBlock = ({ ); }; - -export { DataBlock }; diff --git a/src/components/ui/Badge.tsx b/src/components/ui/Badge.tsx index 10a0e1b0fd..f81b6a5e8d 100644 --- a/src/components/ui/Badge.tsx +++ b/src/components/ui/Badge.tsx @@ -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", }, diff --git a/src/config/chains.ts b/src/config/chains.ts new file mode 100644 index 0000000000..71f2a3b953 --- /dev/null +++ b/src/config/chains.ts @@ -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; + } +>; diff --git a/src/stories/requirements/ChainIndicator.stories.tsx b/src/stories/requirements/ChainIndicator.stories.tsx new file mode 100644 index 0000000000..a032a29bdf --- /dev/null +++ b/src/stories/requirements/ChainIndicator.stories.tsx @@ -0,0 +1,17 @@ +import { ChainIndicator } from "@/components/requirements/ChainIndicator"; +import type { Meta, StoryObj } from "@storybook/react"; + +const meta: Meta = { + title: "Requirement building blocks/ChainIndicator", + component: ChainIndicator, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + chain: 1, + }, +};