@ammarkhalidfarooq/dashboard-package 0.6.127 → 0.6.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -305
- package/dist/ActiveCampaignsCard.cjs.js +41 -22
- package/dist/ActiveCampaignsCard.cjs.js.map +1 -1
- package/dist/ActiveCampaignsCard.es.js +42 -23
- package/dist/ActiveCampaignsCard.es.js.map +1 -1
- package/dist/MetricCard.cjs.js.map +1 -1
- package/dist/MetricCard.es.js.map +1 -1
- package/dist/RenderChartCard.cjs.js.map +1 -1
- package/dist/RenderChartCard.es.js.map +1 -1
- package/dist/index.cjs.js +123 -53
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +124 -54
- package/dist/index.es.js.map +1 -1
- package/package.json +81 -80
package/README.md
CHANGED
|
@@ -1,305 +1,305 @@
|
|
|
1
|
-
# @ammarkhalidfarooq/dashboard-package
|
|
2
|
-
|
|
3
|
-
A reusable React Dashboard component library.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @ammarkhalidfarooq/dashboard-package
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Peer dependencies are required in your app:
|
|
12
|
-
|
|
13
|
-
- `react`, `react-dom`
|
|
14
|
-
- `@mui/material`, `@mui/icons-material`, `@emotion/react`, `@emotion/styled`
|
|
15
|
-
- `apexcharts`, `react-apexcharts`
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Full Dashboard
|
|
20
|
-
|
|
21
|
-
```jsx
|
|
22
|
-
import React from "react";
|
|
23
|
-
import { Dashboard } from "@ammarkhalidfarooq/dashboard-package";
|
|
24
|
-
|
|
25
|
-
const App = () => {
|
|
26
|
-
return <Dashboard />;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default App;
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### RenderChartCard (tree-shakeable)
|
|
33
|
-
|
|
34
|
-
Import only the chart card bundle — avoids pulling in the full dashboard:
|
|
35
|
-
|
|
36
|
-
```jsx
|
|
37
|
-
import RenderChartCard from "@ammarkhalidfarooq/dashboard-package/RenderChartCard";
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Or import from the main entry:
|
|
41
|
-
|
|
42
|
-
```jsx
|
|
43
|
-
import { RenderChartCard } from "@ammarkhalidfarooq/dashboard-package";
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**Example:**
|
|
47
|
-
|
|
48
|
-
```jsx
|
|
49
|
-
import { useState } from "react";
|
|
50
|
-
import Grid from "@mui/material/Grid";
|
|
51
|
-
import RenderChartCard from "@ammarkhalidfarooq/dashboard-package/RenderChartCard";
|
|
52
|
-
|
|
53
|
-
const chartItem = {
|
|
54
|
-
label: "Revenue per Visitor",
|
|
55
|
-
value: "$5.12",
|
|
56
|
-
subtitle: "Last 30 days · daily aggregation",
|
|
57
|
-
trend: "18% vs last month",
|
|
58
|
-
data: [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000],
|
|
59
|
-
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const App = () => {
|
|
63
|
-
const [metric, setMetric] = useState("Revenue");
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Grid container spacing={3}>
|
|
67
|
-
<RenderChartCard
|
|
68
|
-
item={chartItem}
|
|
69
|
-
index={0}
|
|
70
|
-
isPremium
|
|
71
|
-
md={6}
|
|
72
|
-
metric={metric}
|
|
73
|
-
setMetric={setMetric}
|
|
74
|
-
/>
|
|
75
|
-
</Grid>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default App;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**Props:**
|
|
83
|
-
|
|
84
|
-
| Prop | Type | Default | Description |
|
|
85
|
-
|------|------|---------|-------------|
|
|
86
|
-
| `item` | `object` | — | Chart config (see below) |
|
|
87
|
-
| `index` | `number` | — | Unique index for the chart |
|
|
88
|
-
| `isPrimary` | `boolean` | `false` | Uses a taller chart area |
|
|
89
|
-
| `isPremium` | `boolean` | `false` | Premium card layout with trend badge |
|
|
90
|
-
| `metric` | `string` | — | Active metric label (e.g. `"Revenue"`) |
|
|
91
|
-
| `setMetric` | `function` | — | Metric change handler |
|
|
92
|
-
| `md` | `number` | `4` | Grid column width on `md` breakpoint |
|
|
93
|
-
| `type` | `string` | `"area"` | Chart type (`"area"`, `"bar"`, `"donut"`, etc.) |
|
|
94
|
-
| `sx` | `object` | `{}` | MUI `sx` overrides for the grid item wrapper |
|
|
95
|
-
| `cardSx` | `object` | `{}` | MUI `sx` overrides for the card container |
|
|
96
|
-
| `contentSx` | `object` | `{}` | MUI `sx` overrides for the card content area |
|
|
97
|
-
|
|
98
|
-
**`item` shape (common fields):**
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
{
|
|
102
|
-
label: "Revenue per Visitor", // Card title
|
|
103
|
-
value: "$5.12", // Main metric value
|
|
104
|
-
subtitle: "Last 30 days", // Optional subtitle (premium layout)
|
|
105
|
-
trend: "18% vs last month", // Optional trend badge (premium layout)
|
|
106
|
-
data: [3000, 4500, 4200], // Single-series chart data
|
|
107
|
-
categories: ["Jan", "Feb", "Mar"], // X-axis labels
|
|
108
|
-
series: [{ name: "Paid Ads", data: [...] }], // Multi-series (optional)
|
|
109
|
-
stacked: false, // Stack series (optional)
|
|
110
|
-
showSelector: false, // Show metric dropdown (optional)
|
|
111
|
-
hideControls: false, // Hide menu / show legend only (optional)
|
|
112
|
-
height: 250, // Chart height override (optional)
|
|
113
|
-
type: "area", // Per-card chart type override (optional)
|
|
114
|
-
colors: ["#6366F1", "#10B981"], // Custom chart colors (optional)
|
|
115
|
-
footer: { left: "Total", right: "$12k" }, // Optional footer row
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### ActiveCampaignsCard (tree-shakeable)
|
|
120
|
-
|
|
121
|
-
A configurable table card — used for channel performance, active campaigns, and similar ranked lists.
|
|
122
|
-
|
|
123
|
-
```jsx
|
|
124
|
-
import ActiveCampaignsCard from "@ammarkhalidfarooq/dashboard-package/ActiveCampaignsCard";
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Or import from the main entry:
|
|
128
|
-
|
|
129
|
-
```jsx
|
|
130
|
-
import { ActiveCampaignsCard } from "@ammarkhalidfarooq/dashboard-package";
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Channel performance example:**
|
|
134
|
-
|
|
135
|
-
```jsx
|
|
136
|
-
import ActiveCampaignsCard from "@ammarkhalidfarooq/dashboard-package/ActiveCampaignsCard";
|
|
137
|
-
|
|
138
|
-
const channelRows = [
|
|
139
|
-
{
|
|
140
|
-
id: "M",
|
|
141
|
-
avatarBg: "#4267B2",
|
|
142
|
-
name: "Meta Ads",
|
|
143
|
-
val1: "$32,800",
|
|
144
|
-
val2: "$112,400",
|
|
145
|
-
val3: "3.4x",
|
|
146
|
-
val4: "$340",
|
|
147
|
-
type: "trend",
|
|
148
|
-
trendType: "up",
|
|
149
|
-
trendLabel: "Improving",
|
|
150
|
-
highlightVal3: true,
|
|
151
|
-
val3Color: "#22C55E",
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: "G",
|
|
155
|
-
avatarBg: "#4285F4",
|
|
156
|
-
name: "Google Ads",
|
|
157
|
-
val1: "$28,200",
|
|
158
|
-
val2: "$78,300",
|
|
159
|
-
val3: "2.8x",
|
|
160
|
-
val4: "$385",
|
|
161
|
-
type: "trend",
|
|
162
|
-
trendType: "up",
|
|
163
|
-
trendLabel: "Improving",
|
|
164
|
-
highlightVal3: true,
|
|
165
|
-
val3Color: "#22C55E",
|
|
166
|
-
},
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
const App = () => (
|
|
170
|
-
<ActiveCampaignsCard
|
|
171
|
-
title="Channel performance"
|
|
172
|
-
subtitle="Ad platforms ranked by ROAS"
|
|
173
|
-
columns={["channel", "spend", "revenue", "ROAS", "CPA", "trend"]}
|
|
174
|
-
gridTemplateColumns="2.2fr 1fr 1fr 0.8fr 0.8fr 1.2fr"
|
|
175
|
-
height="100%"
|
|
176
|
-
rows={channelRows}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
export default App;
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Props:**
|
|
184
|
-
|
|
185
|
-
| Prop | Type | Default | Description |
|
|
186
|
-
|------|------|---------|-------------|
|
|
187
|
-
| `title` | `string` | `"Active campaigns"` | Card title |
|
|
188
|
-
| `subtitle` | `string` | `"Live fundraisers ranked by velocity"` | Card subtitle |
|
|
189
|
-
| `actionLabel` | `string` | — | Optional top-right action link text |
|
|
190
|
-
| `columns` | `string[]` | `["Campaign", "Raised", "Progress", "Donors", "Avg gift"]` | Table header labels |
|
|
191
|
-
| `rows` | `object[]` | `[]` | Table row data (see below) |
|
|
192
|
-
| `gridTemplateColumns` | `string` | `"3fr 1fr 1.5fr 0.8fr 1fr"` | CSS grid column template |
|
|
193
|
-
| `height` | `string` | — | Card height (e.g. `"100%"`) |
|
|
194
|
-
| `compact` | `boolean` | `false` | Smaller typography and spacing |
|
|
195
|
-
| `sx` | `object` | `{}` | MUI `sx` overrides for the root card container |
|
|
196
|
-
| `headerSx` | `object` | `{}` | MUI `sx` overrides for the title / subtitle header row |
|
|
197
|
-
| `tableSx` | `object` | `{}` | MUI `sx` overrides for the scrollable table area |
|
|
198
|
-
|
|
199
|
-
**`row` shape:**
|
|
200
|
-
|
|
201
|
-
```js
|
|
202
|
-
// Channel performance / trend table (6 columns)
|
|
203
|
-
{
|
|
204
|
-
id: "M", // Avatar label (optional)
|
|
205
|
-
avatarBg: "#4267B2", // Avatar background color
|
|
206
|
-
name: "Meta Ads", // Row label
|
|
207
|
-
val1: "$32,800", // Column 2 (spend / raised)
|
|
208
|
-
val2: "$112,400", // Column 3 when type !== "progress"
|
|
209
|
-
val3: "3.4x", // Column 4 (ROAS / donors)
|
|
210
|
-
val4: "$340", // Column 5 (CPA / avg gift)
|
|
211
|
-
type: "trend", // "trend" | "progress" — controls column 3 & 6
|
|
212
|
-
trendType: "up", // "up" | "down" (when type is "trend")
|
|
213
|
-
trendLabel: "Improving", // Trend badge text
|
|
214
|
-
highlightVal3: true, // Highlight column 4 value
|
|
215
|
-
val3Color: "#22C55E", // Highlight color for column 4
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Campaign progress table (5 columns)
|
|
219
|
-
{
|
|
220
|
-
id: "1",
|
|
221
|
-
name: "Ramadan Appeal",
|
|
222
|
-
val1: "$45,200",
|
|
223
|
-
type: "progress",
|
|
224
|
-
progress: 72,
|
|
225
|
-
progressColor: "rgb(99, 99, 230)",
|
|
226
|
-
val3: "1,240",
|
|
227
|
-
val4: "$36.45",
|
|
228
|
-
status: "Live",
|
|
229
|
-
statusBg: "#DCFCE7",
|
|
230
|
-
statusColor: "#166534",
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### MetricCard (tree-shakeable)
|
|
235
|
-
|
|
236
|
-
A compact KPI card with icon, value, and caption — used for selectable overview metrics.
|
|
237
|
-
|
|
238
|
-
```jsx
|
|
239
|
-
import MetricCard from "@ammarkhalidfarooq/dashboard-package/MetricCard";
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
Or import from the main entry:
|
|
243
|
-
|
|
244
|
-
```jsx
|
|
245
|
-
import { MetricCard } from "@ammarkhalidfarooq/dashboard-package";
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
**Example:**
|
|
249
|
-
|
|
250
|
-
```jsx
|
|
251
|
-
import { useState } from "react";
|
|
252
|
-
import { PaidOutlined as DollarIcon } from "@mui/icons-material";
|
|
253
|
-
import MetricCard from "@ammarkhalidfarooq/dashboard-package/MetricCard";
|
|
254
|
-
|
|
255
|
-
const App = () => {
|
|
256
|
-
const [active, setActive] = useState("Total Raised");
|
|
257
|
-
|
|
258
|
-
return (
|
|
259
|
-
<MetricCard
|
|
260
|
-
title="Total Raised"
|
|
261
|
-
value="$124,500"
|
|
262
|
-
caption="12.4% vs last month"
|
|
263
|
-
icon={<DollarIcon />}
|
|
264
|
-
active={active === "Total Raised"}
|
|
265
|
-
onClick={() => setActive("Total Raised")}
|
|
266
|
-
/>
|
|
267
|
-
);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export default App;
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
**Props:**
|
|
274
|
-
|
|
275
|
-
| Prop | Type | Default | Description |
|
|
276
|
-
|------|------|---------|-------------|
|
|
277
|
-
| `title` | `string` | — | Card label |
|
|
278
|
-
| `value` | `string` | — | Main metric value |
|
|
279
|
-
| `caption` | `string` | — | Subtitle / trend text below the value |
|
|
280
|
-
| `icon` | `ReactNode` | — | Icon shown in the top-right avatar |
|
|
281
|
-
| `active` | `boolean` | `false` | Highlights the card as selected |
|
|
282
|
-
| `warning` | `boolean` | `false` | Warning border and icon styling |
|
|
283
|
-
| `error` | `boolean` | `false` | Error border and caption styling |
|
|
284
|
-
| `onClick` | `function` | — | Click handler (e.g. select metric) |
|
|
285
|
-
| `sx` | `object` | `{}` | MUI `sx` overrides for the root card container |
|
|
286
|
-
| `titleSx` | `object` | `{}` | MUI `sx` overrides for the title text |
|
|
287
|
-
| `valueSx` | `object` | `{}` | MUI `sx` overrides for the main value text |
|
|
288
|
-
| `captionSx` | `object` | `{}` | MUI `sx` overrides for the caption text |
|
|
289
|
-
| `avatarSx` | `object` | `{}` | MUI `sx` overrides for the icon avatar |
|
|
290
|
-
|
|
291
|
-
## Development
|
|
292
|
-
|
|
293
|
-
To preview the component locally:
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
npm run dev
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
To build the package:
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
npm run build
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
The build outputs ESM and CommonJS bundles in the `dist` folder, including separate `RenderChartCard`, `ActiveCampaignsCard`, and `MetricCard` bundles for tree-shaking.
|
|
1
|
+
# @ammarkhalidfarooq/dashboard-package
|
|
2
|
+
|
|
3
|
+
A reusable React Dashboard component library.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ammarkhalidfarooq/dashboard-package
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies are required in your app:
|
|
12
|
+
|
|
13
|
+
- `react`, `react-dom`
|
|
14
|
+
- `@mui/material`, `@mui/icons-material`, `@emotion/react`, `@emotion/styled`
|
|
15
|
+
- `apexcharts`, `react-apexcharts`
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Full Dashboard
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Dashboard } from "@ammarkhalidfarooq/dashboard-package";
|
|
24
|
+
|
|
25
|
+
const App = () => {
|
|
26
|
+
return <Dashboard />;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default App;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### RenderChartCard (tree-shakeable)
|
|
33
|
+
|
|
34
|
+
Import only the chart card bundle — avoids pulling in the full dashboard:
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
import RenderChartCard from "@ammarkhalidfarooq/dashboard-package/RenderChartCard";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or import from the main entry:
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
import { RenderChartCard } from "@ammarkhalidfarooq/dashboard-package";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Example:**
|
|
47
|
+
|
|
48
|
+
```jsx
|
|
49
|
+
import { useState } from "react";
|
|
50
|
+
import Grid from "@mui/material/Grid";
|
|
51
|
+
import RenderChartCard from "@ammarkhalidfarooq/dashboard-package/RenderChartCard";
|
|
52
|
+
|
|
53
|
+
const chartItem = {
|
|
54
|
+
label: "Revenue per Visitor",
|
|
55
|
+
value: "$5.12",
|
|
56
|
+
subtitle: "Last 30 days · daily aggregation",
|
|
57
|
+
trend: "18% vs last month",
|
|
58
|
+
data: [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000],
|
|
59
|
+
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"],
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const App = () => {
|
|
63
|
+
const [metric, setMetric] = useState("Revenue");
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Grid container spacing={3}>
|
|
67
|
+
<RenderChartCard
|
|
68
|
+
item={chartItem}
|
|
69
|
+
index={0}
|
|
70
|
+
isPremium
|
|
71
|
+
md={6}
|
|
72
|
+
metric={metric}
|
|
73
|
+
setMetric={setMetric}
|
|
74
|
+
/>
|
|
75
|
+
</Grid>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default App;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Props:**
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Default | Description |
|
|
85
|
+
|------|------|---------|-------------|
|
|
86
|
+
| `item` | `object` | — | Chart config (see below) |
|
|
87
|
+
| `index` | `number` | — | Unique index for the chart |
|
|
88
|
+
| `isPrimary` | `boolean` | `false` | Uses a taller chart area |
|
|
89
|
+
| `isPremium` | `boolean` | `false` | Premium card layout with trend badge |
|
|
90
|
+
| `metric` | `string` | — | Active metric label (e.g. `"Revenue"`) |
|
|
91
|
+
| `setMetric` | `function` | — | Metric change handler |
|
|
92
|
+
| `md` | `number` | `4` | Grid column width on `md` breakpoint |
|
|
93
|
+
| `type` | `string` | `"area"` | Chart type (`"area"`, `"bar"`, `"donut"`, etc.) |
|
|
94
|
+
| `sx` | `object` | `{}` | MUI `sx` overrides for the grid item wrapper |
|
|
95
|
+
| `cardSx` | `object` | `{}` | MUI `sx` overrides for the card container |
|
|
96
|
+
| `contentSx` | `object` | `{}` | MUI `sx` overrides for the card content area |
|
|
97
|
+
|
|
98
|
+
**`item` shape (common fields):**
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
{
|
|
102
|
+
label: "Revenue per Visitor", // Card title
|
|
103
|
+
value: "$5.12", // Main metric value
|
|
104
|
+
subtitle: "Last 30 days", // Optional subtitle (premium layout)
|
|
105
|
+
trend: "18% vs last month", // Optional trend badge (premium layout)
|
|
106
|
+
data: [3000, 4500, 4200], // Single-series chart data
|
|
107
|
+
categories: ["Jan", "Feb", "Mar"], // X-axis labels
|
|
108
|
+
series: [{ name: "Paid Ads", data: [...] }], // Multi-series (optional)
|
|
109
|
+
stacked: false, // Stack series (optional)
|
|
110
|
+
showSelector: false, // Show metric dropdown (optional)
|
|
111
|
+
hideControls: false, // Hide menu / show legend only (optional)
|
|
112
|
+
height: 250, // Chart height override (optional)
|
|
113
|
+
type: "area", // Per-card chart type override (optional)
|
|
114
|
+
colors: ["#6366F1", "#10B981"], // Custom chart colors (optional)
|
|
115
|
+
footer: { left: "Total", right: "$12k" }, // Optional footer row
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### ActiveCampaignsCard (tree-shakeable)
|
|
120
|
+
|
|
121
|
+
A configurable table card — used for channel performance, active campaigns, and similar ranked lists.
|
|
122
|
+
|
|
123
|
+
```jsx
|
|
124
|
+
import ActiveCampaignsCard from "@ammarkhalidfarooq/dashboard-package/ActiveCampaignsCard";
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Or import from the main entry:
|
|
128
|
+
|
|
129
|
+
```jsx
|
|
130
|
+
import { ActiveCampaignsCard } from "@ammarkhalidfarooq/dashboard-package";
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Channel performance example:**
|
|
134
|
+
|
|
135
|
+
```jsx
|
|
136
|
+
import ActiveCampaignsCard from "@ammarkhalidfarooq/dashboard-package/ActiveCampaignsCard";
|
|
137
|
+
|
|
138
|
+
const channelRows = [
|
|
139
|
+
{
|
|
140
|
+
id: "M",
|
|
141
|
+
avatarBg: "#4267B2",
|
|
142
|
+
name: "Meta Ads",
|
|
143
|
+
val1: "$32,800",
|
|
144
|
+
val2: "$112,400",
|
|
145
|
+
val3: "3.4x",
|
|
146
|
+
val4: "$340",
|
|
147
|
+
type: "trend",
|
|
148
|
+
trendType: "up",
|
|
149
|
+
trendLabel: "Improving",
|
|
150
|
+
highlightVal3: true,
|
|
151
|
+
val3Color: "#22C55E",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "G",
|
|
155
|
+
avatarBg: "#4285F4",
|
|
156
|
+
name: "Google Ads",
|
|
157
|
+
val1: "$28,200",
|
|
158
|
+
val2: "$78,300",
|
|
159
|
+
val3: "2.8x",
|
|
160
|
+
val4: "$385",
|
|
161
|
+
type: "trend",
|
|
162
|
+
trendType: "up",
|
|
163
|
+
trendLabel: "Improving",
|
|
164
|
+
highlightVal3: true,
|
|
165
|
+
val3Color: "#22C55E",
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
const App = () => (
|
|
170
|
+
<ActiveCampaignsCard
|
|
171
|
+
title="Channel performance"
|
|
172
|
+
subtitle="Ad platforms ranked by ROAS"
|
|
173
|
+
columns={["channel", "spend", "revenue", "ROAS", "CPA", "trend"]}
|
|
174
|
+
gridTemplateColumns="2.2fr 1fr 1fr 0.8fr 0.8fr 1.2fr"
|
|
175
|
+
height="100%"
|
|
176
|
+
rows={channelRows}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
export default App;
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Props:**
|
|
184
|
+
|
|
185
|
+
| Prop | Type | Default | Description |
|
|
186
|
+
|------|------|---------|-------------|
|
|
187
|
+
| `title` | `string` | `"Active campaigns"` | Card title |
|
|
188
|
+
| `subtitle` | `string` | `"Live fundraisers ranked by velocity"` | Card subtitle |
|
|
189
|
+
| `actionLabel` | `string` | — | Optional top-right action link text |
|
|
190
|
+
| `columns` | `string[]` | `["Campaign", "Raised", "Progress", "Donors", "Avg gift"]` | Table header labels |
|
|
191
|
+
| `rows` | `object[]` | `[]` | Table row data (see below) |
|
|
192
|
+
| `gridTemplateColumns` | `string` | `"3fr 1fr 1.5fr 0.8fr 1fr"` | CSS grid column template |
|
|
193
|
+
| `height` | `string` | — | Card height (e.g. `"100%"`) |
|
|
194
|
+
| `compact` | `boolean` | `false` | Smaller typography and spacing |
|
|
195
|
+
| `sx` | `object` | `{}` | MUI `sx` overrides for the root card container |
|
|
196
|
+
| `headerSx` | `object` | `{}` | MUI `sx` overrides for the title / subtitle header row |
|
|
197
|
+
| `tableSx` | `object` | `{}` | MUI `sx` overrides for the scrollable table area |
|
|
198
|
+
|
|
199
|
+
**`row` shape:**
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
// Channel performance / trend table (6 columns)
|
|
203
|
+
{
|
|
204
|
+
id: "M", // Avatar label (optional)
|
|
205
|
+
avatarBg: "#4267B2", // Avatar background color
|
|
206
|
+
name: "Meta Ads", // Row label
|
|
207
|
+
val1: "$32,800", // Column 2 (spend / raised)
|
|
208
|
+
val2: "$112,400", // Column 3 when type !== "progress"
|
|
209
|
+
val3: "3.4x", // Column 4 (ROAS / donors)
|
|
210
|
+
val4: "$340", // Column 5 (CPA / avg gift)
|
|
211
|
+
type: "trend", // "trend" | "progress" — controls column 3 & 6
|
|
212
|
+
trendType: "up", // "up" | "down" (when type is "trend")
|
|
213
|
+
trendLabel: "Improving", // Trend badge text
|
|
214
|
+
highlightVal3: true, // Highlight column 4 value
|
|
215
|
+
val3Color: "#22C55E", // Highlight color for column 4
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Campaign progress table (5 columns)
|
|
219
|
+
{
|
|
220
|
+
id: "1",
|
|
221
|
+
name: "Ramadan Appeal",
|
|
222
|
+
val1: "$45,200",
|
|
223
|
+
type: "progress",
|
|
224
|
+
progress: 72,
|
|
225
|
+
progressColor: "rgb(99, 99, 230)",
|
|
226
|
+
val3: "1,240",
|
|
227
|
+
val4: "$36.45",
|
|
228
|
+
status: "Live",
|
|
229
|
+
statusBg: "#DCFCE7",
|
|
230
|
+
statusColor: "#166534",
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### MetricCard (tree-shakeable)
|
|
235
|
+
|
|
236
|
+
A compact KPI card with icon, value, and caption — used for selectable overview metrics.
|
|
237
|
+
|
|
238
|
+
```jsx
|
|
239
|
+
import MetricCard from "@ammarkhalidfarooq/dashboard-package/MetricCard";
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Or import from the main entry:
|
|
243
|
+
|
|
244
|
+
```jsx
|
|
245
|
+
import { MetricCard } from "@ammarkhalidfarooq/dashboard-package";
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Example:**
|
|
249
|
+
|
|
250
|
+
```jsx
|
|
251
|
+
import { useState } from "react";
|
|
252
|
+
import { PaidOutlined as DollarIcon } from "@mui/icons-material";
|
|
253
|
+
import MetricCard from "@ammarkhalidfarooq/dashboard-package/MetricCard";
|
|
254
|
+
|
|
255
|
+
const App = () => {
|
|
256
|
+
const [active, setActive] = useState("Total Raised");
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<MetricCard
|
|
260
|
+
title="Total Raised"
|
|
261
|
+
value="$124,500"
|
|
262
|
+
caption="12.4% vs last month"
|
|
263
|
+
icon={<DollarIcon />}
|
|
264
|
+
active={active === "Total Raised"}
|
|
265
|
+
onClick={() => setActive("Total Raised")}
|
|
266
|
+
/>
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export default App;
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Props:**
|
|
274
|
+
|
|
275
|
+
| Prop | Type | Default | Description |
|
|
276
|
+
|------|------|---------|-------------|
|
|
277
|
+
| `title` | `string` | — | Card label |
|
|
278
|
+
| `value` | `string` | — | Main metric value |
|
|
279
|
+
| `caption` | `string` | — | Subtitle / trend text below the value |
|
|
280
|
+
| `icon` | `ReactNode` | — | Icon shown in the top-right avatar |
|
|
281
|
+
| `active` | `boolean` | `false` | Highlights the card as selected |
|
|
282
|
+
| `warning` | `boolean` | `false` | Warning border and icon styling |
|
|
283
|
+
| `error` | `boolean` | `false` | Error border and caption styling |
|
|
284
|
+
| `onClick` | `function` | — | Click handler (e.g. select metric) |
|
|
285
|
+
| `sx` | `object` | `{}` | MUI `sx` overrides for the root card container |
|
|
286
|
+
| `titleSx` | `object` | `{}` | MUI `sx` overrides for the title text |
|
|
287
|
+
| `valueSx` | `object` | `{}` | MUI `sx` overrides for the main value text |
|
|
288
|
+
| `captionSx` | `object` | `{}` | MUI `sx` overrides for the caption text |
|
|
289
|
+
| `avatarSx` | `object` | `{}` | MUI `sx` overrides for the icon avatar |
|
|
290
|
+
|
|
291
|
+
## Development
|
|
292
|
+
|
|
293
|
+
To preview the component locally:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
npm run dev
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
To build the package:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
npm run build
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
The build outputs ESM and CommonJS bundles in the `dist` folder, including separate `RenderChartCard`, `ActiveCampaignsCard`, and `MetricCard` bundles for tree-shaking.
|