Skip to content

Commit

Permalink
include more chain logos (#151)
Browse files Browse the repository at this point in the history
* add additional chain icons

* add chain test page

* testbench code style

* more logos

* remove duplicate

* fix type

* useChains

* testnet icon cleanup

* testbench cleanup

* testbench cleanup

* remove duplicate testbench data
  • Loading branch information
lochie authored Mar 9, 2023
1 parent 9592da1 commit 7034f7f
Show file tree
Hide file tree
Showing 5 changed files with 795 additions and 34 deletions.
113 changes: 113 additions & 0 deletions examples/testbench/src/pages/chains.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import type { NextPage } from 'next';
import Link from 'next/link';

import { useEffect, useState } from 'react';

import { ConnectKitButton, ChainIcon, useChains } from 'connectkit';

import { useNetwork } from 'wagmi';
import * as wagmiChains from 'wagmi/chains';
const allChains = Object.keys(wagmiChains).map(
(key) => wagmiChains[key as keyof typeof wagmiChains]
);

const Home: NextPage = () => {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);

const [randomChainId, setRandomChainId] = useState(1);
useEffect(() => {
const interval = setInterval(() => {
setRandomChainId(
allChains[Math.floor(Math.random() * allChains.length)].id
);
}, 1000);
return () => clearInterval(interval);
}, []);

const { chain } = useNetwork();
const chains = useChains();

if (!mounted) return null;

return (
<>
<main>
<div className="panel">
<h1>Chains</h1>
<h2>Connected to</h2>
<ChainIcon id={chain?.id} unsupported={chain?.unsupported} />
<h2>Configured/Supported Chains</h2>
<div style={{ display: 'flex', gap: 8 }}>
{chains.map((chain) => (
<ChainIcon key={chain.id} id={chain.id} />
))}
</div>
<h2>{`<ChainIcon /> Component`}</h2>
<div style={{ display: 'flex', gap: 8 }}>
<ChainIcon id={10} size={16} />
<ChainIcon id={10} size={16} unsupported />
<ChainIcon id={10} radius={8} size={16} unsupported />
<ChainIcon id={10} radius={'0'} size={16} unsupported />
</div>
<div style={{ display: 'flex', gap: 8 }}>
<ChainIcon id={42161} />
<ChainIcon id={42161} unsupported />
<ChainIcon id={42161} radius={8} unsupported />
<ChainIcon id={42161} radius={'0'} unsupported />
</div>
<div style={{ display: 'flex', gap: 8 }}>
<ChainIcon id={137} size={'32'} />
<ChainIcon id={137} size={32} unsupported />
<ChainIcon id={137} radius={8} size={32} unsupported />
<ChainIcon id={137} radius={'0'} size={32} unsupported />
</div>
<div style={{ display: 'flex', gap: 8 }}>
<ChainIcon id={43113} size={64} />
<ChainIcon id={43113} size={64} unsupported />
<ChainIcon id={43113} radius={8} size={64} unsupported />
<ChainIcon id={43113} radius={'0'} size={64} unsupported />
</div>
<div
style={{
aspectRatio: '1/1',
resize: 'horizontal',
width: 64,
overflow: 'auto',
}}
>
<ChainIcon id={randomChainId} size={'100%'} />
</div>
</div>
<div className="panel">
<h2>All Chains</h2>
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
gap: 8,
}}
>
{allChains.map((chain) => (
<div
key={chain.id}
style={{ display: 'flex', gap: 8, alignItems: 'center' }}
>
<ChainIcon id={chain.id} size={42} />
<span>
{chain.name} <code>{chain.id}</code>
</span>
</div>
))}
</div>
</div>
</main>
<aside>
<Link href="/">&larr; Testbench</Link>
<ConnectKitButton />
</aside>
</>
);
};

export default Home;
10 changes: 8 additions & 2 deletions examples/testbench/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ import {
useConnect,
useDisconnect,
} from 'wagmi';
import { Chain } from 'wagmi/chains';
import * as wagmiChains from 'wagmi/chains';

import { useTestBench } from '../TestbenchProvider';
import { Checkbox, Textbox, Select, SelectProps } from '../components/inputs';

import CustomAvatar from '../components/CustomAvatar';
import CustomSIWEButton from '../components/CustomSIWEButton';

const allChains = Object.keys(wagmiChains).map(
(key) => wagmiChains[key as keyof typeof wagmiChains]
);

/** TODO: import this data from the connectkit module */
const themes: SelectProps[] = [
{ label: 'Auto', value: 'auto' },
Expand Down Expand Up @@ -305,10 +310,11 @@ const Home: NextPage = () => {
</div>
<h2>dApps configured chains</h2>
<div style={{ display: 'flex', gap: 8 }}>
{chains.map((chain: Chain) => (
{chains.map((chain: wagmiChains.Chain) => (
<ChainIcon key={chain.id} id={chain.id} />
))}
</div>
<Link href="/chains">Chains Testbench &rarr;</Link>
</div>

<div className="panel">
Expand Down
15 changes: 15 additions & 0 deletions examples/testbench/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ main {
aside {
z-index: 2147483647;
position: fixed;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
overflow-x: hidden;
overflow-y: scroll;
top: 0;
Expand All @@ -79,6 +83,17 @@ aside {
padding: 32px;
background: #fff;
}

code {
padding: 2px 4px;
border-radius: 4px;
color: gray;
background: #f5f5f5;
font-size: 12px;
font-weight: bold;
font-family: 'Courier New', Courier, monospace;
}

@media screen and (max-width: 768px) {
main {
padding: 32px;
Expand Down
Loading

4 comments on commit 7034f7f

@vercel
Copy link

@vercel vercel bot commented on 7034f7f Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-vite – ./

connectkit-vite-git-main-lfe.vercel.app
connectkit-vite.vercel.app
connectkit-vite-lfe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 7034f7f Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-cra – ./

connectkit-cra.vercel.app
connectkit-cra-git-main-lfe.vercel.app
connectkit-cra-lfe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 7034f7f Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-nextjs – ./

connectkit-nextjs-lfe.vercel.app
connectkit-nextjs.vercel.app
connectkit-nextjs-git-main-lfe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 7034f7f Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-testbench – ./

connectkit-testbench-git-main-lfe.vercel.app
connectkit-testbench-lfe.vercel.app
connectkit-testbench.vercel.app

Please sign in to comment.