From 9d5086290f6c6b11c3ed857c27a5895b37fe6c2f Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 30 Mar 2022 14:13:31 +0700 Subject: [PATCH] made demo for nodes and comments count by month --- .env.local | 8 ++-- .../charts/BasicCurveChart/index.tsx | 42 +++++++++++++++++++ src/layouts/BorisLayout/index.tsx | 10 +++++ src/types/boris/index.ts | 8 +--- src/types/lab/index.ts | 19 --------- 5 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 src/components/charts/BasicCurveChart/index.tsx diff --git a/.env.local b/.env.local index 91636404..9c946691 100644 --- a/.env.local +++ b/.env.local @@ -1,6 +1,6 @@ -NEXT_PUBLIC_API_HOST=https://pig.staging.vault48.org/ -NEXT_PUBLIC_REMOTE_CURRENT=https://pig.staging.vault48.org/static/ +#NEXT_PUBLIC_API_HOST=https://pig.staging.vault48.org/ +#NEXT_PUBLIC_REMOTE_CURRENT=https://pig.staging.vault48.org/static/ #NEXT_PUBLIC_API_HOST=http://localhost:8888/ #NEXT_PUBLIC_REMOTE_CURRENT=http://localhost:8888/static/ -#NEXT_PUBLIC_API_HOST=https://pig.vault48.org/ -#NEXT_PUBLIC_REMOTE_CURRENT=https://pig.vault48.org/static/ +NEXT_PUBLIC_API_HOST=https://pig.vault48.org/ +NEXT_PUBLIC_REMOTE_CURRENT=https://pig.vault48.org/static/ diff --git a/src/components/charts/BasicCurveChart/index.tsx b/src/components/charts/BasicCurveChart/index.tsx new file mode 100644 index 00000000..6f9ea9cd --- /dev/null +++ b/src/components/charts/BasicCurveChart/index.tsx @@ -0,0 +1,42 @@ +import React, { VFC } from 'react'; + +import { SVGProps } from '~/utils/types'; + +interface BasicCurveChartProps extends SVGProps { + items: number[]; +} + +const BasicCurveChart: VFC = ({ + stroke = '#007962', + items = [], + ...props +}) => { + const max = Math.max(...items) + 5; + const height = props.height ? parseFloat(props.height.toString()) : 100; + const width = props.width ? parseFloat(props.width.toString()) : 100; + + const d = items.reduce( + (acc, val, index) => [ + ...acc, + index === 0 + ? `M 5 ${height - (val / max) * height}` + : `L ${(width / (items.length - 1)) * index} ${height - (val / max) * height}`, + ], + [] + ); + + return ( + + + + + + + + + + + ); +}; + +export { BasicCurveChart }; diff --git a/src/layouts/BorisLayout/index.tsx b/src/layouts/BorisLayout/index.tsx index 5ac52a5a..4c1abddb 100644 --- a/src/layouts/BorisLayout/index.tsx +++ b/src/layouts/BorisLayout/index.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router'; import { BorisSidebar } from '~/components/boris/BorisSidebar'; import { Superpower } from '~/components/boris/Superpower'; +import { BasicCurveChart } from '~/components/charts/BasicCurveChart'; import { Card } from '~/components/containers/Card'; import { Group } from '~/components/containers/Group'; import { Padder } from '~/components/containers/Padder'; @@ -52,6 +53,7 @@ const BorisLayout: FC = ({ title, setIsBetaTester, isTester, stats, isLo

Тестовые фичи

+
@@ -61,6 +63,14 @@ const BorisLayout: FC = ({ title, setIsBetaTester, isTester, stats, isLo Профиль на отдельной странице + + +

Количество нод за год

+ + +

Количество комментов за год

+ +
diff --git a/src/types/boris/index.ts b/src/types/boris/index.ts index 6b008b68..8e6a6196 100644 --- a/src/types/boris/index.ts +++ b/src/types/boris/index.ts @@ -11,12 +11,6 @@ export interface GithubIssue { export type IGetGithubIssuesResult = GithubIssue[]; -export type IStatGitRow = { - commit: string; - subject: string; - timestamp: string; -}; - export type StatBackend = { users: { total: number; @@ -28,9 +22,11 @@ export type StatBackend = { videos: number; texts: number; total: number; + by_month: number[]; }; comments: { total: number; + by_month: number[]; }; files: { count: number; diff --git a/src/types/lab/index.ts b/src/types/lab/index.ts index 2f240760..9d120d66 100644 --- a/src/types/lab/index.ts +++ b/src/types/lab/index.ts @@ -1,24 +1,5 @@ import { IError, INode, ITag } from '~/types'; -export type ILabState = Readonly<{ - list: { - is_loading: boolean; - nodes: ILabNode[]; - count: number; - error: IError; - }; - stats: { - is_loading: boolean; - heroes: Partial[]; - tags: ITag[]; - error?: string; - }; - updates: { - nodes: INode[]; - isLoading: boolean; - }; -}>; - export enum LabNodesSort { New = 'new', Hot = 'hot',