mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
**Description:** - Updated mobile header with respect to latest designs <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a new `showText` property to the `MenuSwitcher` component to control text visibility. - Added a `textSectionClassName` property to the `AvatarWithText` component for conditional text section styling. - Updated the `CommandDialog` and `DialogContent` components with new positioning and styling properties. - **Style Updates** - Adjusted text size responsiveness in the `Hero` component for various screen sizes. - Modified text truncation and input styling in the `Widget` component. - Changed the width of the `SheetContent` element in `MobileNavigation` and adjusted footer layout. - **Documentation** - Added instructions for certificate placement in `SIGNING.md`. - **Refactor** - Standardized type imports across various components and utilities for improved type checking. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Adithya Krishna <adithya@documenso.com> Signed-off-by: Adithya Krishna <aadithya794@gmail.com> Co-authored-by: David Nguyen <davidngu28@gmail.com>
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
'use client';
|
|
|
|
import type { HTMLAttributes } from 'react';
|
|
|
|
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
|
|
|
import { formatMonth } from '@documenso/lib/client-only/format-month';
|
|
|
|
export type BarMetricProps<T extends Record<string, unknown>> = HTMLAttributes<HTMLDivElement> & {
|
|
data: T;
|
|
metricKey: keyof T[string];
|
|
title: string;
|
|
label: string;
|
|
chartHeight?: number;
|
|
extraInfo?: JSX.Element;
|
|
};
|
|
|
|
export const BarMetric = <T extends Record<string, Record<keyof T[string], unknown>>>({
|
|
className,
|
|
data,
|
|
metricKey,
|
|
title,
|
|
label,
|
|
chartHeight = 400,
|
|
extraInfo,
|
|
...props
|
|
}: BarMetricProps<T>) => {
|
|
const formattedData = Object.keys(data)
|
|
.map((key) => ({
|
|
month: formatMonth(key),
|
|
[metricKey]: data[key][metricKey],
|
|
}))
|
|
.reverse();
|
|
|
|
return (
|
|
<div className={className} {...props}>
|
|
<div className="border-border flex flex-col justify-center rounded-2xl border p-6 pl-2 shadow-sm hover:shadow">
|
|
<div className="mb-6 flex px-4">
|
|
<h3 className="text-lg font-semibold">{title}</h3>
|
|
<span>{extraInfo}</span>
|
|
</div>
|
|
|
|
<ResponsiveContainer width="100%" height={chartHeight}>
|
|
<BarChart data={formattedData}>
|
|
<XAxis dataKey="month" />
|
|
<YAxis />
|
|
<Tooltip
|
|
labelStyle={{
|
|
color: 'hsl(var(--primary-foreground))',
|
|
}}
|
|
itemStyle={{
|
|
color: 'hsl(var(--primary-foreground))',
|
|
}}
|
|
formatter={(value) => [Number(value), label]}
|
|
cursor={{ fill: 'hsl(var(--primary) / 10%)' }}
|
|
/>
|
|
<Bar
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
dataKey={metricKey as string}
|
|
maxBarSize={60}
|
|
fill="hsl(var(--primary))"
|
|
label={label}
|
|
radius={[4, 4, 0, 0]}
|
|
/>
|
|
</BarChart>
|
|
</ResponsiveContainer>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|