From 56592086caca9d25cf4083d87387a80d1d40e8cb Mon Sep 17 00:00:00 2001 From: Mridul2820 Date: Sat, 22 Jan 2022 09:49:22 +0530 Subject: [PATCH] reuseable tooltip --- components/graphs/ContributionGraph.js | 22 ++-------------------- components/graphs/MostForked.js | 2 +- components/graphs/MostStar.js | 2 +- components/reuse/CustomTooltip.js | 8 ++++---- 4 files changed, 8 insertions(+), 26 deletions(-) diff --git a/components/graphs/ContributionGraph.js b/components/graphs/ContributionGraph.js index 3d72ea3..67f2475 100644 --- a/components/graphs/ContributionGraph.js +++ b/components/graphs/ContributionGraph.js @@ -1,5 +1,6 @@ import React from 'react' import { LineChart, Line, Tooltip, YAxis, XAxis, ResponsiveContainer, CartesianGrid } from 'recharts'; +import CustomTooltip from '../reuse/CustomTooltip'; const ContributionGraph = ({ weeks,username }) => { let contributions = [] @@ -20,25 +21,6 @@ const ContributionGraph = ({ weeks,username }) => { 36 + presentDay ); - const CustomTooltip = ({ active, payload, label }) => { - if (active && payload && payload.length) { - return ( -
-

- {`Contribution : ${payload[0].value}`} -

- -

- {`Date : ${label}`} -

- -
- ); - } - - return null; - }; - const tickDate = value => { const roundVal = new Date(value).getDate(); @@ -63,7 +45,7 @@ const ContributionGraph = ({ weeks,username }) => { > } + content={} /> { width={24} tickFormatter={tickFork} /> - } /> + } /> diff --git a/components/graphs/MostStar.js b/components/graphs/MostStar.js index 45bd637..aa785b6 100644 --- a/components/graphs/MostStar.js +++ b/components/graphs/MostStar.js @@ -44,7 +44,7 @@ const MostStar = ({ repos }) => { width={24} tickFormatter={tickFork} /> - } /> + } /> diff --git a/components/reuse/CustomTooltip.js b/components/reuse/CustomTooltip.js index 53081ee..dd99523 100644 --- a/components/reuse/CustomTooltip.js +++ b/components/reuse/CustomTooltip.js @@ -1,17 +1,17 @@ import React from 'react'; -const CustomTooltip = ({ active, payload }) => { +const CustomTooltip = ({ active, payload, customLabel1, customLabel2, label }) => { if (active && payload && payload.length) { return (

- Repository : - {payload[0].payload.name} + {customLabel1} : + {label}

- Star Count : + {customLabel2} : {payload[0].value}