proje-react-panel 1.6.0-test-1 → 1.7.0
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/COLOR_SYSTEM_GUIDE.md +296 -0
- package/DASHBOARD_GUIDE.md +531 -0
- package/README.md +18 -1
- package/dist/components/DashboardContainer.d.ts +7 -0
- package/dist/components/DashboardGrid.d.ts +9 -0
- package/dist/components/DashboardItem.d.ts +10 -0
- package/dist/components/ThemeSwitcher.d.ts +7 -0
- package/dist/components/dashboard/Dashboard.d.ts +7 -0
- package/dist/components/dashboard/DashboardGrid.d.ts +7 -0
- package/dist/components/dashboard/DashboardItem.d.ts +6 -0
- package/dist/components/dashboard/index.d.ts +3 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/store/themeStore.d.ts +23 -0
- package/package.json +1 -1
- package/src/components/dashboard/Dashboard.tsx +11 -0
- package/src/components/dashboard/DashboardGrid.tsx +14 -0
- package/src/components/dashboard/DashboardItem.tsx +9 -0
- package/src/components/dashboard/index.ts +3 -0
- package/src/index.ts +1 -0
- package/src/styles/base/_variables.scss +45 -0
- package/src/styles/components/button.scss +3 -3
- package/src/styles/components/checkbox.scss +6 -6
- package/src/styles/components/form-header.scss +21 -19
- package/src/styles/components/uploader.scss +15 -37
- package/src/styles/counter.scss +25 -33
- package/src/styles/dashboard.scss +9 -0
- package/src/styles/details.scss +6 -15
- package/src/styles/error-boundary.scss +75 -74
- package/src/styles/filter-popup.scss +29 -27
- package/src/styles/form.scss +16 -15
- package/src/styles/index.scss +8 -4
- package/src/styles/layout.scss +9 -8
- package/src/styles/list.scss +29 -27
- package/src/styles/loading-screen.scss +4 -4
- package/src/styles/login.scss +3 -3
- package/src/styles/pagination.scss +13 -13
- package/src/styles/sidebar.scss +24 -22
- package/src/styles/utils/scrollbar.scss +4 -3
- package/dist/components/components/Checkbox.d.ts +0 -7
- package/dist/components/components/Counter.d.ts +0 -9
- package/dist/components/components/ErrorBoundary.d.ts +0 -16
- package/dist/components/components/ErrorComponent.d.ts +0 -4
- package/dist/components/components/FormField.d.ts +0 -17
- package/dist/components/components/ImageUploader.d.ts +0 -15
- package/dist/components/components/InnerForm.d.ts +0 -17
- package/dist/components/components/Label.d.ts +0 -9
- package/dist/components/components/LoadingScreen.d.ts +0 -2
- package/dist/components/components/Uploader.d.ts +0 -8
- package/dist/components/components/index.d.ts +0 -8
- package/dist/components/components/list/Datagrid.d.ts +0 -9
- package/dist/components/components/list/EmptyList.d.ts +0 -2
- package/dist/components/components/list/FilterPopup.d.ts +0 -11
- package/dist/components/components/list/ListPage.d.ts +0 -20
- package/dist/components/components/list/Pagination.d.ts +0 -11
- package/dist/components/components/list/index.d.ts +0 -0
- package/dist/components/pages/ControllerDetails.d.ts +0 -5
- package/dist/components/pages/FormPage.d.ts +0 -18
- package/dist/components/pages/ListPage.d.ts +0 -18
- package/dist/components/pages/Login.d.ts +0 -13
- package/dist/decorators/Crud.d.ts +0 -6
- package/dist/decorators/form/FormOptions.d.ts +0 -7
- package/dist/decorators/form/getFormFields.d.ts +0 -3
- package/dist/decorators/list/GetCellFields.d.ts +0 -2
- package/dist/decorators/list/ImageCell.d.ts +0 -6
- package/dist/decorators/list/ListData.d.ts +0 -6
- package/dist/decorators/list/getListFields.d.ts +0 -2
- package/dist/initPanel.d.ts +0 -2
- package/dist/types/Screen.d.ts +0 -4
- package/dist/types/ScreenCreatorData.d.ts +0 -13
- package/dist/types/getDetailsData.d.ts +0 -1
- package/dist/types/initPanelOptions.d.ts +0 -2
- package/dist/utils/createScreens.d.ts +0 -1
- package/dist/utils/getFields.d.ts +0 -3
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
# Dashboard Components Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to use the Dashboard components from the `proje-react-panel` library to create flexible and responsive dashboard layouts.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Dashboard components provide a simple and flexible way to create grid-based dashboard layouts with:
|
|
8
|
+
|
|
9
|
+
- Configurable grid columns
|
|
10
|
+
- Responsive item containers
|
|
11
|
+
- Simple CSS styling
|
|
12
|
+
- Flexible component composition
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
1. [Quick Start](#quick-start)
|
|
17
|
+
2. [Components](#components)
|
|
18
|
+
3. [Basic Usage](#basic-usage)
|
|
19
|
+
4. [Advanced Usage](#advanced-usage)
|
|
20
|
+
5. [Styling](#styling)
|
|
21
|
+
6. [Examples](#examples)
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Installation
|
|
26
|
+
|
|
27
|
+
The Dashboard components are part of the `proje-react-panel` library:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install proje-react-panel
|
|
31
|
+
# or
|
|
32
|
+
yarn add proje-react-panel
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Basic Example
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { DashboardGrid, DashboardItem, Counter } from 'proje-react-panel';
|
|
39
|
+
|
|
40
|
+
export function MyDashboard() {
|
|
41
|
+
return (
|
|
42
|
+
<DashboardGrid columns={3}>
|
|
43
|
+
<DashboardItem>
|
|
44
|
+
<Counter targetNumber={100} duration={2000} image={''} text={'Products'} />
|
|
45
|
+
</DashboardItem>
|
|
46
|
+
<DashboardItem>
|
|
47
|
+
<Counter targetNumber={50} duration={2000} image={''} text={'Orders'} />
|
|
48
|
+
</DashboardItem>
|
|
49
|
+
<DashboardItem>
|
|
50
|
+
<Counter targetNumber={25} duration={2000} image={''} text={'Users'} />
|
|
51
|
+
</DashboardItem>
|
|
52
|
+
</DashboardGrid>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Components
|
|
58
|
+
|
|
59
|
+
### Dashboard
|
|
60
|
+
|
|
61
|
+
A convenience wrapper component that uses `DashboardGrid` internally.
|
|
62
|
+
|
|
63
|
+
**Props:**
|
|
64
|
+
|
|
65
|
+
- `children` (React.ReactNode): Child components to render
|
|
66
|
+
- `columns?` (number): Number of columns in the grid (default: 3)
|
|
67
|
+
|
|
68
|
+
**Example:**
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { Dashboard } from 'proje-react-panel';
|
|
72
|
+
|
|
73
|
+
<Dashboard columns={3}>
|
|
74
|
+
<DashboardItem>Content 1</DashboardItem>
|
|
75
|
+
<DashboardItem>Content 2</DashboardItem>
|
|
76
|
+
</Dashboard>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### DashboardGrid
|
|
80
|
+
|
|
81
|
+
The main grid container component that creates a CSS Grid layout.
|
|
82
|
+
|
|
83
|
+
**Props:**
|
|
84
|
+
|
|
85
|
+
- `children` (React.ReactNode): Child components to render
|
|
86
|
+
- `columns?` (number): Number of columns in the grid (default: 3)
|
|
87
|
+
|
|
88
|
+
**Example:**
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { DashboardGrid } from 'proje-react-panel';
|
|
92
|
+
|
|
93
|
+
<DashboardGrid columns={3}>{/* Your dashboard items */}</DashboardGrid>;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### DashboardItem
|
|
97
|
+
|
|
98
|
+
A wrapper component for individual dashboard items. Ensures items take full width within their grid cell.
|
|
99
|
+
|
|
100
|
+
**Props:**
|
|
101
|
+
|
|
102
|
+
- `children` (React.ReactNode): Content to render inside the item
|
|
103
|
+
|
|
104
|
+
**Example:**
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import { DashboardItem } from 'proje-react-panel';
|
|
108
|
+
|
|
109
|
+
<DashboardItem>
|
|
110
|
+
<YourComponent />
|
|
111
|
+
</DashboardItem>;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Basic Usage
|
|
115
|
+
|
|
116
|
+
### Simple Grid Layout
|
|
117
|
+
|
|
118
|
+
Create a basic 3-column grid:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
122
|
+
|
|
123
|
+
export function SimpleDashboard() {
|
|
124
|
+
return (
|
|
125
|
+
<DashboardGrid columns={3}>
|
|
126
|
+
<DashboardItem>
|
|
127
|
+
<div>Item 1</div>
|
|
128
|
+
</DashboardItem>
|
|
129
|
+
<DashboardItem>
|
|
130
|
+
<div>Item 2</div>
|
|
131
|
+
</DashboardItem>
|
|
132
|
+
<DashboardItem>
|
|
133
|
+
<div>Item 3</div>
|
|
134
|
+
</DashboardItem>
|
|
135
|
+
</DashboardGrid>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Using Dashboard Wrapper
|
|
141
|
+
|
|
142
|
+
The `Dashboard` component is a convenience wrapper:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import { Dashboard, DashboardItem } from 'proje-react-panel';
|
|
146
|
+
|
|
147
|
+
export function WrappedDashboard() {
|
|
148
|
+
return (
|
|
149
|
+
<Dashboard columns={3}>
|
|
150
|
+
<DashboardItem>Content 1</DashboardItem>
|
|
151
|
+
<DashboardItem>Content 2</DashboardItem>
|
|
152
|
+
<DashboardItem>Content 3</DashboardItem>
|
|
153
|
+
</Dashboard>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Different Column Counts
|
|
159
|
+
|
|
160
|
+
Adjust the number of columns based on your needs:
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
// 2 columns
|
|
164
|
+
<DashboardGrid columns={2}>
|
|
165
|
+
{/* items */}
|
|
166
|
+
</DashboardGrid>
|
|
167
|
+
|
|
168
|
+
// 4 columns
|
|
169
|
+
<DashboardGrid columns={4}>
|
|
170
|
+
{/* items */}
|
|
171
|
+
</DashboardGrid>
|
|
172
|
+
|
|
173
|
+
// 6 columns
|
|
174
|
+
<DashboardGrid columns={6}>
|
|
175
|
+
{/* items */}
|
|
176
|
+
</DashboardGrid>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Advanced Usage
|
|
180
|
+
|
|
181
|
+
### Dynamic Columns
|
|
182
|
+
|
|
183
|
+
Set columns dynamically based on screen size or state:
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { useState } from 'react';
|
|
187
|
+
import { DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
188
|
+
|
|
189
|
+
export function ResponsiveDashboard() {
|
|
190
|
+
const [columns, setColumns] = useState(3);
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
<select value={columns} onChange={e => setColumns(Number(e.target.value))}>
|
|
195
|
+
<option value={1}>1 Column</option>
|
|
196
|
+
<option value={2}>2 Columns</option>
|
|
197
|
+
<option value={3}>3 Columns</option>
|
|
198
|
+
<option value={4}>4 Columns</option>
|
|
199
|
+
</select>
|
|
200
|
+
<DashboardGrid columns={columns}>
|
|
201
|
+
<DashboardItem>Item 1</DashboardItem>
|
|
202
|
+
<DashboardItem>Item 2</DashboardItem>
|
|
203
|
+
<DashboardItem>Item 3</DashboardItem>
|
|
204
|
+
<DashboardItem>Item 4</DashboardItem>
|
|
205
|
+
</DashboardGrid>
|
|
206
|
+
</>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Using with Counter Component
|
|
212
|
+
|
|
213
|
+
Combine Dashboard components with the Counter component:
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { DashboardGrid, DashboardItem, Counter } from 'proje-react-panel';
|
|
217
|
+
|
|
218
|
+
export function StatsDashboard() {
|
|
219
|
+
return (
|
|
220
|
+
<DashboardGrid columns={3}>
|
|
221
|
+
<DashboardItem>
|
|
222
|
+
<Counter targetNumber={100} duration={2000} image={<Icon />} text={'Products'} />
|
|
223
|
+
</DashboardItem>
|
|
224
|
+
<DashboardItem>
|
|
225
|
+
<Counter targetNumber={50} duration={2000} image={<Icon />} text={'Downloads'} />
|
|
226
|
+
</DashboardItem>
|
|
227
|
+
<DashboardItem>
|
|
228
|
+
<Counter targetNumber={25} duration={2000} image={<Icon />} text={'Services'} />
|
|
229
|
+
</DashboardItem>
|
|
230
|
+
</DashboardGrid>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Custom Content
|
|
236
|
+
|
|
237
|
+
Wrap any content in DashboardItem:
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
import { DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
241
|
+
|
|
242
|
+
export function CustomDashboard() {
|
|
243
|
+
return (
|
|
244
|
+
<DashboardGrid columns={2}>
|
|
245
|
+
<DashboardItem>
|
|
246
|
+
<div className="card">
|
|
247
|
+
<h2>Title</h2>
|
|
248
|
+
<p>Content goes here</p>
|
|
249
|
+
</div>
|
|
250
|
+
</DashboardItem>
|
|
251
|
+
<DashboardItem>
|
|
252
|
+
<div className="chart">{/* Chart component */}</div>
|
|
253
|
+
</DashboardItem>
|
|
254
|
+
<DashboardItem>
|
|
255
|
+
<div className="table">{/* Table component */}</div>
|
|
256
|
+
</DashboardItem>
|
|
257
|
+
</DashboardGrid>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Conditional Rendering
|
|
263
|
+
|
|
264
|
+
Render items conditionally:
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
import { DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
268
|
+
|
|
269
|
+
export function ConditionalDashboard({ showStats, showCharts }) {
|
|
270
|
+
return (
|
|
271
|
+
<DashboardGrid columns={3}>
|
|
272
|
+
{showStats && (
|
|
273
|
+
<DashboardItem>
|
|
274
|
+
<StatsComponent />
|
|
275
|
+
</DashboardItem>
|
|
276
|
+
)}
|
|
277
|
+
{showCharts && (
|
|
278
|
+
<DashboardItem>
|
|
279
|
+
<ChartComponent />
|
|
280
|
+
</DashboardItem>
|
|
281
|
+
)}
|
|
282
|
+
<DashboardItem>
|
|
283
|
+
<AlwaysVisibleComponent />
|
|
284
|
+
</DashboardItem>
|
|
285
|
+
</DashboardGrid>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Styling
|
|
291
|
+
|
|
292
|
+
### Default Styles
|
|
293
|
+
|
|
294
|
+
The dashboard components come with minimal default styles:
|
|
295
|
+
|
|
296
|
+
```scss
|
|
297
|
+
.dashboard-grid,
|
|
298
|
+
.dashboard {
|
|
299
|
+
display: grid;
|
|
300
|
+
gap: 1rem;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.dashboard-item {
|
|
304
|
+
width: 100%;
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Custom Styling
|
|
309
|
+
|
|
310
|
+
You can override styles by targeting the CSS classes:
|
|
311
|
+
|
|
312
|
+
```scss
|
|
313
|
+
.dashboard-grid {
|
|
314
|
+
gap: 2rem; // Custom gap
|
|
315
|
+
padding: 1rem;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.dashboard-item {
|
|
319
|
+
width: 100%;
|
|
320
|
+
padding: 1rem;
|
|
321
|
+
background-color: var(--bg-primary);
|
|
322
|
+
border-radius: 8px;
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Responsive Styles
|
|
327
|
+
|
|
328
|
+
Use media queries for responsive layouts:
|
|
329
|
+
|
|
330
|
+
```scss
|
|
331
|
+
.dashboard-grid {
|
|
332
|
+
display: grid;
|
|
333
|
+
gap: 1rem;
|
|
334
|
+
|
|
335
|
+
// Responsive columns
|
|
336
|
+
@media (max-width: 768px) {
|
|
337
|
+
grid-template-columns: 1fr !important;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@media (min-width: 769px) and (max-width: 1024px) {
|
|
341
|
+
grid-template-columns: repeat(2, 1fr) !important;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### CSS Variables
|
|
347
|
+
|
|
348
|
+
Use CSS variables for theming:
|
|
349
|
+
|
|
350
|
+
```scss
|
|
351
|
+
:root {
|
|
352
|
+
--dashboard-gap: 1rem;
|
|
353
|
+
--dashboard-item-padding: 1rem;
|
|
354
|
+
--dashboard-item-radius: 8px;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.dashboard-grid {
|
|
358
|
+
gap: var(--dashboard-gap);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.dashboard-item {
|
|
362
|
+
padding: var(--dashboard-item-padding);
|
|
363
|
+
border-radius: var(--dashboard-item-radius);
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## Examples
|
|
368
|
+
|
|
369
|
+
### Complete Dashboard Example
|
|
370
|
+
|
|
371
|
+
```tsx
|
|
372
|
+
import React from 'react';
|
|
373
|
+
import { DashboardGrid, DashboardItem, Counter } from 'proje-react-panel';
|
|
374
|
+
|
|
375
|
+
export function CompleteDashboard() {
|
|
376
|
+
return (
|
|
377
|
+
<DashboardGrid columns={3}>
|
|
378
|
+
<DashboardItem>
|
|
379
|
+
<Counter targetNumber={100} duration={2000} image={<ProductsIcon />} text={'Products'} />
|
|
380
|
+
</DashboardItem>
|
|
381
|
+
<DashboardItem>
|
|
382
|
+
<Counter targetNumber={50} duration={2000} image={<DownloadsIcon />} text={'Downloads'} />
|
|
383
|
+
</DashboardItem>
|
|
384
|
+
<DashboardItem>
|
|
385
|
+
<Counter targetNumber={25} duration={2000} image={<ServicesIcon />} text={'Services'} />
|
|
386
|
+
</DashboardItem>
|
|
387
|
+
<DashboardItem>
|
|
388
|
+
<Counter targetNumber={10} duration={2000} image={<AdminsIcon />} text={'Admins'} />
|
|
389
|
+
</DashboardItem>
|
|
390
|
+
</DashboardGrid>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Mixed Content Dashboard
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
import { DashboardGrid, DashboardItem, Counter } from 'proje-react-panel';
|
|
399
|
+
|
|
400
|
+
export function MixedDashboard() {
|
|
401
|
+
return (
|
|
402
|
+
<DashboardGrid columns={2}>
|
|
403
|
+
<DashboardItem>
|
|
404
|
+
<Counter targetNumber={100} duration={2000} image={''} text={'Total Users'} />
|
|
405
|
+
</DashboardItem>
|
|
406
|
+
<DashboardItem>
|
|
407
|
+
<div className="recent-activity">
|
|
408
|
+
<h3>Recent Activity</h3>
|
|
409
|
+
{/* Activity list */}
|
|
410
|
+
</div>
|
|
411
|
+
</DashboardItem>
|
|
412
|
+
<DashboardItem>
|
|
413
|
+
<div className="chart">
|
|
414
|
+
<h3>Sales Chart</h3>
|
|
415
|
+
{/* Chart component */}
|
|
416
|
+
</div>
|
|
417
|
+
</DashboardItem>
|
|
418
|
+
<DashboardItem>
|
|
419
|
+
<div className="table">
|
|
420
|
+
<h3>Latest Orders</h3>
|
|
421
|
+
{/* Table component */}
|
|
422
|
+
</div>
|
|
423
|
+
</DashboardItem>
|
|
424
|
+
</DashboardGrid>
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Responsive Dashboard
|
|
430
|
+
|
|
431
|
+
```tsx
|
|
432
|
+
import { useEffect, useState } from 'react';
|
|
433
|
+
import { DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
434
|
+
|
|
435
|
+
export function ResponsiveDashboard() {
|
|
436
|
+
const [columns, setColumns] = useState(3);
|
|
437
|
+
|
|
438
|
+
useEffect(() => {
|
|
439
|
+
const handleResize = () => {
|
|
440
|
+
if (window.innerWidth < 768) {
|
|
441
|
+
setColumns(1);
|
|
442
|
+
} else if (window.innerWidth < 1024) {
|
|
443
|
+
setColumns(2);
|
|
444
|
+
} else {
|
|
445
|
+
setColumns(3);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
handleResize();
|
|
450
|
+
window.addEventListener('resize', handleResize);
|
|
451
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
452
|
+
}, []);
|
|
453
|
+
|
|
454
|
+
return (
|
|
455
|
+
<DashboardGrid columns={columns}>
|
|
456
|
+
<DashboardItem>Item 1</DashboardItem>
|
|
457
|
+
<DashboardItem>Item 2</DashboardItem>
|
|
458
|
+
<DashboardItem>Item 3</DashboardItem>
|
|
459
|
+
<DashboardItem>Item 4</DashboardItem>
|
|
460
|
+
</DashboardGrid>
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
## API Reference
|
|
466
|
+
|
|
467
|
+
### Dashboard Props
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
interface DashboardProps {
|
|
471
|
+
children: React.ReactNode;
|
|
472
|
+
columns?: number; // Default: 3
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### DashboardGrid Props
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
interface DashboardGridProps {
|
|
480
|
+
children: React.ReactNode;
|
|
481
|
+
columns?: number; // Default: 3
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### DashboardItem Props
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
interface DashboardItemProps {
|
|
489
|
+
children: React.ReactNode;
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
## Best Practices
|
|
494
|
+
|
|
495
|
+
1. **Always wrap content in DashboardItem**: This ensures proper spacing and width within grid cells
|
|
496
|
+
2. **Use appropriate column counts**: Consider your content and screen sizes when choosing columns
|
|
497
|
+
3. **Keep styles simple**: The components are designed to be minimal - add custom styling as needed
|
|
498
|
+
4. **Use Dashboard for convenience**: Use `Dashboard` if you prefer a simpler API, or `DashboardGrid` for more control
|
|
499
|
+
5. **Responsive design**: Consider using responsive breakpoints or dynamic column counts for mobile devices
|
|
500
|
+
|
|
501
|
+
## Troubleshooting
|
|
502
|
+
|
|
503
|
+
### Items not displaying correctly
|
|
504
|
+
|
|
505
|
+
- Ensure you're wrapping content in `DashboardItem`
|
|
506
|
+
- Check that CSS styles are properly imported
|
|
507
|
+
- Verify the `columns` prop is set correctly
|
|
508
|
+
|
|
509
|
+
### Grid not responsive
|
|
510
|
+
|
|
511
|
+
- The grid uses CSS Grid with fixed columns
|
|
512
|
+
- Use media queries or dynamic column state for responsive behavior
|
|
513
|
+
- Consider using CSS `grid-template-columns: repeat(auto-fit, minmax(300px, 1fr))` for auto-responsive grids
|
|
514
|
+
|
|
515
|
+
### Styling issues
|
|
516
|
+
|
|
517
|
+
- Check that dashboard styles are imported in your main stylesheet
|
|
518
|
+
- Verify CSS specificity isn't being overridden
|
|
519
|
+
- Use browser DevTools to inspect computed styles
|
|
520
|
+
|
|
521
|
+
## Dependencies
|
|
522
|
+
|
|
523
|
+
The Dashboard components are part of the `proje-react-panel` library and require:
|
|
524
|
+
|
|
525
|
+
- React (^16.8.0 or later)
|
|
526
|
+
- TypeScript (optional, but recommended)
|
|
527
|
+
|
|
528
|
+
## Related Components
|
|
529
|
+
|
|
530
|
+
- [Counter Component](./README.md#counter-component) - For displaying animated counters
|
|
531
|
+
- [Layout Component](./AUTH_LAYOUT_GUIDE.md) - For page layouts with sidebar
|
package/README.md
CHANGED
|
@@ -10,17 +10,21 @@ A powerful and flexible React-based panel library for building administrative in
|
|
|
10
10
|
- **Layout System**: Consistent layout management
|
|
11
11
|
- **Panel Component**: Core panel functionality
|
|
12
12
|
- **Counter Component**: Utility component for counting operations
|
|
13
|
+
- **Dashboard Components**: Flexible grid-based dashboard layout system
|
|
14
|
+
- **Color System**: Centralized color system with SCSS variables and CSS custom properties
|
|
13
15
|
|
|
14
16
|
## Decorators
|
|
15
17
|
|
|
16
18
|
The library provides several decorators for enhanced functionality:
|
|
17
19
|
|
|
18
20
|
### List Decorators
|
|
21
|
+
|
|
19
22
|
- `@List`: Main list decorator for creating list views
|
|
20
23
|
- `@ImageCell`: Specialized cell for handling images in lists
|
|
21
24
|
- `@Cell`: Base cell decorator for list items
|
|
22
25
|
|
|
23
26
|
### Form Decorators
|
|
27
|
+
|
|
24
28
|
- `@Input`: Form input decorator
|
|
25
29
|
- `@Crud`: CRUD operations decorator
|
|
26
30
|
|
|
@@ -35,7 +39,7 @@ yarn add proje-react-panel
|
|
|
35
39
|
## Usage
|
|
36
40
|
|
|
37
41
|
```typescript
|
|
38
|
-
import { Panel, ListPage, FormPage, Login, Layout } from 'proje-react-panel';
|
|
42
|
+
import { Panel, ListPage, FormPage, Login, Layout, DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
39
43
|
|
|
40
44
|
// Initialize the panel
|
|
41
45
|
const panel = new Panel({
|
|
@@ -48,8 +52,21 @@ const panel = new Panel({
|
|
|
48
52
|
<FormPage />
|
|
49
53
|
<Login />
|
|
50
54
|
</Layout>
|
|
55
|
+
|
|
56
|
+
// Dashboard example
|
|
57
|
+
<DashboardGrid columns={3}>
|
|
58
|
+
<DashboardItem>Content 1</DashboardItem>
|
|
59
|
+
<DashboardItem>Content 2</DashboardItem>
|
|
60
|
+
<DashboardItem>Content 3</DashboardItem>
|
|
61
|
+
</DashboardGrid>
|
|
51
62
|
```
|
|
52
63
|
|
|
64
|
+
## Guides
|
|
65
|
+
|
|
66
|
+
- **[Dashboard Guide](./DASHBOARD_GUIDE.md)** - Complete guide for using Dashboard components
|
|
67
|
+
- **[Auth Layout Guide](./AUTH_LAYOUT_GUIDE.md)** - Guide for implementing authentication layouts with sidebar
|
|
68
|
+
- **[Color System Guide](./COLOR_SYSTEM_GUIDE.md)** - Complete documentation of the color system, SCSS variables, and CSS custom properties
|
|
69
|
+
|
|
53
70
|
## Type Definitions
|
|
54
71
|
|
|
55
72
|
The library includes TypeScript definitions for better development experience:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DashboardGridProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
columns?: number;
|
|
5
|
+
gap?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function DashboardGrid({ children, columns, gap, className, }: DashboardGridProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DashboardItemProps {
|
|
3
|
+
targetNumber: number;
|
|
4
|
+
duration?: number;
|
|
5
|
+
image: React.ReactNode;
|
|
6
|
+
text: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function DashboardItem({ targetNumber, duration, image, text, className, }: DashboardItemProps): React.JSX.Element;
|
|
10
|
+
export {};
|