Skip to content

Commit

Permalink
feat: add trashy ui
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Feb 7, 2024
1 parent e1faa69 commit 6ef5114
Show file tree
Hide file tree
Showing 19 changed files with 3,567 additions and 1 deletion.
3 changes: 3 additions & 0 deletions interface/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions interface/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Binary file added interface/app/favicon.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions interface/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
26 changes: 26 additions & 0 deletions interface/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

const inter = Inter({
variable: "--font-inter",
subsets: ["latin"],
display: "swap",
});

export const metadata: Metadata = {
title: "Aave address book",
description: "An interactive list of all the addresses in the aave ecosystem",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={inter.variable}>{children}</body>
</html>
);
}
60 changes: 60 additions & 0 deletions interface/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import Image from "next/image";
import * as _addresses from "../../src/ts/AaveAddressBook";
import { CHAIN_ID_CLIENT_MAP } from "@bgd-labs/js-utils";
import { AwesomeSearch } from "@/components/AwesomeSearch";
import Link from "next/link";

export type Address = { path: string; value: string; link: string };

// TODO: flatten nested as well
const addresses = Object.entries(_addresses).reduce((acc, [root, nested]) => {
if (/ABI/.test(root)) return acc;
Object.keys(nested).map((key) => {
if (typeof nested[key as keyof typeof nested] === "string") {
const value = nested[key as keyof typeof nested];
if (!nested.CHAIN_ID) console.log(root);
acc.push({
path: `${root} ${key}`,
value: value,
link: `${CHAIN_ID_CLIENT_MAP[nested.CHAIN_ID]?.chain?.blockExplorers
?.default.url}/address/${value}`,
});
}
});
return acc;
}, [] as Address[]);

export default function Home() {
return (
<main className="relative flex min-h-screen flex-col items-center justify-center">
<h1 className="pt-4 pb-8 bg-gradient-to-br from-black via-[#171717] to-[#4b4b4b] bg-clip-text text-center text-4xl font-medium tracking-tight text-transparent md:text-7xl">
Aave address book
</h1>
<AwesomeSearch addresses={addresses} />
<div className="flex justify-center space-x-5 pt-10 mt-10 border-t border-gray-300 w-full max-w-xl text-gray-600">
<Link
href="https://bgdlabs.com/"
className="font-medium underline underline-offset-4 hover:text-black transition-colors"
>
BGD labs
</Link>
</div>

<div className="sm:absolute sm:bottom-0 w-full px-20 py-10 flex justify-between">
<Link
href="https://github.com/bgd-labs/aave-address-book"
className="flex items-center space-x-2"
>
<Image
src="/github.svg"
alt="GitHub Logo"
width={24}
height={24}
priority
/>
<p className="font-light">Source</p>
</Link>
</div>
</main>
);
}
66 changes: 66 additions & 0 deletions interface/components/AwesomeSearch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"use client";
import { Address } from "@/app/page";
import Fuse from "fuse.js";
import { useRef, useState } from "react";

const fuseOptions = {
// isCaseSensitive: false,
// includeScore: false,
// shouldSort: true,
// includeMatches: false,
// findAllMatches: true,
// minMatchCharLength: 1,
// location: 0,
threshold: 0.4,
// distance: 100,
// useExtendedSearch: false,
// ignoreLocation: false,
// ignoreFieldNorm: false,
// fieldNormWeight: 1,
keys: [{ name: "path", weight: 2 }, "value"],
};

export function AwesomeSearch({ addresses }: { addresses: Address[] }) {
const fuse = useRef(new Fuse(addresses, fuseOptions));
const [needle, setNeedle] = useState<string>("");

const matches = fuse.current.search(needle);

return (
<ul className="divide-y divide-slate-100">
<div className="bg-white/30 p-12 shadow-xl ring-1 ring-gray-900/5 rounded-lg backdrop-blur-lg max-w-xl mx-auto w-full">
<div className="flex justify-between items-center mb-4">
<div className="space-y-1">
<input
className="focus:ring-2 focus:ring-blue-500 focus:outline-none appearance-none w-full text-sm leading-6 text-slate-900 placeholder-slate-400 rounded-md py-2 pl-10 ring-1 ring-slate-200 shadow-sm"
type="text"
aria-label="Filter addresses"
placeholder="Filter addresses..."
value={needle}
onChange={(e) => setNeedle(e.target.value)}
/>
</div>
</div>
<div className="divide-y divide-gray-900/5">
{matches.map((match) => (
<div
key={match.refIndex}
className="flex items-center justify-between py-3"
>
<div className="flex items-center space-x-4">
<div className="space-y-1">
<p className="font-medium leading-none">{match.item.path}</p>
<p className="text-sm text-gray-500">
<a href={addresses[match.refIndex].link} target="_blank">
{match.item.value}
</a>
</p>
</div>
</div>
</div>
))}
</div>
</div>
</ul>
);
}
4 changes: 4 additions & 0 deletions interface/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
29 changes: 29 additions & 0 deletions interface/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "aave-address-book",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@bgd-labs/js-utils": "^1.1.1",
"fuse.js": "^7.0.0",
"next": "14.1.0",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
Loading

0 comments on commit 6ef5114

Please sign in to comment.