@ammarkhalidfarooq/dashboard-package 0.5.39 → 0.5.40
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 +93 -1
- package/dist/RenderChartCard.cjs.js +669 -0
- package/dist/RenderChartCard.cjs.js.map +1 -0
- package/dist/RenderChartCard.es.js +667 -0
- package/dist/RenderChartCard.es.js.map +1 -0
- package/dist/index.cjs.js +2 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -8,8 +8,16 @@ A reusable React Dashboard component library.
|
|
|
8
8
|
npm install @ammarkhalidfarooq/dashboard-package
|
|
9
9
|
```
|
|
10
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
|
+
|
|
11
17
|
## Usage
|
|
12
18
|
|
|
19
|
+
### Full Dashboard
|
|
20
|
+
|
|
13
21
|
```jsx
|
|
14
22
|
import React from "react";
|
|
15
23
|
import { Dashboard } from "@ammarkhalidfarooq/dashboard-package";
|
|
@@ -21,6 +29,90 @@ const App = () => {
|
|
|
21
29
|
export default App;
|
|
22
30
|
```
|
|
23
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
|
+
|
|
95
|
+
**`item` shape (common fields):**
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
{
|
|
99
|
+
label: "Revenue per Visitor", // Card title
|
|
100
|
+
value: "$5.12", // Main metric value
|
|
101
|
+
subtitle: "Last 30 days", // Optional subtitle (premium layout)
|
|
102
|
+
trend: "18% vs last month", // Optional trend badge (premium layout)
|
|
103
|
+
data: [3000, 4500, 4200], // Single-series chart data
|
|
104
|
+
categories: ["Jan", "Feb", "Mar"], // X-axis labels
|
|
105
|
+
series: [{ name: "Paid Ads", data: [...] }], // Multi-series (optional)
|
|
106
|
+
stacked: false, // Stack series (optional)
|
|
107
|
+
showSelector: false, // Show metric dropdown (optional)
|
|
108
|
+
hideControls: false, // Hide menu / show legend only (optional)
|
|
109
|
+
height: 250, // Chart height override (optional)
|
|
110
|
+
type: "area", // Per-card chart type override (optional)
|
|
111
|
+
colors: ["#6366F1", "#10B981"], // Custom chart colors (optional)
|
|
112
|
+
footer: { left: "Total", right: "$12k" }, // Optional footer row
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
24
116
|
## Development
|
|
25
117
|
|
|
26
118
|
To preview the component locally:
|
|
@@ -35,4 +127,4 @@ To build the package:
|
|
|
35
127
|
npm run build
|
|
36
128
|
```
|
|
37
129
|
|
|
38
|
-
The build outputs
|
|
130
|
+
The build outputs ESM and CommonJS bundles in the `dist` folder, including a separate `RenderChartCard` bundle for tree-shaking.
|