Skip to content

Commit

Permalink
feat: redesing home page
Browse files Browse the repository at this point in the history
  • Loading branch information
reza-bm committed Nov 22, 2023
1 parent e63e933 commit 4ff2d46
Show file tree
Hide file tree
Showing 49 changed files with 983 additions and 748 deletions.
2 changes: 1 addition & 1 deletion components/Button/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function LinkButton(props: PropsWithChildren<LinkButtonProps>) {
return (
<Link
onClick={onClick}
className={`transition-all hover:bg-opacity-90 overflow-hidden relative py-3 flex items-center justify-center px-4 text-xs font-semibold md:leading-snug md:text-md text-baseForeground bg-secondary-500 rounded-lg ${props.className}`}
className={`transition-all hover:bg-opacity-90 overflow-hidden relative py-3 flex items-center justify-center px-4 text-12 font-semibold md:leading-snug md:text-18 text-baseForeground bg-secondary-500 rounded-lg ${props.className}`}
href={props.href}>
{props.children}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function Button(props: PropsWithChildren<ButtonProps>) {
return (
<button
onClick={handleClick}
className={`transition-all hover:bg-opacity-90 overflow-hidden relative py-3 flex items-center justify-center px-4 text-md font-semibold md:leading-snug text-baseForeground bg-secondary-500 rounded-micro ${
className={`transition-all hover:bg-opacity-90 overflow-hidden relative py-3 flex items-center justify-center px-4 text-18 font-semibold md:leading-snug text-baseForeground bg-secondary-500 rounded-micro ${
props.className || ''
}`}>
{props.children}
Expand Down
24 changes: 12 additions & 12 deletions components/ChartBox old.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,40 @@ const ChartBox: React.FC<PropsType> = ({ summary }) => {
</div>
<div className="gap-5 px-4 py-6 bg-neutral-100 grid lg:gap-x-8 lg:gap-y-24 grid-cols-2 lg:w-6/12 lg:p-0 lg:grid-cols-3 rounded-lg">
<div className="lg:justify-self-center text-center">
<p className="text-xl lg:text-4xl font-bold">
<p className="text-28 lg:text-4xl font-bold">
{AmountConverter(summary.connectedWallets)}
</p>
<p className="text-xs">Total Wallets Connected</p>
<p className="text-12">Total Wallets Connected</p>
</div>
<div className="lg:justify-self-center text-center">
<p className="text-xl lg:text-4xl truncate font-bold">
<p className="text-28 lg:text-4xl truncate font-bold">
{AmountConverter(summary.totalTxVolumeUSD)}
</p>
<p className="text-xs">Total Swap Volume</p>
<p className="text-12">Total Swap Volume</p>
</div>
<div className="lg:justify-self-center text-center">
<p className="text-xl truncate lg:text-4xl font-bold">
<p className="text-28 truncate lg:text-4xl font-bold">
{AmountConverter(summary.totalTxCount)}
</p>
<p className="text-xs">Total Swap</p>
<p className="text-12">Total Swap</p>
</div>
<div className="lg:justify-self-center text-center">
<p className="text-xl truncate lg:text-4xl font-bold">
<p className="text-28 truncate lg:text-4xl font-bold">
{AmountConverter(summary.supportedDexes)}
</p>
<p className="text-xs">Supported Dexes</p>
<p className="text-12">Supported Dexes</p>
</div>
<div className="lg:justify-self-center text-center">
<p className="text-xl truncate lg:text-4xl font-bold">
<p className="text-28 truncate lg:text-4xl font-bold">
{AmountConverter(summary.supportedChains)}
</p>
<p className="text-xs">Supported Chain</p>
<p className="text-12">Supported Chain</p>
</div>
<div className="lg:justify-self-center text-center">
<p className="text-xl truncate lg:text-4xl font-bold">
<p className="text-28 truncate lg:text-4xl font-bold">
{AmountConverter(summary.supportedBridges)}
</p>
<p className="text-xs">Supported Bridges</p>
<p className="text-12">Supported Bridges</p>
</div>
</div>
</div>
Expand Down
155 changes: 89 additions & 66 deletions components/ChartBox/Chart.tsx
Original file line number Diff line number Diff line change
@@ -1,87 +1,110 @@
import { curveCardinal } from '@visx/curve';
import {
AnimatedAxis,
AnimatedGrid,
AnimatedLineSeries,
XYChart,
Tooltip,
Axis,
AnimatedAreaSeries,
AnimatedAreaStack,
} from '@visx/xychart';
import { customTheme, getDayOfMonth, getRoundedCount } from './Chart.helper';
import dayjs from 'dayjs';
import isMobile from 'is-mobile';
import { CustomTick } from './CustomTick';
import { ChartProps } from './Chart.type';
import { customTheme, monthsShort } from './Chart.helper';

function Chart(props: ChartProps) {
const { data } = props;
export const Chart = (props: ChartProps) => {
const { data, days } = props;
const currentWeek = data.slice(24, 31).map((item) => ({ ...item }));
const prevWeek = data.slice(17, 24).map((item) => ({ ...item }));

// Update the date property of each item in prevWeek with the corresponding item from deepCopyCurrentWeek
prevWeek.forEach((item, index) => {
prevWeek[index].date = currentWeek[index].date;
});

const IsMobile = isMobile();
return (
<div className="relative flex justify-center overflow-hidden">
<XYChart
theme={customTheme}
xScale={{ type: 'band' }}
yScale={{ type: 'linear' }}>
<Axis
orientation="bottom"
hideAxisLine
hideTicks
hideZero
numTicks={IsMobile ? 4 : 8}
tickFormat={(d) =>
`${monthsShort[dayjs(d).month()]} ${dayjs(d).year()}`
}
/>
<Axis
orientation="left"
hideAxisLine
hideTicks
hideZero
tickValues={[1000, 2000, 3000, 4000]}
labelProps={{ fontSize: 12, fontWeight: 600 }}
/>
<XYChart
theme={customTheme}
height={300}
xScale={{ type: 'band' }}
yScale={{ type: 'linear' }}>
<AnimatedAxis
tickComponent={(props) => (
<CustomTick dxValue={days === 7 ? 15 : 30} {...props} />
)}
orientation="bottom"
hideTicks
numTicks={7}
tickFormat={(d) => getDayOfMonth(d)}
/>
<AnimatedAxis
orientation="left"
hideAxisLine
hideTicks
numTicks={3}
tickFormat={(c) => getRoundedCount(c).toString()}
tickComponent={(props) => <CustomTick {...props} />}
/>
<AnimatedGrid
lineStyle={{
stroke: 'rgba(184, 184, 184, 0.30)',
strokeLinecap: 'round',
strokeWidth: 1,
}}
columns={false}
numTicks={3}
/>

<AnimatedGrid
columns={false}
numTicks={5}
strokeDasharray="5, 5"
stroke="#00A9BB"
lineStyle={{ opacity: 0.5 }}
{days === 30 && (
<AnimatedLineSeries
curve={curveCardinal}
dataKey="Last month"
data={data}
stroke="#469BF5"
xAccessor={(d) => d.date}
yAccessor={(d) => d.count}
/>
)}

<AnimatedAreaStack curve={curveCardinal} renderLine>
<AnimatedAreaSeries
dataKey="Daily Interval"
data={data.slice(0, 15)}
{days === 7 && (
<>
<AnimatedLineSeries
curve={curveCardinal}
dataKey="Current Week"
data={currentWeek}
stroke="#469BF5"
xAccessor={(d) => d.date}
yAccessor={(d) => d.count}
fillOpacity={0}
/>
</AnimatedAreaStack>
<AnimatedLineSeries
curve={curveCardinal}
dataKey="Prev Week"
data={prevWeek}
stroke="#242D5B"
xAccessor={(d) => d.date}
yAccessor={(d) => d.count}
/>
</>
)}

<Tooltip
snapTooltipToDatumX
snapTooltipToDatumY
showVerticalCrosshair
renderTooltip={({ tooltipData }: any) => (
<div className="text-xs">
<div className="mb-1">Swaps</div>
<Tooltip
snapTooltipToDatumX
snapTooltipToDatumY
showVerticalCrosshair
renderTooltip={({ tooltipData }: any) => (
<div className="text-12">
<div className="mb-1">Swaps</div>

<div className="mb-1">
{dayjs(
tooltipData.nearestDatum.datum.date.split('T')[0],
).format('dddd, YYYY MMMM DD')}
</div>
<div className="mb-1">
Count: {tooltipData.nearestDatum.datum.count}
</div>
<div className="mb-1">
{dayjs(tooltipData.nearestDatum.datum.date.split('T')[0]).format(
'dddd, YYYY MMMM DD',
)}
</div>
)}
/>
</XYChart>
<div className="w-full h-12 absolute bottom-12" />
</div>
<div className="mb-1">
Count: {tooltipData.nearestDatum.datum.count}
</div>
</div>
)}
/>
</XYChart>
);
}

export default Chart;
};
10 changes: 6 additions & 4 deletions components/ChartBox/Chart.type.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { DailyIntervalType } from 'types';

import { TickRendererProps } from '@visx/axis';

export interface ChartProps {
data: DailyIntervalType[];
days?: number;
}

export interface WeeklyChartProps {
currentWeek: DailyIntervalType[];
prevWeek: DailyIntervalType[];
}
export type CustomTickProps = TickRendererProps & {
dxValue?: number;
};

export type DaysFilter = 7 | 30;

Expand Down
19 changes: 7 additions & 12 deletions components/ChartBox/CustomTick.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
/* eslint-disable react/prop-types */
export function CustomTick({ formattedValue, ...tickProps }) {
import { CustomTickProps } from './Chart.type';

export function CustomTick(props: CustomTickProps) {
const { formattedValue, dxValue = 0 } = props;

return (
<g transform={`translate(${tickProps.x},${tickProps.y})`}>
<g style={{ transform: `translateX(${dxValue}px)` }}>
<text
fontSize={12}
fontWeight={400}
textAnchor="end"
dominantBaseline="middle"
fill="#B8B8B8" // Set tick label color
>
fill="#B8B8B8">
{formattedValue}
</text>
<line
x1={-4} // Adjust the tick line length as needed
x2={0}
y1={0}
y2={0}
stroke="#333" // Set tick line color
/>
</g>
);
}
78 changes: 0 additions & 78 deletions components/ChartBox/MonthlyChart.tsx

This file was deleted.

Loading

0 comments on commit 4ff2d46

Please sign in to comment.