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 all 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>
);
};
5 changes: 5 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export * from './Theme';
export * from './Disclaimer';
export * from './CustomHead';
export * from './Table';
export * from './SearchBar';
export * from './TotalValueLocked';
export * from './Title';
export * from './TitleBanner';
13 changes: 13 additions & 0 deletions src/containers/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SearchBar, Table, Title } from '~/components';

export const Dashboard = () => {
return (
<section>
<header>
<Title title='Chain list' />
<SearchBar />
</header>
<Table />
</section>
);
};
10 changes: 6 additions & 4 deletions src/containers/Landing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { styled } from '@mui/material/styles';

import { DISCLAIMER_HEIGHT, SURROUND_HEIGHT } from '~/utils';
import { Dashboard, LockedAssets } from '~/containers';
import { TitleBanner } from '~/components';

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
17 changes: 17 additions & 0 deletions src/containers/LockedAssets/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { TotalValueLocked, Title } from '~/components';
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>
);
};
2 changes: 2 additions & 0 deletions src/containers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export * from './Footer';
export * from './Header';
export * from './Layout';
export * from './Landing';
export * from './Dashboard';
export * from './LockedAssets';
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
Empty file added src/utils/misc.ts
Empty file.
Loading