Skip to content
Open
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
20 changes: 20 additions & 0 deletions src/figma/compositions/DashboardBarChart.figma.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import figma from "@figma/code-connect";
import {
DashboardBarChart,
GraphHeader,
GraphVisualisation,
} from "compositions";
Expand Down Expand Up @@ -33,3 +34,22 @@ figma.connect(
),
},
);

figma.connect(
DashboardBarChart,
"https://www.figma.com/design/RunXbtjgAaAIsNgvyEndOD/MCP-Design-System?node-id=6-513&m=dev",
{
example: () => (
<DashboardBarChart
title="Title text"
aiButtons={[
{ label: "Analyse" },
{ label: "Analyse" },
{ label: "Analyse" },
]}
keys={[{ label: "Label" }, { label: "Label" }, { label: "Label" }]}
dates={[{ label: "01 Aug" }, { label: "01 Aug" }]}
/>
),
},
);
23 changes: 22 additions & 1 deletion src/stories/compositions/DashboardBarChart.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react";
import { GraphHeader } from "compositions";
import { DashboardBarChart, GraphHeader } from "compositions";

const meta: Meta<typeof GraphHeader> = {
component: GraphHeader,
Expand Down Expand Up @@ -58,3 +58,24 @@ export const StoryGraphHeaderWithoutAI: StoryObj<typeof GraphHeader> = {
</div>
),
};

export const Default: StoryObj<typeof DashboardBarChart> = {
args: {
title: "Gross Pay Ins",
aiButtons: [{ label: "Analyse" }],
keys: [
{ label: "Key Label" },
{ label: "Key Label" },
{ label: "Key Label" },
],
dates: [{ label: "01 Aug" }, { label: "07 Aug" }],
},
argTypes: {
title: { control: { type: "text" } },
},
render: (args) => (
<div style={{ width: 560 }}>
<DashboardBarChart {...args} />
</div>
),
};
48 changes: 48 additions & 0 deletions src/ui/compositions/DashboardBarChart/DashboardBarChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { clsx } from "clsx";
import type { ReactNode } from "react";
import { GraphHeader } from "./GraphHeader";
import { GraphVisualisation } from "./GraphVisualisation";
import "./dashboard-bar-chart.css";

export type DashboardBarChartProps = {
/** The title text displayed in the header */
title: ReactNode;
/** Array of AI button configurations */
aiButtons?: Array<{
label: string;
onPress?: () => void;
}>;
/** The key/legend items displayed above the chart */
keys?: Array<{
label: string;
color?: string;
}>;
/** The date labels displayed below the chart */
dates?: Array<{
label: string;
}>;
/** Optional custom chart content */
chart?: ReactNode;
/** Additional CSS class names */
className?: string;
};

/**
* A complete dashboard bar chart card that combines a graph header
* with a graph visualisation inside a styled container.
*/
export function DashboardBarChart({
title,
aiButtons,
keys,
dates,
chart,
className,
}: DashboardBarChartProps) {
return (
<div className={clsx("dashboard-bar-chart", className)}>
<GraphHeader title={title} aiButtons={aiButtons} />
<GraphVisualisation keys={keys} dates={dates} chart={chart} />
</div>
);
}
10 changes: 10 additions & 0 deletions src/ui/compositions/DashboardBarChart/dashboard-bar-chart.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.dashboard-bar-chart {
background: var(--mcp-color-surface-primary-light);
display: flex;
flex-direction: column;
align-items: flex-start;
overflow: clip;
border-radius: var(--sds-size-radius-400);
box-shadow: var(--sds-effects-shadows-drop-shadow-600);
width: 100%;
}
1 change: 1 addition & 0 deletions src/ui/compositions/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./DashboardBarChart/DashboardBarChart";
export * from "./DashboardBarChart/GraphHeader";
export * from "./DashboardBarChart/GraphVisualisation";