-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from AngleProtocol/fix-low-hanging-fruits
add: chains
- Loading branch information
Showing
10 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
Submodule dappkit
updated
47 files
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,15 @@ | ||
import type { Chain } from "@merkl/api"; | ||
import { useMemo } from "react"; | ||
import { ChainTable } from "./ChainTable"; | ||
import ChainTableRow from "./ChainTableRow"; | ||
|
||
export type ChainLibraryProps = { | ||
chains: Chain[]; | ||
count?: number; | ||
}; | ||
|
||
export default function ChainLibrary({ chains, count }: ChainLibraryProps) { | ||
const rows = useMemo(() => chains?.map(c => <ChainTableRow key={`${c.id}`} chain={c} />), [chains]); | ||
|
||
return <ChainTable>{rows}</ChainTable>; | ||
} |
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,11 @@ | ||
import { createTable } from "dappkit"; | ||
|
||
export const [ChainTable, ChainRow, chainColumns] = createTable({ | ||
chain: { | ||
name: "CHAIN", | ||
size: "minmax(350px,1fr)", | ||
compact: "1fr", | ||
className: "justify-start", | ||
main: true, | ||
}, | ||
}); |
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,41 @@ | ||
import type { Chain } from "@merkl/api"; | ||
import { Link } from "@remix-run/react"; | ||
import { Group, Icon } from "dappkit"; | ||
import type { BoxProps } from "dappkit"; | ||
import { Title } from "dappkit"; | ||
import { mergeClass } from "dappkit"; | ||
import type { TagTypes } from "../Tag"; | ||
import { ChainRow } from "./ChainTable"; | ||
|
||
export type ChainTableRowProps = { | ||
hideTags?: (keyof TagTypes)[]; | ||
chain: Chain; | ||
} & BoxProps; | ||
|
||
export default function ChainTableRow({ hideTags, chain, className, ...props }: ChainTableRowProps) { | ||
console.log(chain); | ||
|
||
return ( | ||
<Link to={`/chains/${chain.name}`}> | ||
<ChainRow | ||
size="lg" | ||
content="sm" | ||
className={mergeClass("", className)} | ||
{...props} | ||
chainColumn={ | ||
<Group className="py-md flex-col w-full text-nowrap whitespace-nowrap text-ellipsis"> | ||
<Group className="text-nowrap whitespace-nowrap text-ellipsis min-w-0 flex-nowrap overflow-hidden max-w-full"> | ||
<Title | ||
h={3} | ||
size={4} | ||
className="text-nowrap flex gap-lg whitespace-nowrap text-ellipsis min-w-0 overflow-hidden"> | ||
<Icon src={chain.icon} /> | ||
{chain.name} | ||
</Title> | ||
</Group> | ||
</Group> | ||
} | ||
/> | ||
</Link> | ||
); | ||
} |
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
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
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
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,22 @@ | ||
import type { LoaderFunctionArgs } from "@remix-run/node"; | ||
import { json, useLoaderData } from "@remix-run/react"; | ||
import { Container, Space } from "packages/dappkit/src"; | ||
import { ChainService } from "src/api/services/chain.service"; | ||
import ChainLibrary from "src/components/element/chain/ChainLibrary"; | ||
|
||
export async function loader({ params: { id }, request }: LoaderFunctionArgs) { | ||
const chains = await ChainService.getAll(); | ||
|
||
return json({ chains, count: chains.length }); | ||
} | ||
|
||
export default function Index() { | ||
const { chains, count } = useLoaderData<typeof loader>(); | ||
|
||
return ( | ||
<Container> | ||
<Space size="xl" /> | ||
<ChainLibrary chains={chains} count={count} /> | ||
</Container> | ||
); | ||
} |
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,14 @@ | ||
import { Outlet } from "@remix-run/react"; | ||
import Hero from "src/components/composite/Hero"; | ||
|
||
export default function Index() { | ||
return ( | ||
<Hero | ||
icons={[{ remix: "RiExchange2Line" }]} | ||
title={"Chains"} | ||
breadcrumbs={[{ link: "/chains", name: "Chains" }]} | ||
description={"Chains integrated by Merkl"}> | ||
<Outlet /> | ||
</Hero> | ||
); | ||
} |