Skip to content

Commit

Permalink
add: chains
Browse files Browse the repository at this point in the history
  • Loading branch information
clmntsnr committed Dec 3, 2024
1 parent 3a66bd3 commit 2dbbee0
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 6 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/dappkit
Submodule dappkit updated 47 files
+1 −1 src/components.ts
+2 −2 src/components/VisuallyHidden.tsx
+5 −4 src/components/dapp/Countdown.tsx
+9 −4 src/components/dapp/TransactionButton.tsx
+8 −8 src/components/dapp/TransactionHelper.tsx
+62 −27 src/components/dapp/WalletButton.tsx
+12 −6 src/components/dapp/WalletConnectors.tsx
+13 −8 src/components/extenders/Card.tsx
+32 −10 src/components/extenders/Dropdown.tsx
+3 −1 src/components/extenders/Group.tsx
+34 −8 src/components/extenders/Modal.tsx
+66 −35 src/components/extenders/Select.tsx
+11 −3 src/components/layout/Container.tsx
+29 −8 src/components/primitives/Accordion.tsx
+1 −1 src/components/primitives/Bar.tsx
+10 −6 src/components/primitives/Box.tsx
+22 −7 src/components/primitives/Button.tsx
+17 −4 src/components/primitives/Checkbox.tsx
+11 −4 src/components/primitives/Collapsible.tsx
+62 −8 src/components/primitives/Divider.tsx
+24 −10 src/components/primitives/Hash.tsx
+17 −3 src/components/primitives/Icon.tsx
+46 −15 src/components/primitives/Input.tsx
+1 −1 src/components/primitives/List.tsx
+4 −3 src/components/primitives/PrimitiveTag.tsx
+5 −2 src/components/primitives/Scroll.tsx
+25 −7 src/components/primitives/Slider.tsx
+73 −25 src/components/primitives/Table.tsx
+27 −5 src/components/primitives/Text.tsx
+43 −7 src/components/primitives/Title.tsx
+9 −4 src/components/primitives/Tooltip.tsx
+12 −4 src/components/primitives/Value.tsx
+100 −25 src/config/themes.ts
+7 −12 src/context/Dapp.context.tsx
+40 −16 src/context/Theme.context.tsx
+4 −4 src/context/Wallet.context.tsx
+7 −2 src/hooks/theming/OverrideTheme.tsx
+3 −3 src/hooks/theming/useThemableProps.tsx
+13 −4 src/hooks/theming/useThemedVariables.tsx
+21 −23 src/hooks/useClipboard.tsx
+6 −5 src/hooks/useWalletState.tsx
+4 −4 src/index.ts
+1 −1 src/style.css
+4 −4 src/theming/coloring.ts
+7 −9 src/utils/event.ts
+9 −9 src/utils/react.ts
+7 −4 src/utils/tailwind.ts
24 changes: 24 additions & 0 deletions src/components/element/chain/ChainLibrary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Chain } from "@merkl/api";
import { Group } from "dappkit";
import { useMemo } from "react";
import OpportunityPagination from "../opportunity/OpportunityPagination";
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>
);
}
11 changes: 11 additions & 0 deletions src/components/element/chain/ChainTable.tsx
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,
},
});
41 changes: 41 additions & 0 deletions src/components/element/chain/ChainTableRow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { Protocol, Chain } from "@merkl/api";
import { Link } from "@remix-run/react";
import { Button, Group, Icon, Value } 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>
);
}
2 changes: 1 addition & 1 deletion src/components/element/functions/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function SearchBar({ icon = false }: SearchBarProps) {
switch (category) {
case "chain":
return (
<Button to={`/chain/${results[i].name}`} size="lg" look="bold">
<Button to={`/chains/${results[i].name}`} size="lg" look="bold">
<Icon src={results[i].icon} /> {results[i].name}
</Button>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/element/opportunity/OpportunityTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function OpportunityTableRow({ hideTags, opportunity, className,
{tags
?.filter(({ type }) => !hideTags || hideTags.includes(type))
.map(tag => {
console.table(tag);
return <Tag key={`${tag.type}_${tag.value?.address ?? tag.value}`} {...tag} size="lg" />;
})}
</Group>
Expand Down
10 changes: 7 additions & 3 deletions src/routes/_merkl.chains.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ export default function Index() {
return (
<Hero
icons={[{ src: chain.icon }]}
breadcrumbs={[
{ link: "/chains", name: "Chains" },
{ link: "/", name: chain.name },
]}
navigation={{ label: "Back to opportunities", link: "/" }}
title={chain.name}
description={"Lorem ipsum something cool about the chain"}
tabs={[
{ label: "Opportunities", link: `/chain/${label?.toLowerCase()}` },
{ label: "Opportunities", link: `/chains/${label?.toLowerCase()}` },
{
label: "Leaderboard",
link: `/chain/${label?.toLowerCase()}/leaderboard`,
link: `/chains/${label?.toLowerCase()}/leaderboard`,
},
{
label: "Analytics",
link: `/chain/${label?.toLowerCase()}/analytics`,
link: `/chains/${label?.toLowerCase()}/analytics`,
},
]}>
<Outlet />
Expand Down
22 changes: 22 additions & 0 deletions src/routes/_merkl.chains.(all).(chains).tsx
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>
);
}
14 changes: 14 additions & 0 deletions src/routes/_merkl.chains.(all).tsx
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>
);
}

0 comments on commit 2dbbee0

Please sign in to comment.