Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions packages/features/insights/components/ChartCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Fragment, type ReactNode } from "react";

import classNames from "@calcom/ui/classNames";
import { Button } from "@calcom/ui/components/button";
import { PanelCard } from "@calcom/ui/components/card";
import { Tooltip } from "@calcom/ui/components/tooltip";

type LegendItem = {
Expand All @@ -21,39 +21,19 @@ export function ChartCard({
legendSize,
children,
}: {
title: string | React.ReactNode;
title: string | ReactNode;
subtitle?: string;
cta?: { label: string; onClick: () => void };
legend?: Array<LegendItem>;
legendSize?: LegendSize;
children: React.ReactNode;
children: ReactNode;
}) {
const legendComponent = legend && legend.length > 0 ? <Legend items={legend} size={legendSize} /> : null;

return (
<div className="bg-muted group relative flex w-full flex-col items-center rounded-2xl px-1 pb-1">
<div className="flex h-11 w-full shrink-0 items-center justify-between gap-2 px-4">
{typeof title === "string" ? (
<h2 className="text-emphasis mr-4 shrink-0 text-sm font-semibold">{title}</h2>
) : (
title
)}
<div className="no-scrollbar flex items-center gap-2 overflow-x-auto">
{legend && legend.length > 0 && <Legend items={legend} size={legendSize} />}
{cta && (
<Button className="shrink-0" color="secondary" onClick={cta.onClick}>
{cta.label}
</Button>
)}
</div>
</div>
<div className="bg-default border-muted w-full grow gap-3 rounded-xl border">
{subtitle && (
<h3 className="text-subtle border-muted border-b p-3 text-sm font-medium leading-none">
{subtitle}
</h3>
)}
{children}
</div>
</div>
<PanelCard title={title} subtitle={subtitle} cta={cta} headerContent={legendComponent}>
{children}
</PanelCard>
);
}

Expand Down
45 changes: 45 additions & 0 deletions packages/ui/components/card/PanelCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { ReactNode } from "react";

import { Button } from "@calcom/ui/components/button";

export function PanelCard({
title,
subtitle,
cta,
headerContent,
children,
}: {
title: string | ReactNode;
subtitle?: string;
cta?: { label: string; onClick: () => void };
headerContent?: ReactNode;
children: ReactNode;
}) {
return (
<div className="bg-muted group relative flex w-full flex-col items-center rounded-2xl px-1 pb-1">
<div className="flex h-11 w-full shrink-0 items-center justify-between gap-2 px-4">
{typeof title === "string" ? (
<h2 className="text-emphasis mr-4 shrink-0 text-sm font-semibold">{title}</h2>
) : (
title
)}
<div className="no-scrollbar flex items-center gap-2 overflow-x-auto">
{headerContent}
{cta && (
<Button className="shrink-0" color="secondary" onClick={cta.onClick}>
{cta.label}
</Button>
)}
</div>
</div>
<div className="bg-default border-muted w-full grow gap-3 rounded-xl border">
{subtitle && (
<h3 className="text-subtle border-muted border-b p-3 text-sm font-medium leading-none">
{subtitle}
</h3>
)}
{children}
</div>
</div>
);
}
1 change: 1 addition & 0 deletions packages/ui/components/card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as Card } from "./Card";
export type { BaseCardProps } from "./Card";
export { StepCard } from "./StepCard";
export { default as FormCard } from "./FormCard";
export { PanelCard } from "./PanelCard";
Loading