Skip to content

Commit

Permalink
Create Tangle Dapp - EVM Staking App (#1777)
Browse files Browse the repository at this point in the history
Co-authored-by: Trung-Tin Pham <[email protected]>
  • Loading branch information
devpavan04 and AtelyPham authored Oct 18, 2023
1 parent 896d4cc commit 2b2b4e0
Show file tree
Hide file tree
Showing 42 changed files with 535 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ apps/stats-dapp/graphql.schema.json
.direnv

# Generated by json files
/**/generated/**/*.json
/**/generated/**/*.json
3 changes: 1 addition & 2 deletions apps/hubble-stats/components/sideBar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import { type FC } from 'react';
import { SideBar as SideBarCmp } from '@webb-tools/webb-ui-components';

import { setSideBarCookieOnToggle } from './sideBarActions';
import { setSideBarCookieOnToggle } from '@webb-tools/webb-ui-components/next-utils';
import sideBarProps from './sideBarProps';

interface SideBarProps {
Expand Down
5 changes: 2 additions & 3 deletions apps/hubble-stats/containers/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { type PropsWithChildren, type FC } from 'react';
import { Footer } from '@webb-tools/webb-ui-components';

import { HeaderChipsContainer } from '..';
import { getSideBarStateFromCookie } from '../../components/sideBar/sideBarActions';
import { getSideBarStateFromCookie } from '@webb-tools/webb-ui-components/next-utils';
import { Breadcrumbs, SideBar, SideBarMenu } from '../../components';

const Layout: FC<PropsWithChildren> = ({ children }) => {
Expand All @@ -28,7 +27,7 @@ const Layout: FC<PropsWithChildren> = ({ children }) => {
</div>

{/* Footer */}
<Footer isMinimal className="mx-0 max-w-none py-12" />
<Footer isMinimal className="py-12 mx-0 max-w-none" />
</main>
</>
);
Expand Down
31 changes: 31 additions & 0 deletions apps/tangle-dapp/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"extends": [
"plugin:@nx/react-typescript",
"next",
"next/core-web-vitals",
"../../.eslintrc.json"
],
"ignorePatterns": ["!**/*", ".next/**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@next/next/no-html-link-for-pages": ["error", "apps/tangle-dapp/pages"]
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
],
"rules": {
"@next/next/no-html-link-for-pages": "off"
},
"env": {
"jest": true
}
}
4 changes: 4 additions & 0 deletions apps/tangle-dapp/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "../../../node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
19 changes: 19 additions & 0 deletions apps/tangle-dapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div align="center">
<a href="https://www.webb.tools/">

![Webb Logo](../../.github/assets/webb_banner_light.png#gh-light-mode-only)
![Webb Logo](../../.github/assets/webb_banner_dark.png#gh-dark-mode-only)
</a>

</div>

# Tangle Dapp - EVM Staking UI

<p align="left">
<strong>EVM Staking UI</strong>
<br />
</p>

## Run the Tangle Dapp

TBD
3 changes: 3 additions & 0 deletions apps/tangle-dapp/app/api/hello/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function GET(request: Request) {
return new Response('Hello, from API!');
}
55 changes: 55 additions & 0 deletions apps/tangle-dapp/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import '@webb-tools/webb-ui-components/tailwind.css';
import { Metadata } from 'next';
import { TANGLE_DAPP_URL } from '@webb-tools/webb-ui-components/constants';
import { Layout } from '../containers';
import NextThemeProvider from '@webb-tools/api-provider-environment/NextThemeProvider';

export const metadata: Metadata = {
title: {
default: 'Tangle Dapp',
template: 'Tangle Dapp | %s',
},
description: 'Welcome to Tangle Dapp!',
metadataBase: process.env.URL ? new URL(process.env.URL) : null,
openGraph: {
title: 'Tangle Dapp',
description: 'Welcome to Tangle Dapp!',
url: TANGLE_DAPP_URL,
siteName: 'Tangle Dapp',
images: [
{
alt: 'Optimized Og Image Alt',
height: 630,
url: 'https://webb-assets.s3.amazonaws.com/og-optimize.png',
width: 1200,
},
],
locale: 'en_US',
type: 'website',
},
themeColor: '#ffffff',
icons: {
icon: '/favicon.png',
},
twitter: {
card: 'summary_large_image',
title: 'Tangle Dapp',
description: 'Welcome to Tangle Dapp!',
},
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<body className="flex h-screen bg-body">
<NextThemeProvider>
<Layout>{children}</Layout>
</NextThemeProvider>
</body>
</html>
);
}
3 changes: 3 additions & 0 deletions apps/tangle-dapp/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function Index() {
return <div></div>;
}
1 change: 1 addition & 0 deletions apps/tangle-dapp/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sideBar';
23 changes: 23 additions & 0 deletions apps/tangle-dapp/components/sideBar/SideBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use client';

import { type FC } from 'react';
import { SideBar as SideBarCmp } from '@webb-tools/webb-ui-components';
import { setSideBarCookieOnToggle } from '@webb-tools/webb-ui-components/next-utils';
import SideBarProps from './sideBarProps';

interface SideBarProps {
isExpandedAtDefault?: boolean;
}

const SideBar: FC<SideBarProps> = ({ isExpandedAtDefault }) => {
return (
<SideBarCmp
{...SideBarProps}
className="hidden lg:block"
isExpandedAtDefault={isExpandedAtDefault}
onSideBarToggle={() => setSideBarCookieOnToggle()}
/>
);
};

export default SideBar;
12 changes: 12 additions & 0 deletions apps/tangle-dapp/components/sideBar/SideBarMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use client';

import { FC } from 'react';
import { SideBarMenu as SideBarMenuCmp } from '@webb-tools/webb-ui-components';

import sideBarProps from './sideBarProps';

const SideBarMenu: FC = () => {
return <SideBarMenuCmp {...sideBarProps} className="lg:hidden" />;
};

export default SideBarMenu;
2 changes: 2 additions & 0 deletions apps/tangle-dapp/components/sideBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as SideBar } from './SideBar';
export { default as SideBarMenu } from './SideBarMenu';
97 changes: 97 additions & 0 deletions apps/tangle-dapp/components/sideBar/sideBarProps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import {
AppsLine,
DocumentationIcon,
FaucetIcon,
GlobalLine,
KeyIcon,
FundsLine,
} from '@webb-tools/icons';
import {
type SideBarFooterType,
type SideBarItemProps,
type SidebarProps,
TangleLogo,
} from '@webb-tools/webb-ui-components';
import { SidebarTangleClosedIcon } from '@webb-tools/webb-ui-components/components';
import {
DKG_STATS_AUTHORITIES_URL,
DKG_STATS_KEYS_URL,
DKG_STATS_PROPOSALS_URL,
TANGLE_MKT_URL,
TANGLE_STANDALONE_EXPLORER_URL,
TANGLE_TESTNET_EXPLORER_URL,
WEBB_TANGLE_DOCS_URL,
WEBB_FAUCET_URL,
} from '@webb-tools/webb-ui-components/constants';

const SideBarItems: SideBarItemProps[] = [
{
name: 'EVM Staking',
href: '/',
isInternal: true,
Icon: FundsLine,
subItems: [],
},
{
Icon: KeyIcon,
href: '',
isInternal: false,
name: 'DKG Explorer',
subItems: [
{
href: DKG_STATS_KEYS_URL,
isInternal: false,
name: 'Keys',
},
{
href: DKG_STATS_AUTHORITIES_URL,
isInternal: false,
name: 'Authorities',
},
{
href: DKG_STATS_PROPOSALS_URL,
isInternal: false,
name: 'Proposals',
},
],
},
{
Icon: FaucetIcon,
href: WEBB_FAUCET_URL,
isInternal: false,
name: 'Faucet',
subItems: [],
},
{
Icon: AppsLine,
href: TANGLE_STANDALONE_EXPLORER_URL,
isInternal: false,
name: 'Substrate Portal',
subItems: [],
},
{
Icon: GlobalLine,
href: TANGLE_TESTNET_EXPLORER_URL,
isInternal: false,
name: 'EVM Explorer',
subItems: [],
},
];

const SideBarFooter: SideBarFooterType = {
Icon: DocumentationIcon,
href: WEBB_TANGLE_DOCS_URL,
isInternal: false,
name: 'Tangle Docs',
useNextThemesForThemeToggle: true,
};

const SideBarProps: SidebarProps = {
ClosedLogo: SidebarTangleClosedIcon,
Logo: TangleLogo,
footer: SideBarFooter,
items: SideBarItems,
logoLink: TANGLE_MKT_URL,
};

export default SideBarProps;
35 changes: 35 additions & 0 deletions apps/tangle-dapp/containers/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { type PropsWithChildren, type FC } from 'react';
import { Footer } from '@webb-tools/webb-ui-components';
import { getSideBarStateFromCookie } from '@webb-tools/webb-ui-components/next-utils';
import { SideBar, SideBarMenu } from '../../components';

const Layout: FC<PropsWithChildren> = ({ children }) => {
const isSideBarInitiallyExpanded = getSideBarStateFromCookie();

return (
<>
<SideBar isExpandedAtDefault={isSideBarInitiallyExpanded} />
<main className="flex flex-col justify-between flex-1 h-full px-3 overflow-y-auto md:px-5 lg:px-10">
<div className="flex-[1]">
{/* Header */}
<div className="flex items-center justify-between pt-6 pb-4">
<div className="flex items-center gap-2">
<SideBarMenu />
{/* Breadcrumbs will go here! */}
</div>

{/* Wallet connection will go here! */}
</div>

{/* Body */}
{children}
</div>

{/* Footer */}
<Footer isMinimal className="py-12 mx-0 max-w-none" />
</main>
</>
);
};

export default Layout;
1 change: 1 addition & 0 deletions apps/tangle-dapp/containers/Layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Layout } from './Layout';
1 change: 1 addition & 0 deletions apps/tangle-dapp/containers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Layout } from './Layout';
6 changes: 6 additions & 0 deletions apps/tangle-dapp/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare module '*.svg' {
const content: any;
export const ReactComponent: any;
export default content;
}
11 changes: 11 additions & 0 deletions apps/tangle-dapp/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'tangle-dapp',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/next/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/tangle-dapp',
};
5 changes: 5 additions & 0 deletions apps/tangle-dapp/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
Loading

0 comments on commit 2b2b4e0

Please sign in to comment.