Skip to content

Commit

Permalink
Merge pull request #227 from cosmos/hkeep/update-deps
Browse files Browse the repository at this point in the history
Update deps and minor housekeeping
  • Loading branch information
abefernan authored Jun 27, 2024
2 parents e7110d9 + 838e1df commit 8b3f85c
Show file tree
Hide file tree
Showing 16 changed files with 2,247 additions and 3,048 deletions.
14 changes: 12 additions & 2 deletions components/ChainConnect/ChainsGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainInfo } from "@/context/ChainsContext/types";
import { useEffect, useRef, useState } from "react";
import { CommandGroup } from "../ui/command";
import ChainItem from "./ChainItem";
import { useRef } from "react";

interface ChainsGroupProps {
readonly chains: readonly ChainInfo[];
Expand All @@ -11,6 +11,16 @@ interface ChainsGroupProps {

export default function ChainsGroup({ chains, heading, emptyMsg }: ChainsGroupProps) {
const containerRef = useRef<HTMLDivElement>(null);
const [numChainsToRender, setNumChainsToRender] = useState(10);

useEffect(() => {
// Unblock the main thread
setTimeout(() => {
if (numChainsToRender < chains.length) {
setNumChainsToRender((prev) => prev + 10);
}
}, 0);
}, [chains.length, numChainsToRender]);

return (
<CommandGroup
Expand All @@ -19,7 +29,7 @@ export default function ChainsGroup({ chains, heading, emptyMsg }: ChainsGroupPr
>
{chains.length ? (
<div ref={containerRef} className="flex flex-wrap gap-2">
{chains.map((chain) => (
{chains.slice(0, numChainsToRender).map((chain) => (
<ChainItem
key={chain.registryName}
chain={chain}
Expand Down
11 changes: 7 additions & 4 deletions components/ChainConnect/ChooseChain.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { useChains } from "@/context/ChainsContext";
import { getRecentChainsFromStorage } from "@/context/ChainsContext/storage";
import { ChainInfo } from "@/context/ChainsContext/types";
import { useLayoutEffect, useState } from "react";
import { useEffect, useState } from "react";
import { Command, CommandEmpty, CommandInput, CommandList, CommandSeparator } from "../ui/command";
import ChainsGroup from "./ChainsGroup";

export default function ChooseChain() {
const { chains } = useChains();
const [recentChains, setRecentChains] = useState<readonly ChainInfo[]>([]);

useLayoutEffect(() => {
const newRecentChains = getRecentChainsFromStorage(chains);
setRecentChains(newRecentChains);
useEffect(() => {
// Unblock the main thread
setTimeout(() => {
const newRecentChains = getRecentChainsFromStorage(chains);
setRecentChains(newRecentChains);
}, 0);
}, [chains]);

return (
Expand Down
49 changes: 30 additions & 19 deletions components/ChainConnect/CustomChainForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { setNewConnection } from "@/context/ChainsContext/helpers";
import { RegistryAsset } from "@/types/chainRegistry";
import { zodResolver } from "@hookform/resolvers/zod";
import dynamic from "next/dynamic";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import * as z from "zod";
import { Button } from "../ui/button";
Expand All @@ -21,6 +22,14 @@ const JsonEditor = dynamic(() => import("../inputs/JsonEditor"), { ssr: false })

export default function CustomChainForm() {
const { chain, chains, newConnection, chainsDispatch } = useChains();
const [showAssetsEditor, setShowAssetsEditor] = useState(false);

useEffect(() => {
// Unblock the main thread
setTimeout(() => {
setShowAssetsEditor(true);
}, 0);
}, []);

const formSchema = z
.object({
Expand Down Expand Up @@ -246,25 +255,27 @@ export default function CustomChainForm() {
</FormItem>
)}
/>
<FormField
name="assets"
render={({ field }) => (
<FormItem className="mt-4">
<FormLabel>Assets</FormLabel>
<FormControl>
<div>
<JsonEditor
content={{ text: field.value }}
onChange={(newMsgContent) => {
field.onChange("text" in newMsgContent ? newMsgContent.text ?? "{}" : "{}");
}}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{showAssetsEditor ? (
<FormField
name="assets"
render={({ field }) => (
<FormItem className="mt-4">
<FormLabel>Assets</FormLabel>
<FormControl>
<div>
<JsonEditor
content={{ text: field.value }}
onChange={(newMsgContent) => {
field.onChange("text" in newMsgContent ? newMsgContent.text ?? "{}" : "{}");
}}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
) : null}
<Button type="submit" className="mt-4">
Submit
</Button>
Expand Down
4 changes: 3 additions & 1 deletion components/ChainConnect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useChains } from "@/context/ChainsContext";
import { setNewConnection } from "@/context/ChainsContext/helpers";
import { useState } from "react";
import { Dialog, DialogContent, DialogHeader } from "../ui/dialog";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog";
import { Tabs, TabsContent, TabsList } from "../ui/tabs";
import ChooseChain from "./ChooseChain";
import ConfirmConnection from "./ConfirmConnection";
Expand All @@ -25,9 +25,11 @@ export default function ChainConnect() {
>
<DialogButton />
<DialogContent
aria-describedby={undefined}
className={"max-h-[75%] max-w-[75%] overflow-y-auto bg-fuchsia-900"}
style={newConnection.action === "confirm" ? { width: "auto" } : {}}
>
<DialogTitle className="hidden">Connect to a new chain</DialogTitle>
{newConnection.action === "confirm" ? (
<ConfirmConnection closeDialog={() => setDialogOpen(false)} />
) : (
Expand Down
57 changes: 0 additions & 57 deletions components/dashboard/date-range-picker.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions components/dashboard/main-nav.tsx

This file was deleted.

72 changes: 0 additions & 72 deletions components/dashboard/overview.tsx

This file was deleted.

63 changes: 0 additions & 63 deletions components/dashboard/recent-sales.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions components/dashboard/search.tsx

This file was deleted.

Loading

0 comments on commit 8b3f85c

Please sign in to comment.