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

Hubble Stats - Pool Overview #1431

Merged
merged 51 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
db18833
feat: add Shielded Asset table
vutuanlinh2k2 Jul 5, 2023
6087038
Merge remote-tracking branch 'origin' into linh/hubble-stats-shielded…
vutuanlinh2k2 Jul 5, 2023
8eaa2a2
feat: add Shielded Pools table
vutuanlinh2k2 Jul 5, 2023
d4f9048
chore: add style support for dark theme
vutuanlinh2k2 Jul 5, 2023
d61171d
chore: refactor code + remove dummy data + add netlify.toml
vutuanlinh2k2 Jul 5, 2023
4a54582
fix: fix interface error in Shielded Pools
vutuanlinh2k2 Jul 5, 2023
714ac47
feat: refactor code for reusable table components later
vutuanlinh2k2 Jul 5, 2023
c749047
chore: refactor code
vutuanlinh2k2 Jul 6, 2023
1a86974
chore: update styling
vutuanlinh2k2 Jul 6, 2023
dcb3f0b
chore: refactor tooltip in HeaderCell
vutuanlinh2k2 Jul 6, 2023
958b8ad
chore: fix icon size
vutuanlinh2k2 Jul 6, 2023
4ae3894
chore: merge with develop
vutuanlinh2k2 Jul 6, 2023
3fe38e2
chore: fix use client
vutuanlinh2k2 Jul 6, 2023
971b089
chore: fix minor bugs
vutuanlinh2k2 Jul 6, 2023
6f8ae02
feat: add TableAndChartTabs
vutuanlinh2k2 Jul 7, 2023
fda8160
chore: add storybook for TableAndChartTabs
vutuanlinh2k2 Jul 7, 2023
76e9b10
chore: utilize export default in components
vutuanlinh2k2 Jul 7, 2023
7be996e
chore: add types file for table folder
vutuanlinh2k2 Jul 7, 2023
c21aa89
chore: restructure folder
vutuanlinh2k2 Jul 7, 2023
915e051
feat: add IconsGroup component in webb-ui-kit
vutuanlinh2k2 Jul 7, 2023
e6b5f9a
chore: apply IconsGroup in Hubble Stats
vutuanlinh2k2 Jul 7, 2023
be72037
chore: apply IconsGroup in Bridge dapp
vutuanlinh2k2 Jul 7, 2023
fcdaa24
chore: add tooltip for IconsGroup
vutuanlinh2k2 Jul 7, 2023
ce7cdcb
chore: merge with develop
vutuanlinh2k2 Jul 8, 2023
adf8aea
chore: refactor TableAndChartTabs component
vutuanlinh2k2 Jul 11, 2023
114445b
chore: update UI for Hubble Stats and Bridge
vutuanlinh2k2 Jul 11, 2023
fa98e17
feat: add Pool Transactions table
vutuanlinh2k2 Jul 11, 2023
d0a554b
feat: add Pool Metadata table
vutuanlinh2k2 Jul 11, 2023
90d190c
chore: fix layout
vutuanlinh2k2 Jul 11, 2023
614c6ce
feat: add filter for Pool Transactions table
vutuanlinh2k2 Jul 13, 2023
953b976
chore: refactor CheckBoxMenuGroup component
vutuanlinh2k2 Jul 13, 2023
2636669
chore: minor code refactor + check dummy data
vutuanlinh2k2 Jul 13, 2023
71a4fd5
chore: set up pool overview and create PoolTypeChip component
vutuanlinh2k2 Jul 13, 2023
72f28e1
feat: add Pool Overview component
vutuanlinh2k2 Jul 13, 2023
76a6fc6
chore: update UI
vutuanlinh2k2 Jul 15, 2023
354aa7f
chore: update UI + check dummy data
vutuanlinh2k2 Jul 15, 2023
1ec403b
chore: merge with develop
vutuanlinh2k2 Jul 15, 2023
a996f37
chore: format code
vutuanlinh2k2 Jul 15, 2023
0081cc3
chore: remove PoolTypeCell
vutuanlinh2k2 Jul 15, 2023
81af554
chore: parameterize variables + minor UI fix + default pooltype as si…
vutuanlinh2k2 Jul 19, 2023
1b07d3c
Merge remote-tracking branch 'origin' into linh/hubble-stats-pool-ove…
vutuanlinh2k2 Jul 19, 2023
1fffcd3
chore: remove console erros
vutuanlinh2k2 Jul 19, 2023
e65e3f4
chore: remove useState in PoolOverviewContainer + update tailwind config
vutuanlinh2k2 Jul 20, 2023
bf6442b
chore: merge with develop
vutuanlinh2k2 Jul 20, 2023
2c61089
chore: refactor code
vutuanlinh2k2 Jul 20, 2023
437c7e8
chore: resolve git to take account of the case in folders
vutuanlinh2k2 Jul 20, 2023
6c91237
chore: add files after resolving case sensitive in git
vutuanlinh2k2 Jul 20, 2023
e80b3c2
chore: delete Areachart directory
vutuanlinh2k2 Jul 20, 2023
c5f0429
chore: delete Barchart component
vutuanlinh2k2 Jul 20, 2023
2e178d3
chore: delete Areachart.tsx
vutuanlinh2k2 Jul 20, 2023
a482bc2
chore: delete Barchart.tsx
vutuanlinh2k2 Jul 20, 2023
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
21 changes: 6 additions & 15 deletions apps/hubble-stats/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use client';
import { useEffect } from 'react';

import {
WebbUIProvider,
useDarkMode,
Footer,
SideBar,
Logo,
Expand All @@ -20,19 +19,13 @@ import {
WEBB_DOCS_URL,
WEBB_MKT_URL,
} from '@webb-tools/webb-ui-components/constants';
import { Header } from '../components/Header';
import { Header } from '../components';

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const [, setIsDarkMode] = useDarkMode();

useEffect(() => {
setIsDarkMode('light');
}, [setIsDarkMode]);

const items: ItemProps[] = [
{
name: 'Hubble',
Expand Down Expand Up @@ -96,12 +89,10 @@ export default function RootLayout({
footer={footer}
/>

<main className="flex-1 overflow-y-auto">
<div className="max-w-[1240px] mx-auto">
<Header />
{children}
<Footer isMinimal style={{ background: 'inherit' }} />
</div>
<main className="flex-1 px-10 overflow-y-auto">
<Header />
{children}
<Footer isMinimal style={{ background: 'inherit' }} />
</main>
</body>
</WebbUIProvider>
Expand Down
4 changes: 2 additions & 2 deletions apps/hubble-stats/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Metadata } from 'next';
import {
KeyMetricsTableContainer,
ShieldedTablesContainer,
OverviewChartsContainer,
} from '../containers';
import { VolumeChartsContainer } from '../containers/VolumeChartsContainer';

export const metadata: Metadata = {
title: 'Hubble Stats',
Expand All @@ -13,7 +13,7 @@ export const metadata: Metadata = {
export default async function Index() {
return (
<div className="py-4 space-y-8">
<VolumeChartsContainer />
<OverviewChartsContainer />
<KeyMetricsTableContainer />
<ShieldedTablesContainer />
</div>
Expand Down
7 changes: 7 additions & 0 deletions apps/hubble-stats/app/pool/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
PoolMetadataTableContainer,
PoolOverviewContainer,
PoolTransactionsTableContainer,
} from '../../../containers';

Expand All @@ -8,6 +9,12 @@ export default function Pool({ params }: { params: { slug: string } }) {

return (
<div className="py-4 space-y-8">
<div className="flex gap-4">
<div className="w-[400px]">
<PoolOverviewContainer />
</div>
<div className="flex-grow"></div>
</div>
<PoolTransactionsTableContainer />
<PoolMetadataTableContainer />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { ResponsiveContainer, AreaChart, Area, Tooltip, XAxis } from 'recharts';
import { AreachartProps } from './types';

export const Areachart = (props: AreachartProps) => {
const {
data,
setDate,
setValue,
isDarkMode,
width = '100%',
height = 180,
} = props;
import { FC } from 'react';
import {
ResponsiveContainer,
AreaChart as AreaChartCmp,
Area,
Tooltip,
XAxis,
} from 'recharts';
import { AreaChartProps } from './types';

const AreaChart: FC<AreaChartProps> = ({
data,
setDate,
setValue,
isDarkMode,
width = '100%',
height = 180,
}) => {
return (
<ResponsiveContainer width={width} height={height}>
<AreaChart
<AreaChartCmp
data={data}
onMouseLeave={() => {
setDate && setDate(null);
Expand Down Expand Up @@ -52,7 +57,9 @@ export const Areachart = (props: AreachartProps) => {
fillOpacity={0}
strokeWidth={2}
/>
</AreaChart>
</AreaChartCmp>
</ResponsiveContainer>
);
};

export default AreaChart;
1 change: 1 addition & 0 deletions apps/hubble-stats/components/AreaChart/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as AreaChart } from './AreaChart';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type AreachartProps = {
export type AreaChartProps = {
data: any;
setValue: (value: number | null) => void;
setDate: (date: Date | null) => void;
Expand Down
2 changes: 0 additions & 2 deletions apps/hubble-stats/components/Areachart/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { ResponsiveContainer, BarChart, XAxis, Tooltip, Bar } from 'recharts';
import { BarchartProps } from './types';

export const Barchart = (props: BarchartProps) => {
const {
data,
setValue,
setDate,
isDarkMode,
width = '100%',
height = 180,
} = props;
import { FC } from 'react';
import {
ResponsiveContainer,
BarChart as BarChartCmp,
XAxis,
Tooltip,
Bar,
} from 'recharts';
import { BarChartProps } from './types';

const BarChart: FC<BarChartProps> = ({
data,
setValue,
setDate,
isDarkMode,
width = '100%',
height = 180,
}) => {
return (
<ResponsiveContainer width={width} height={height}>
<BarChart
<BarChartCmp
data={data}
onMouseLeave={() => {
setValue && setValue(null);
Expand Down Expand Up @@ -47,7 +52,9 @@ export const Barchart = (props: BarchartProps) => {
}}
/>
<Bar dataKey="value" fill={isDarkMode ? '#81B3F6' : '#3D7BCE'} />
</BarChart>
</BarChartCmp>
</ResponsiveContainer>
);
};

export default BarChart;
1 change: 1 addition & 0 deletions apps/hubble-stats/components/BarChart/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as BarChart } from './BarChart';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type BarchartProps = {
export type BarChartProps = {
data: any;
setValue: (value: number | null) => void;
setDate: (date: Date | null) => void;
Expand Down
2 changes: 0 additions & 2 deletions apps/hubble-stats/components/Barchart/index.ts

This file was deleted.

4 changes: 3 additions & 1 deletion apps/hubble-stats/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import Link from 'next/link';
import React, { useMemo } from 'react';

export const Header = () => {
const Header = () => {
const tvl = useMemo(() => {
return 'TVL: $13,642,124';
}, []);
Expand Down Expand Up @@ -80,3 +80,5 @@ export const VolumeChip: React.FC<VolumeChipProps> = ({
</Chip>
);
};

export default Header;
2 changes: 1 addition & 1 deletion apps/hubble-stats/components/Header/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './Header';
export { default as Header } from './Header';
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { FC } from 'react';
import cx from 'classnames';
import { Typography } from '@webb-tools/webb-ui-components';
import { getRoundedAmountString } from '@webb-tools/webb-ui-components/utils';
import { ArrowRight } from '@webb-tools/icons';

import { PoolOverviewItemProps } from './types';

const PoolOverviewItem: FC<PoolOverviewItemProps> = ({
title,
value,
changeRate,
prefix,
className,
}) => {
return (
<div className={cx('px-2', className)}>
<div className="flex justify-center items-center gap-1">
<Typography variant="h5" fw="black" className="text-center">
{value && (prefix ?? '')}
{getRoundedAmountString(value, 2, {
roundingFunction: Math.floor,
totalLength: 0,
})}
</Typography>
{changeRate && (
<Typography
variant="utility"
tw="black"
className={cx(
'flex items-center',
'uppercase text-mono-120 dark:text-mono-80 !text-[12px]',
{
'!text-green-70': changeRate >= 0,
'!text-red-70': changeRate < 0,
}
)}
>
<ArrowRight
className={cx({
'-rotate-90 !fill-green-70': changeRate >= 0,
'rotate-90 !fill-red-70': changeRate < 0,
})}
/>
{getRoundedAmountString(Math.abs(changeRate), 2)}%
</Typography>
)}
</div>

<Typography
variant="utility"
tw="black"
className="w-full uppercase block text-center text-mono-120 dark:text-mono-80 !text-[12px]"
>
{title}
</Typography>
</div>
);
};

export default PoolOverviewItem;
1 change: 1 addition & 0 deletions apps/hubble-stats/components/PoolOverviewItem/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as PoolOverviewItem } from './PoolOverviewItem';
7 changes: 7 additions & 0 deletions apps/hubble-stats/components/PoolOverviewItem/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface PoolOverviewItemProps {
title: string;
value?: number;
changeRate?: number;
prefix?: string;
className?: string;
}
15 changes: 15 additions & 0 deletions apps/hubble-stats/components/PoolTypeChip/PoolTypeChip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { FC } from 'react';
import { Chip, ChipProps } from '@webb-tools/webb-ui-components';

import { PoolType, PoolTypeChipProps } from './types';

const typeColorMap: Record<PoolType, ChipProps['color']> = {
single: 'purple',
multi: 'blue',
};

const PoolTypeChip: FC<PoolTypeChipProps> = ({ type = 'single', name }) => {
return <Chip color={typeColorMap[type]}>{name ?? type}</Chip>;
};

export default PoolTypeChip;
1 change: 1 addition & 0 deletions apps/hubble-stats/components/PoolTypeChip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as PoolTypeChip } from './PoolTypeChip';
6 changes: 6 additions & 0 deletions apps/hubble-stats/components/PoolTypeChip/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type PoolType = 'single' | 'multi';

export interface PoolTypeChipProps {
type?: PoolType;
name?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ import {
import { ShieldedAssetDark, ShieldedAssetLight } from '@webb-tools/icons';

import { ShieldedAssetType, ShieldedAssetsTableProps } from './types';
import { HeaderCell, NumberCell, PoolTypeCell, ShieldedCell } from '../table';
import { HeaderCell, NumberCell, ShieldedCell } from '../table';
import { PoolTypeChip } from '..';

const columnHelper = createColumnHelper<ShieldedAssetType>();

const staticColumns: ColumnDef<ShieldedAssetType, any>[] = [
columnHelper.accessor('poolType', {
header: () => <HeaderCell title="Pool Type" />,
cell: (props) => <PoolTypeCell type={props.getValue()} />,
cell: (props) => (
<div className="text-center">
<PoolTypeChip type={props.getValue()} />
</div>
),
}),
columnHelper.accessor('composition', {
header: () => <HeaderCell title="Composition" />,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PoolType } from '../table/types';
import { PoolType } from '../PoolTypeChip/types';

export interface ShieldedAssetType {
assetAddress: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
import { Table, IconsGroup, fuzzyFilter } from '@webb-tools/webb-ui-components';

import { ShieldedPoolType, ShieldedPoolsTableProps } from './types';
import { HeaderCell, NumberCell, PoolTypeCell, ShieldedCell } from '../table';
import { HeaderCell, NumberCell, ShieldedCell } from '../table';
import { PoolTypeChip } from '..';

const columnHelper = createColumnHelper<ShieldedPoolType>();

Expand All @@ -30,7 +31,11 @@ const columns: ColumnDef<ShieldedPoolType, any>[] = [
}),
columnHelper.accessor('poolType', {
header: () => <HeaderCell title="Pool Type" />,
cell: (props) => <PoolTypeCell type={props.getValue()} />,
cell: (props) => (
<div className="text-center">
<PoolTypeChip type={props.getValue()} />
</div>
),
}),
columnHelper.accessor('token', {
header: () => <HeaderCell title="Token #" className="justify-end" />,
Expand Down
2 changes: 1 addition & 1 deletion apps/hubble-stats/components/ShieldedPoolsTable/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PoolType } from '../table/types';
import { PoolType } from '../PoolTypeChip/types';

export interface ShieldedPoolType {
poolSymbol: string;
Expand Down
7 changes: 5 additions & 2 deletions apps/hubble-stats/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export * from './AreaChart';
export * from './BarChart';
export * from './Header';
export * from './KeyMetricItem';
export * from './PoolMetadataTable';
export * from './PoolOverviewItem';
export * from './PoolTransactionsTable';
export * from './PoolTypeChip';
export * from './ShieldedAssetsTable';
export * from './ShieldedPoolsTable';
export * from './Areachart';
export * from './Barchart';
Loading
Loading