Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ecosystem layout #3

Merged
merged 9 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
describe('Renders every component', () => {
it('Renders App component', () => {
cy.visit('/');
cy.getByTestId('boilerplate-title').should('exist');
});
});
7 changes: 7 additions & 0 deletions src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const SearchBar = () => {
return (
<form>
<input type='text' placeholder='Search...' />
</form>
);
};
28 changes: 28 additions & 0 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useData } from '~/hooks';

export const Table = () => {
const { ecosystemData } = useData();
return (
<table>
<tr>
<th>Chain</th>
<th>Chain ID</th>
<th>Native token</th>
<th>TVL - L1</th>
<th>Type</th>
</tr>

{ecosystemData?.chains.map((data, index) => {
return (
<tr key={index}>
<td>{data.name}</td>
<td>{data.id}</td>
<td>{data.nativeToken}</td>
<td>{data.tvl}</td>
<td>{data.type}</td>
</tr>
);
})}
</table>
);
};
11 changes: 11 additions & 0 deletions src/components/Title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
interface TitleProps {
title: string;
}

export const Title = ({ title }: TitleProps) => {
return (
<>
<h2> {title}</h2>
</>
);
};
10 changes: 10 additions & 0 deletions src/components/TitleBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const TitleBanner = () => {
return (
<div>
<span>zkSync Ecosystem</span>
<div>
<span>Gas Price: 10 wei · ERC-20 Transfer: $10</span>
</div>
</div>
);
};
21 changes: 21 additions & 0 deletions src/components/TotalValueLocked.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export interface TokenValueLocked {
token: string;
value: number;
}

interface TotalValueLockedProps {
tvl: { [token: string]: number }[];
}

export const TotalValueLocked = ({ tvl }: TotalValueLockedProps) => {
return (
<div>
{tvl.map((data, index) => (
<div key={index}>
<span>{data.token}</span>
<span>{data.value}</span>
</div>
))}
</div>
);
};
3 changes: 3 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from './Theme';
export * from './Disclaimer';
export * from './CustomHead';
export * from './Table';
export * from './SearchBar';
export * from './TotalValueLocked';
16 changes: 16 additions & 0 deletions src/containers/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SearchBar, Table } from '~/components';
import { Title } from '~/components/Title';
0xtiti marked this conversation as resolved.
Show resolved Hide resolved

const Dashboard = () => {
return (
<section>
<header>
<Title title={'Chain list'} />
0xtiti marked this conversation as resolved.
Show resolved Hide resolved
<SearchBar />
</header>
<Table />
</section>
);
};

export default Dashboard;
11 changes: 7 additions & 4 deletions src/containers/Landing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { styled } from '@mui/material/styles';

import { DISCLAIMER_HEIGHT, SURROUND_HEIGHT } from '~/utils';
import Dashboard from '../Dashboard';
import { LockedAssets } from '../LockedAssets';
import { TitleBanner } from '~/components/TitleBanner';
0xArdy marked this conversation as resolved.
Show resolved Hide resolved

export const Landing = () => {
return (
<LandingContainer>
<h1 data-testid='boilerplate-title'>Web3 React Boilerplate</h1>
<TitleBanner />
<LockedAssets />
<Dashboard />
</LandingContainer>
);
};

const LandingContainer = styled('div')({
const LandingContainer = styled('main')({
display: 'flex',
flexDirection: 'column',
height: `calc(100vh - ${SURROUND_HEIGHT}rem - ${DISCLAIMER_HEIGHT}rem)`,
padding: '0 8rem',
alignItems: 'center',
justifyContent: 'center',
Expand Down
18 changes: 18 additions & 0 deletions src/containers/LockedAssets/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TotalValueLocked } from '~/components';
import { Title } from '~/components/Title';
0xtiti marked this conversation as resolved.
Show resolved Hide resolved
import { useData } from '~/hooks';

export const LockedAssets = () => {
const { ecosystemData } = useData();

return (
<section>
{ecosystemData && (
<>
<Title title={`Locked assets in shared bridge: ${ecosystemData.total}`} />
<TotalValueLocked tvl={ecosystemData.tvl} />
</>
)}
</section>
);
};
1 change: 1 addition & 0 deletions src/containers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './Footer';
export * from './Header';
export * from './Layout';
export * from './Landing';
export * from './Dashboard';
1 change: 1 addition & 0 deletions src/data/ecosystemMockData.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"type": "Validium"
}
],
"total": 7000000,
"tvl": [
{
"token": "ETH",
Expand Down
5 changes: 2 additions & 3 deletions src/types/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ export interface EcosystemChainData {
name: string;
id: number;
nativeToken: string;
tvl: {
[token: string]: number;
};
tvl: number;
type: string;
}

export interface EcosystemData {
chains: EcosystemChainData[];
total: number;
tvl: {
[token: string]: number;
}[];
Expand Down
Loading