diff --git a/src/app/about/statistics/components/github-dashboard/cards/line-graph/chart.tsx b/src/app/about/statistics/components/github-dashboard/cards/line-graph/chart.tsx new file mode 100644 index 00000000..ad2d8381 --- /dev/null +++ b/src/app/about/statistics/components/github-dashboard/cards/line-graph/chart.tsx @@ -0,0 +1,83 @@ +'use client' + +import { ContributionDay } from '@/shared/lib/github' +import { useTheme } from 'next-themes' +import { + Area, + AreaChart, + CartesianGrid, + Tooltip, + TooltipProps, + XAxis +} from 'recharts' +import { + NameType, + ValueType +} from 'recharts/types/component/DefaultTooltipContent' +import usePrefersColorScheme from 'use-prefers-color-scheme' + +export function Chart({ data }: { data: ContributionDay[] }) { + const { theme } = useTheme() + const colorScheme = usePrefersColorScheme() + const isDarkMode = + theme === 'system' ? colorScheme === 'dark' : theme == 'dark' + + return ( + + + + + + + + + + } /> + + + ) +} + +const ContributionsToolTip = ({ + active, + payload +}: TooltipProps) => { + if (active && payload && payload.length) { + return ( +
+

+ Date :{' '} + {new Date(payload[0].payload.date).toDateString()} +

+

+ Commit Count : {payload[0].value} +

+
+ ) + } + + return null +} diff --git a/src/app/about/statistics/components/github-dashboard/cards/line-graph/index.tsx b/src/app/about/statistics/components/github-dashboard/cards/line-graph/index.tsx new file mode 100644 index 00000000..592f5862 --- /dev/null +++ b/src/app/about/statistics/components/github-dashboard/cards/line-graph/index.tsx @@ -0,0 +1,19 @@ +import { ChartLine } from '@phosphor-icons/react/dist/ssr' +import { getGithubContribution } from '@/shared/lib/github' +import { Chart } from './chart' + +export async function LineGraph() { + const githubActivity = await getGithubContribution() + + return ( +
+ + Contribution Graph + + +
+ +
+
+ ) +} diff --git a/src/app/about/statistics/components/github-dashboard/cards/line-graph/skeleton.tsx b/src/app/about/statistics/components/github-dashboard/cards/line-graph/skeleton.tsx new file mode 100644 index 00000000..275062a6 --- /dev/null +++ b/src/app/about/statistics/components/github-dashboard/cards/line-graph/skeleton.tsx @@ -0,0 +1,15 @@ +import { ChartLine } from '@phosphor-icons/react/dist/ssr' + +export function LineGraphSkeleton() { + return ( +
+ + Contribution Graph + + +
+
+
+
+ ) +} diff --git a/src/app/about/statistics/components/github-dashboard/index.tsx b/src/app/about/statistics/components/github-dashboard/index.tsx index b2540ba8..5211dfa5 100644 --- a/src/app/about/statistics/components/github-dashboard/index.tsx +++ b/src/app/about/statistics/components/github-dashboard/index.tsx @@ -10,6 +10,7 @@ import { Repos } from './cards/repos' import { Stars } from './cards/stars' import { Commits } from './cards/commits' import { Graph } from './cards/graph' +import { LineGraph } from './cards/line-graph' export function GithubDashboard() { return ( @@ -28,6 +29,10 @@ export function GithubDashboard() {
+ +
+ +
diff --git a/src/app/about/statistics/components/github-dashboard/skeleton/index.tsx b/src/app/about/statistics/components/github-dashboard/skeleton/index.tsx index 1d88f3b9..d1ee84e2 100644 --- a/src/app/about/statistics/components/github-dashboard/skeleton/index.tsx +++ b/src/app/about/statistics/components/github-dashboard/skeleton/index.tsx @@ -4,6 +4,7 @@ import { LanguagesSkeleton } from './languages' import { ReposSkeleton } from './repos' import { CommitsSkeleton } from './commits' import { GraphSkeleton } from './graph' +import { LineGraphSkeleton } from '../cards/line-graph/skeleton' export function GithubStatsSkeleton() { return ( @@ -21,6 +22,10 @@ export function GithubStatsSkeleton() {
+ +
+ +
) }