mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { HTMLAttributes } from 'react';
|
|
|
|
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
|
|
|
import { formatMonth } from '@documenso/lib/client-only/format-month';
|
|
import { cn } from '@documenso/ui/lib/utils';
|
|
|
|
import { StargazersType } from './page';
|
|
|
|
export type GithubOpenIssuesProps = HTMLAttributes<HTMLDivElement> & { data: StargazersType };
|
|
|
|
export const GithubOpenIssues = ({ className, data, ...props }: GithubOpenIssuesProps) => {
|
|
const formattedData = Object.keys(data)
|
|
.map((key) => ({
|
|
month: formatMonth(key),
|
|
stars: data[key].openIssues,
|
|
}))
|
|
.reverse();
|
|
|
|
return (
|
|
<div className={cn('flex flex-col', className)} {...props}>
|
|
<h3 className="px-4 text-lg font-semibold">Github: Open Issues</h3>
|
|
|
|
<div className="border-border mt-2.5 flex flex-1 items-center justify-center rounded-2xl border shadow-sm hover:shadow">
|
|
<ResponsiveContainer width="100%" height={400}>
|
|
<BarChart data={formattedData} margin={{ top: 40, right: 40, bottom: 20, left: 40 }}>
|
|
<XAxis dataKey="month" />
|
|
<YAxis />
|
|
<Tooltip
|
|
itemStyle={{
|
|
color: 'hsl(var(--primary-foreground))',
|
|
}}
|
|
formatter={(value) => [Number(value), 'Stars']}
|
|
cursor={{ fill: 'hsl(var(--primary) / 10%)' }}
|
|
/>
|
|
<Bar dataKey="stars" fill="hsl(var(--primary))" label="Stars" />
|
|
</BarChart>
|
|
</ResponsiveContainer>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|