mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added graphs to boris
This commit is contained in:
parent
857993e354
commit
7bcb33b0d0
5 changed files with 59 additions and 10 deletions
|
@ -2,9 +2,8 @@ import React, { VFC } from 'react';
|
||||||
|
|
||||||
import { parseISO } from 'date-fns/esm';
|
import { parseISO } from 'date-fns/esm';
|
||||||
|
|
||||||
import { BasicCurveChart } from '~/components/charts/BasicCurveChart';
|
|
||||||
import { StatsCard } from '~/components/charts/StatsCard';
|
|
||||||
import { StatsCountdownCard } from '~/components/charts/StatsCountdownCard';
|
import { StatsCountdownCard } from '~/components/charts/StatsCountdownCard';
|
||||||
|
import { StatsGraphCard } from '~/components/charts/StatsGraphCard';
|
||||||
import { foundationDate } from '~/constants/boris/constants';
|
import { foundationDate } from '~/constants/boris/constants';
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
@ -22,20 +21,26 @@ const BorisGraphicStats: VFC<BorisGraphicStatsProps> = ({
|
||||||
totalNodes,
|
totalNodes,
|
||||||
nodesByMonth,
|
nodesByMonth,
|
||||||
}) => {
|
}) => {
|
||||||
|
const year = new Date().getFullYear();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.group}>
|
<div className={styles.group}>
|
||||||
<StatsCard
|
<StatsGraphCard
|
||||||
background={<BasicCurveChart items={nodesByMonth} />}
|
|
||||||
title="Посты"
|
title="Посты"
|
||||||
total={totalNodes}
|
total={totalNodes}
|
||||||
|
data={nodesByMonth}
|
||||||
className={styles.card}
|
className={styles.card}
|
||||||
|
left={year - 1}
|
||||||
|
right={year}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<StatsCard
|
<StatsGraphCard
|
||||||
background={<BasicCurveChart items={commentsByMonth} />}
|
title="Комменты"
|
||||||
title="Комментарии"
|
|
||||||
total={totalComments}
|
total={totalComments}
|
||||||
|
data={commentsByMonth}
|
||||||
className={styles.card}
|
className={styles.card}
|
||||||
|
left={year - 1}
|
||||||
|
right={year}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<StatsCountdownCard since={parseISO(foundationDate)} className={styles.card} />
|
<StatsCountdownCard since={parseISO(foundationDate)} className={styles.card} />
|
||||||
|
|
|
@ -11,7 +11,7 @@ import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface StatsCardProps extends CardProps {
|
interface StatsCardProps extends CardProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
total?: number;
|
total?: string | number;
|
||||||
background?: ReactNode;
|
background?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
import React, { VFC } from 'react';
|
import React, { VFC } from 'react';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { addMonths } from 'date-fns';
|
import {
|
||||||
import { addYears, differenceInDays, differenceInMonths, differenceInYears } from 'date-fns/esm';
|
addMonths,
|
||||||
|
addYears,
|
||||||
|
differenceInDays,
|
||||||
|
differenceInMonths,
|
||||||
|
differenceInYears,
|
||||||
|
} from 'date-fns';
|
||||||
|
|
||||||
import { StatsCard } from '~/components/charts/StatsCard';
|
import { StatsCard } from '~/components/charts/StatsCard';
|
||||||
import { CardProps } from '~/components/containers/Card';
|
import { CardProps } from '~/components/containers/Card';
|
||||||
|
|
28
src/components/charts/StatsGraphCard/index.tsx
Normal file
28
src/components/charts/StatsGraphCard/index.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import React, { VFC } from 'react';
|
||||||
|
|
||||||
|
import { BasicCurveChart } from '~/components/charts/BasicCurveChart';
|
||||||
|
import { StatsCard } from '~/components/charts/StatsCard';
|
||||||
|
import { CardProps } from '~/components/containers/Card';
|
||||||
|
import { Filler } from '~/components/containers/Filler';
|
||||||
|
|
||||||
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
|
interface StatsGraphCardProps extends CardProps {
|
||||||
|
title?: string;
|
||||||
|
total?: string | number;
|
||||||
|
data: number[];
|
||||||
|
left?: string | number;
|
||||||
|
right?: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatsGraphCard: VFC<StatsGraphCardProps> = ({ total, title, data, left, right }) => (
|
||||||
|
<StatsCard title={title} total={total} background={<BasicCurveChart items={data} />}>
|
||||||
|
<div className={styles.content}>
|
||||||
|
<span>{left}</span>
|
||||||
|
<Filler />
|
||||||
|
<span>{right}</span>
|
||||||
|
</div>
|
||||||
|
</StatsCard>
|
||||||
|
);
|
||||||
|
|
||||||
|
export { StatsGraphCard };
|
11
src/components/charts/StatsGraphCard/styles.module.scss
Normal file
11
src/components/charts/StatsGraphCard/styles.module.scss
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
@import "src/styles/variables";
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
padding-bottom: $gap;
|
||||||
|
font: $font_12_medium;
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue