@pattern-stack/frontend-patterns 0.0.4 → 0.0.6
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/dist/atoms/composed/SalesPanel/SalesPanel.d.ts +19 -0
- package/dist/atoms/composed/SalesPanel/SalesPanel.d.ts.map +1 -0
- package/dist/atoms/composed/SalesPanel/index.d.ts +2 -0
- package/dist/atoms/composed/SalesPanel/index.d.ts.map +1 -0
- package/dist/atoms/composed/SalesPanel/mockSalesData.d.ts +63 -0
- package/dist/atoms/composed/SalesPanel/mockSalesData.d.ts.map +1 -0
- package/dist/atoms/composed/index.d.ts +1 -0
- package/dist/atoms/composed/index.d.ts.map +1 -1
- package/dist/atoms/types/entity-config.d.ts +117 -0
- package/dist/atoms/types/entity-config.d.ts.map +1 -0
- package/dist/atoms/types/index.d.ts +2 -0
- package/dist/atoms/types/index.d.ts.map +1 -1
- package/dist/atoms/types/navigation.d.ts +30 -0
- package/dist/atoms/types/navigation.d.ts.map +1 -0
- package/dist/atoms/ui/ErrorBoundary.d.ts +1 -1
- package/dist/atoms/ui/button.d.ts +1 -1
- package/dist/atoms/utils/icon-resolver.d.ts +72 -0
- package/dist/atoms/utils/icon-resolver.d.ts.map +1 -0
- package/dist/atoms/utils/metric-engine.d.ts +30 -0
- package/dist/atoms/utils/metric-engine.d.ts.map +1 -0
- package/dist/atoms/utils/utils.d.ts +2 -0
- package/dist/atoms/utils/utils.d.ts.map +1 -1
- package/dist/features/auth/components/ProtectedRoute.d.ts +1 -1
- package/dist/frontend-patterns.css +1 -1
- package/dist/index.es.js +402 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +402 -14
- package/dist/index.js.map +1 -1
- package/dist/molecules/layout/DashboardWithSidePanel/DashboardWithSidePanel.d.ts +16 -0
- package/dist/molecules/layout/DashboardWithSidePanel/DashboardWithSidePanel.d.ts.map +1 -0
- package/dist/molecules/layout/DashboardWithSidePanel/index.d.ts +2 -0
- package/dist/molecules/layout/DashboardWithSidePanel/index.d.ts.map +1 -0
- package/dist/molecules/layout/NavigationContext.d.ts +15 -0
- package/dist/molecules/layout/NavigationContext.d.ts.map +1 -0
- package/dist/molecules/layout/Sidebar.d.ts.map +1 -1
- package/dist/molecules/layout/SidebarButton/SidebarButton.d.ts +2 -0
- package/dist/molecules/layout/SidebarButton/SidebarButton.d.ts.map +1 -1
- package/dist/molecules/layout/index.d.ts +3 -0
- package/dist/molecules/layout/index.d.ts.map +1 -1
- package/dist/templates/factory.d.ts +2 -1
- package/dist/templates/factory.d.ts.map +1 -1
- package/dist/templates/index.d.ts.map +1 -1
- package/package.json +7 -3
- package/src/App.tsx +11 -1
- package/src/__tests__/atoms/composed/databadge.test.tsx +106 -0
- package/src/__tests__/atoms/composed/statcard.test.tsx +133 -0
- package/src/__tests__/atoms/utils/icon-resolver.test.tsx +140 -0
- package/src/atoms/composed/SalesPanel/SalesPanel.tsx +116 -0
- package/src/atoms/composed/SalesPanel/index.ts +1 -0
- package/src/atoms/composed/SalesPanel/mockSalesData.ts +151 -0
- package/src/atoms/composed/index.ts +1 -0
- package/src/atoms/types/entity-config.ts +127 -0
- package/src/atoms/types/index.ts +3 -1
- package/src/atoms/types/navigation.ts +43 -0
- package/src/atoms/utils/icon-resolver.tsx +54 -0
- package/src/atoms/utils/metric-engine.ts +236 -0
- package/src/atoms/utils/utils.ts +4 -2
- package/src/molecules/layout/DashboardWithSidePanel/DashboardWithSidePanel.tsx +42 -0
- package/src/molecules/layout/DashboardWithSidePanel/index.ts +1 -0
- package/src/molecules/layout/NavigationContext.tsx +63 -0
- package/src/molecules/layout/Sidebar.tsx +10 -23
- package/src/molecules/layout/SidebarButton/SidebarButton.tsx +32 -10
- package/src/molecules/layout/index.ts +4 -1
- package/src/organisms/entity/CategoryBreakdownPanel.tsx +427 -0
- package/src/organisms/entity/EntityListPanel.tsx +339 -0
- package/src/organisms/entity/MetricsOverviewPanel.tsx +236 -0
- package/src/organisms/entity/TrendAnalysisPanel.tsx +337 -0
- package/src/organisms/entity/index.ts +4 -0
- package/src/organisms/index.ts +5 -1
- package/src/pages/AdminShowcase/AdminDashboardShowcase.tsx +77 -75
- package/src/pages/AdminShowcase/SalesPerformanceDashboard.tsx +158 -0
- package/src/pages/AdminShowcase/index.tsx +2 -1
- package/src/pages/EntityShowcase/EntityManagementShowcase.tsx +137 -0
- package/src/pages/EntityShowcase/EntityPerformanceShowcase.tsx +117 -0
- package/src/pages/EntityShowcase/index.ts +2 -0
- package/src/pages/EntityTemplateExample.tsx +229 -0
- package/src/pages/TestEntityTemplate.tsx +40 -0
- package/src/pages/index.ts +2 -1
- package/src/templates/entity/EntityManagementTemplate.tsx +430 -0
- package/src/templates/entity/EntityPerformanceDashboardTemplate.tsx +277 -0
- package/src/templates/entity/configs/financial-config.ts +141 -0
- package/src/templates/entity/configs/index.ts +1 -0
- package/src/templates/entity/index.ts +3 -0
- package/src/templates/factory.tsx +14 -7
- package/src/templates/financial/FinancialDashboardTemplate.tsx +326 -0
- package/src/templates/index.ts +4 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { DashboardWithSidePanel } from '../../molecules/layout';
|
|
3
|
+
import { SalesPanel } from '../../atoms/composed/SalesPanel';
|
|
4
|
+
import { DataTable, StatCard, Chart } from '../../atoms/composed';
|
|
5
|
+
import { Card } from '../../atoms/ui/card';
|
|
6
|
+
import { mockSalesData } from '../../atoms/composed/SalesPanel/mockSalesData';
|
|
7
|
+
import { Button } from '../../atoms/ui/button';
|
|
8
|
+
import { Eye, Filter, Calendar, TrendingUp, Users, Target, DollarSign } from 'lucide-react';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// Mock data for main dashboard
|
|
12
|
+
const salesMetrics = [
|
|
13
|
+
{ title: 'Total Revenue', value: '$1.2M', trend: { value: 15.3, label: 'from last month' }, icon: <DollarSign className="w-5 h-5" />, category: 2 as const },
|
|
14
|
+
{ title: 'Deals Closed', value: '47', trend: { value: 12.8, label: 'from last month' }, icon: <Target className="w-5 h-5" />, category: 3 as const },
|
|
15
|
+
{ title: 'Conversion Rate', value: '24.5%', trend: { value: -2.1, label: 'from last month' }, icon: <TrendingUp className="w-5 h-5" />, category: 1 as const },
|
|
16
|
+
{ title: 'Active Prospects', value: '156', trend: { value: 8.7, label: 'from last month' }, icon: <Users className="w-5 h-5" />, category: 4 as const }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const salesTrendData = [
|
|
20
|
+
{ label: 'Jan', value: 85000 },
|
|
21
|
+
{ label: 'Feb', value: 92000 },
|
|
22
|
+
{ label: 'Mar', value: 108000 },
|
|
23
|
+
{ label: 'Apr', value: 125000 },
|
|
24
|
+
{ label: 'May', value: 118000 },
|
|
25
|
+
{ label: 'Jun', value: 135000 }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const allSalesColumns = [
|
|
29
|
+
{ key: 'customer', header: 'Customer', render: (value: string) => <div className="font-medium">{value}</div> },
|
|
30
|
+
{ key: 'product', header: 'Product', render: (value: string) => <div className="text-sm">{value}</div> },
|
|
31
|
+
{ key: 'amount', header: 'Value', render: (value: number) => <div className="font-semibold text-green-600">${value.toLocaleString()}</div> },
|
|
32
|
+
{ key: 'stage', header: 'Stage', render: (value: string) => <span className="text-sm">{value}</span> },
|
|
33
|
+
{ key: 'salesperson', header: 'Sales Rep', render: (value: string) => <div className="text-sm">{value}</div> },
|
|
34
|
+
{ key: 'region', header: 'Region', render: (value: string) => <div className="text-sm">{value}</div> }
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const SalesPerformanceDashboard: React.FC = () => {
|
|
38
|
+
const [showSidePanel, setShowSidePanel] = useState(true);
|
|
39
|
+
|
|
40
|
+
const handleSaleClick = (sale: any) => {
|
|
41
|
+
console.log('Deal selected:', sale);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<DashboardWithSidePanel
|
|
46
|
+
showSidePanel={showSidePanel}
|
|
47
|
+
sidePanel={
|
|
48
|
+
<SalesPanel
|
|
49
|
+
sales={mockSalesData}
|
|
50
|
+
onSaleClick={handleSaleClick}
|
|
51
|
+
onClose={() => setShowSidePanel(false)}
|
|
52
|
+
/>
|
|
53
|
+
}
|
|
54
|
+
>
|
|
55
|
+
<div className="p-6 space-y-6">
|
|
56
|
+
{/* Header */}
|
|
57
|
+
<div className="flex items-center justify-between">
|
|
58
|
+
<div>
|
|
59
|
+
<h1 className="text-2xl font-bold">Sales Performance</h1>
|
|
60
|
+
<p className="text-muted-foreground">Monitor sales metrics, team performance, and revenue trends</p>
|
|
61
|
+
</div>
|
|
62
|
+
<div className="flex gap-2">
|
|
63
|
+
<Button
|
|
64
|
+
variant="outline"
|
|
65
|
+
size="sm"
|
|
66
|
+
onClick={() => setShowSidePanel(!showSidePanel)}
|
|
67
|
+
>
|
|
68
|
+
<Eye className="w-4 h-4 mr-2" />
|
|
69
|
+
{showSidePanel ? 'Hide' : 'Show'} Pipeline
|
|
70
|
+
</Button>
|
|
71
|
+
<Button variant="outline" size="sm">
|
|
72
|
+
<Filter className="w-4 h-4 mr-2" />
|
|
73
|
+
Filter by Region
|
|
74
|
+
</Button>
|
|
75
|
+
<Button variant="outline" size="sm">
|
|
76
|
+
<Calendar className="w-4 h-4 mr-2" />
|
|
77
|
+
Date Range
|
|
78
|
+
</Button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
{/* Metrics */}
|
|
83
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
84
|
+
{salesMetrics.map((metric, index) => (
|
|
85
|
+
<StatCard
|
|
86
|
+
key={index}
|
|
87
|
+
title={metric.title}
|
|
88
|
+
value={metric.value}
|
|
89
|
+
trend={metric.trend}
|
|
90
|
+
icon={metric.icon}
|
|
91
|
+
category={metric.category}
|
|
92
|
+
/>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
{/* Charts */}
|
|
97
|
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
98
|
+
<Card className="p-6">
|
|
99
|
+
<Chart
|
|
100
|
+
title="Revenue Trend"
|
|
101
|
+
type="line"
|
|
102
|
+
data={salesTrendData}
|
|
103
|
+
category={2}
|
|
104
|
+
noWrapper={true}
|
|
105
|
+
/>
|
|
106
|
+
</Card>
|
|
107
|
+
|
|
108
|
+
<Card className="p-6">
|
|
109
|
+
<h3 className="font-semibold mb-4">Sales by Region</h3>
|
|
110
|
+
<div className="space-y-3">
|
|
111
|
+
<div className="flex justify-between items-center">
|
|
112
|
+
<span>North America</span>
|
|
113
|
+
<div className="flex items-center gap-2">
|
|
114
|
+
<div className="w-24 h-2 bg-muted rounded-full overflow-hidden">
|
|
115
|
+
<div className="w-3/5 h-full bg-category-2 rounded-full"></div>
|
|
116
|
+
</div>
|
|
117
|
+
<span className="text-sm font-medium">$750K</span>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="flex justify-between items-center">
|
|
121
|
+
<span>Europe</span>
|
|
122
|
+
<div className="flex items-center gap-2">
|
|
123
|
+
<div className="w-24 h-2 bg-muted rounded-full overflow-hidden">
|
|
124
|
+
<div className="w-2/5 h-full bg-category-1 rounded-full"></div>
|
|
125
|
+
</div>
|
|
126
|
+
<span className="text-sm font-medium">$320K</span>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
<div className="flex justify-between items-center">
|
|
130
|
+
<span>Asia Pacific</span>
|
|
131
|
+
<div className="flex items-center gap-2">
|
|
132
|
+
<div className="w-24 h-2 bg-muted rounded-full overflow-hidden">
|
|
133
|
+
<div className="w-1/4 h-full bg-category-3 rounded-full"></div>
|
|
134
|
+
</div>
|
|
135
|
+
<span className="text-sm font-medium">$130K</span>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</Card>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
{/* Detailed Sales Table */}
|
|
143
|
+
<Card className="p-6">
|
|
144
|
+
<h3 className="font-semibold mb-4">All Sales Opportunities</h3>
|
|
145
|
+
<DataTable
|
|
146
|
+
data={mockSalesData}
|
|
147
|
+
columns={allSalesColumns}
|
|
148
|
+
showSearch={true}
|
|
149
|
+
searchPlaceholder="Search deals, customers, or products..."
|
|
150
|
+
onRowClick={handleSaleClick}
|
|
151
|
+
/>
|
|
152
|
+
</Card>
|
|
153
|
+
</div>
|
|
154
|
+
</DashboardWithSidePanel>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export default SalesPerformanceDashboard;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { AdminDashboardShowcase } from './AdminDashboardShowcase';
|
|
2
2
|
export { AdminCRUDShowcase } from './AdminCRUDShowcase';
|
|
3
|
-
export { AdminDetailShowcase } from './AdminDetailShowcase';
|
|
3
|
+
export { AdminDetailShowcase } from './AdminDetailShowcase';
|
|
4
|
+
export { SalesPerformanceDashboard } from './SalesPerformanceDashboard';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { EntityListPanel } from '../../organisms/entity';
|
|
3
|
+
import { financialConfig, sampleFinancialData, type FinancialTransaction } from '../../templates/entity/configs/financial-config';
|
|
4
|
+
import { ShowcaseSection } from '../../molecules/layout/ShowcaseSection';
|
|
5
|
+
import { IconBadge } from '../../atoms/composed/IconBadge';
|
|
6
|
+
import { Switch } from '../../atoms/ui/Switch';
|
|
7
|
+
import { Button } from '../../atoms/ui/button';
|
|
8
|
+
import { Database, Filter, Search, Download, Plus, Layers } from 'lucide-react';
|
|
9
|
+
|
|
10
|
+
export const EntityManagementShowcase: React.FC = () => {
|
|
11
|
+
const [enableSearch, setEnableSearch] = useState(true);
|
|
12
|
+
const [enableFiltering, setEnableFiltering] = useState(true);
|
|
13
|
+
const [enableBulkActions, setEnableBulkActions] = useState(true);
|
|
14
|
+
const [enableExport, setEnableExport] = useState(true);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="min-h-screen bg-background">
|
|
18
|
+
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-12">
|
|
19
|
+
<div className="flex items-center justify-between mb-12">
|
|
20
|
+
<div className="flex items-center space-x-4">
|
|
21
|
+
<IconBadge
|
|
22
|
+
variant="category"
|
|
23
|
+
category={7}
|
|
24
|
+
size="lg"
|
|
25
|
+
icon={<Database className="w-6 h-6" />}
|
|
26
|
+
/>
|
|
27
|
+
<div>
|
|
28
|
+
<h1 className="text-4xl font-bold text-foreground">Entity Management</h1>
|
|
29
|
+
<p className="text-lg text-muted-foreground mt-2">
|
|
30
|
+
Cross-domain template for CRUD operations with intelligent search, filtering, and bulk actions
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div className="flex items-center space-x-3">
|
|
36
|
+
<Button variant="outline" size="sm">
|
|
37
|
+
<Plus className="w-4 h-4 mr-2" />
|
|
38
|
+
Add Transaction
|
|
39
|
+
</Button>
|
|
40
|
+
<div className="flex items-center gap-3 bg-card/80 backdrop-blur-sm border border-border/50 rounded px-3 py-2">
|
|
41
|
+
<Layers className="w-4 h-4 text-muted-foreground" />
|
|
42
|
+
<span className="text-sm font-medium text-foreground">Demo Mode</span>
|
|
43
|
+
<Switch checked={true} disabled />
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
{/* Feature Toggles */}
|
|
49
|
+
<div className="mb-8">
|
|
50
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
51
|
+
<div className="flex items-center gap-3 bg-card/50 backdrop-blur-sm border border-border/30 rounded px-3 py-2">
|
|
52
|
+
<Search className="w-4 h-4 text-muted-foreground" />
|
|
53
|
+
<span className="text-sm font-medium text-foreground">Search</span>
|
|
54
|
+
<Switch
|
|
55
|
+
checked={enableSearch}
|
|
56
|
+
onCheckedChange={setEnableSearch}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
<div className="flex items-center gap-3 bg-card/50 backdrop-blur-sm border border-border/30 rounded px-3 py-2">
|
|
60
|
+
<Filter className="w-4 h-4 text-muted-foreground" />
|
|
61
|
+
<span className="text-sm font-medium text-foreground">Filters</span>
|
|
62
|
+
<Switch
|
|
63
|
+
checked={enableFiltering}
|
|
64
|
+
onCheckedChange={setEnableFiltering}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
<div className="flex items-center gap-3 bg-card/50 backdrop-blur-sm border border-border/30 rounded px-3 py-2">
|
|
68
|
+
<Database className="w-4 h-4 text-muted-foreground" />
|
|
69
|
+
<span className="text-sm font-medium text-foreground">Bulk Actions</span>
|
|
70
|
+
<Switch
|
|
71
|
+
checked={enableBulkActions}
|
|
72
|
+
onCheckedChange={setEnableBulkActions}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
<div className="flex items-center gap-3 bg-card/50 backdrop-blur-sm border border-border/30 rounded px-3 py-2">
|
|
76
|
+
<Download className="w-4 h-4 text-muted-foreground" />
|
|
77
|
+
<span className="text-sm font-medium text-foreground">Export</span>
|
|
78
|
+
<Switch
|
|
79
|
+
checked={enableExport}
|
|
80
|
+
onCheckedChange={setEnableExport}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div className="space-y-12">
|
|
87
|
+
<ShowcaseSection
|
|
88
|
+
title="Entity List with Advanced Features"
|
|
89
|
+
description="Smart data table with domain-aware column rendering, search, filtering, and bulk operations"
|
|
90
|
+
badge={{
|
|
91
|
+
text: "Full Featured",
|
|
92
|
+
variant: "category",
|
|
93
|
+
category: 3
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<EntityListPanel
|
|
97
|
+
config={financialConfig}
|
|
98
|
+
data={sampleFinancialData}
|
|
99
|
+
isLoading={false}
|
|
100
|
+
enableSearch={enableSearch}
|
|
101
|
+
enableFiltering={enableFiltering}
|
|
102
|
+
enableBulkActions={enableBulkActions}
|
|
103
|
+
enableExport={enableExport}
|
|
104
|
+
onItemClick={(item: FinancialTransaction) => {
|
|
105
|
+
console.log('Item clicked:', item);
|
|
106
|
+
}}
|
|
107
|
+
onItemEdit={(item: FinancialTransaction) => {
|
|
108
|
+
console.log('Item edit:', item);
|
|
109
|
+
}}
|
|
110
|
+
onItemDelete={(item: FinancialTransaction) => {
|
|
111
|
+
console.log('Item delete:', item);
|
|
112
|
+
}}
|
|
113
|
+
onBulkAction={(action: string, items: FinancialTransaction[]) => {
|
|
114
|
+
console.log('Bulk action:', action, items);
|
|
115
|
+
}}
|
|
116
|
+
onSearch={(query: string) => {
|
|
117
|
+
console.log('Search:', query);
|
|
118
|
+
}}
|
|
119
|
+
onFilter={(filters: Record<string, any>) => {
|
|
120
|
+
console.log('Filter:', filters);
|
|
121
|
+
}}
|
|
122
|
+
onSort={(field: string, direction: 'asc' | 'desc') => {
|
|
123
|
+
console.log('Sort:', field, direction);
|
|
124
|
+
}}
|
|
125
|
+
onExport={(format: 'csv' | 'json' | 'xlsx') => {
|
|
126
|
+
console.log('Export:', format);
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
</ShowcaseSection>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export default EntityManagementShowcase;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
MetricsOverviewWithInsightsPanel,
|
|
4
|
+
TrendAnalysisPanel,
|
|
5
|
+
CategoryBreakdownPanel
|
|
6
|
+
} from '../../organisms/entity';
|
|
7
|
+
import { financialConfig, sampleFinancialData } from '../../templates/entity/configs/financial-config';
|
|
8
|
+
import { ShowcaseSection } from '../../molecules/layout/ShowcaseSection';
|
|
9
|
+
import { IconBadge } from '../../atoms/composed/IconBadge';
|
|
10
|
+
import { Switch } from '../../atoms/ui/Switch';
|
|
11
|
+
import { BarChart3, TrendingUp, PieChart, Layers } from 'lucide-react';
|
|
12
|
+
|
|
13
|
+
export const EntityPerformanceShowcase: React.FC = () => {
|
|
14
|
+
const [showInsights, setShowInsights] = useState(true);
|
|
15
|
+
const [showTrends, setShowTrends] = useState(true);
|
|
16
|
+
const [showCategories, setShowCategories] = useState(true);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="min-h-screen bg-background">
|
|
20
|
+
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-12">
|
|
21
|
+
<div className="flex items-center justify-between mb-12">
|
|
22
|
+
<div className="flex items-center space-x-4">
|
|
23
|
+
<IconBadge
|
|
24
|
+
variant="category"
|
|
25
|
+
category={6}
|
|
26
|
+
size="lg"
|
|
27
|
+
icon={<BarChart3 className="w-6 h-6" />}
|
|
28
|
+
/>
|
|
29
|
+
<div>
|
|
30
|
+
<h1 className="text-4xl font-bold text-foreground">Performance Dashboard</h1>
|
|
31
|
+
<p className="text-lg text-muted-foreground mt-2">
|
|
32
|
+
Cross-domain entity template showcasing configurable performance metrics and analytics
|
|
33
|
+
</p>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div className="flex items-center space-x-3">
|
|
38
|
+
<div className="flex items-center gap-3 bg-card/80 backdrop-blur-sm border border-border/50 rounded px-3 py-2">
|
|
39
|
+
<Layers className="w-4 h-4 text-muted-foreground" />
|
|
40
|
+
<span className="text-sm font-medium text-foreground">Live Data</span>
|
|
41
|
+
<Switch checked={true} disabled />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div className="space-y-12">
|
|
47
|
+
{showInsights && (
|
|
48
|
+
<ShowcaseSection
|
|
49
|
+
title="Metrics Overview with Insights"
|
|
50
|
+
description="Configurable KPI displays with automated insights and trend indicators"
|
|
51
|
+
badge={{
|
|
52
|
+
text: "Interactive",
|
|
53
|
+
variant: "category",
|
|
54
|
+
category: 2
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<MetricsOverviewWithInsightsPanel
|
|
58
|
+
metrics={financialConfig.metrics}
|
|
59
|
+
data={sampleFinancialData}
|
|
60
|
+
isLoading={false}
|
|
61
|
+
showInsights={true}
|
|
62
|
+
onMetricClick={(metric, value) => {
|
|
63
|
+
console.log('Metric clicked:', metric.label, value);
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
</ShowcaseSection>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{showTrends && (
|
|
70
|
+
<ShowcaseSection
|
|
71
|
+
title="Trend Analysis"
|
|
72
|
+
description="Time-series visualizations with forecasting and period comparison"
|
|
73
|
+
badge={{
|
|
74
|
+
text: "Dynamic",
|
|
75
|
+
variant: "category",
|
|
76
|
+
category: 4
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<TrendAnalysisPanel
|
|
80
|
+
metrics={financialConfig.metrics}
|
|
81
|
+
data={sampleFinancialData}
|
|
82
|
+
isLoading={false}
|
|
83
|
+
onTrendPeriodChange={(period) => {
|
|
84
|
+
console.log('Trend period changed:', period);
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</ShowcaseSection>
|
|
88
|
+
)}
|
|
89
|
+
|
|
90
|
+
{showCategories && (
|
|
91
|
+
<ShowcaseSection
|
|
92
|
+
title="Category Breakdown"
|
|
93
|
+
description="Hierarchical data visualization with drill-down capabilities"
|
|
94
|
+
badge={{
|
|
95
|
+
text: "Explorable",
|
|
96
|
+
variant: "category",
|
|
97
|
+
category: 7
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<CategoryBreakdownPanel
|
|
101
|
+
categoryConfig={financialConfig.categories}
|
|
102
|
+
valueField="amount"
|
|
103
|
+
data={sampleFinancialData}
|
|
104
|
+
isLoading={false}
|
|
105
|
+
onCategoryClick={(category) => {
|
|
106
|
+
console.log('Category clicked:', category);
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
</ShowcaseSection>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default EntityPerformanceShowcase;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { EntityPerformanceDashboardTemplate } from '../templates/entity';
|
|
3
|
+
import { DashboardWithSidePanel } from '../molecules/layout';
|
|
4
|
+
import { financialConfig, sampleFinancialData } from '../templates/entity/configs/financial-config';
|
|
5
|
+
import { DataTable } from '../atoms/composed/DataTable';
|
|
6
|
+
import { DataBadge } from '../atoms/composed/DataBadge';
|
|
7
|
+
import { Card } from '../atoms/ui/card';
|
|
8
|
+
import { Button } from '../atoms/ui/button';
|
|
9
|
+
import { DollarSign, TrendingUp, TrendingDown, Eye, Filter } from 'lucide-react';
|
|
10
|
+
|
|
11
|
+
// Enhanced transaction data for side panel
|
|
12
|
+
const recentTransactions = [
|
|
13
|
+
{
|
|
14
|
+
id: 'TXN-001',
|
|
15
|
+
description: 'Product Sale - Premium Package',
|
|
16
|
+
amount: 2499.99,
|
|
17
|
+
type: 'income',
|
|
18
|
+
category: 'Sales',
|
|
19
|
+
date: '2024-06-08',
|
|
20
|
+
status: 'completed',
|
|
21
|
+
customer: 'Acme Corp'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'TXN-002',
|
|
25
|
+
description: 'Subscription Revenue',
|
|
26
|
+
amount: 149.99,
|
|
27
|
+
type: 'income',
|
|
28
|
+
category: 'Recurring',
|
|
29
|
+
date: '2024-06-08',
|
|
30
|
+
status: 'completed',
|
|
31
|
+
customer: 'TechStart Inc'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'TXN-003',
|
|
35
|
+
description: 'Refund - Service Cancellation',
|
|
36
|
+
amount: -299.99,
|
|
37
|
+
type: 'expense',
|
|
38
|
+
category: 'Refunds',
|
|
39
|
+
date: '2024-06-07',
|
|
40
|
+
status: 'processed',
|
|
41
|
+
customer: 'Beta Solutions'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'TXN-004',
|
|
45
|
+
description: 'Consulting Services',
|
|
46
|
+
amount: 1200.00,
|
|
47
|
+
type: 'income',
|
|
48
|
+
category: 'Services',
|
|
49
|
+
date: '2024-06-07',
|
|
50
|
+
status: 'completed',
|
|
51
|
+
customer: 'Global Enterprises'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'TXN-005',
|
|
55
|
+
description: 'Platform License',
|
|
56
|
+
amount: 599.99,
|
|
57
|
+
type: 'income',
|
|
58
|
+
category: 'Licenses',
|
|
59
|
+
date: '2024-06-06',
|
|
60
|
+
status: 'pending',
|
|
61
|
+
customer: 'StartupXYZ'
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const transactionColumns = [
|
|
66
|
+
{
|
|
67
|
+
key: 'id',
|
|
68
|
+
header: 'Transaction ID',
|
|
69
|
+
render: (value: string) => (
|
|
70
|
+
<code className="text-xs bg-muted px-2 py-1 rounded">{value}</code>
|
|
71
|
+
)
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: 'description',
|
|
75
|
+
header: 'Description',
|
|
76
|
+
render: (value: string) => (
|
|
77
|
+
<div className="max-w-[200px] truncate" title={value}>
|
|
78
|
+
{value}
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: 'amount',
|
|
84
|
+
header: 'Amount',
|
|
85
|
+
render: (value: number) => (
|
|
86
|
+
<div className={`font-medium ${value >= 0 ? 'text-green-600' : 'text-red-600'}`}>
|
|
87
|
+
{value >= 0 ? '+' : ''}${Math.abs(value).toLocaleString()}
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: 'category',
|
|
93
|
+
header: 'Category',
|
|
94
|
+
render: (value: string) => (
|
|
95
|
+
<DataBadge variant="category" category={1}>
|
|
96
|
+
{value}
|
|
97
|
+
</DataBadge>
|
|
98
|
+
)
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: 'status',
|
|
102
|
+
header: 'Status',
|
|
103
|
+
render: (value: string) => (
|
|
104
|
+
<DataBadge variant="status" status={value === 'completed' ? 'success' : value === 'pending' ? 'warning' : 'info'}>
|
|
105
|
+
{value}
|
|
106
|
+
</DataBadge>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
export const EntityTemplateExample: React.FC = () => {
|
|
112
|
+
const [showSidePanel, setShowSidePanel] = useState(true);
|
|
113
|
+
|
|
114
|
+
const handleTransactionClick = (transaction: any) => {
|
|
115
|
+
console.log('Transaction selected:', transaction);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<DashboardWithSidePanel
|
|
120
|
+
showSidePanel={showSidePanel}
|
|
121
|
+
sidePanelWidth={80}
|
|
122
|
+
sidePanel={
|
|
123
|
+
<div className="fixed right-0 top-16 h-[calc(100vh-4rem)] w-80 bg-background border-l border-border shadow-lg flex flex-col z-30">
|
|
124
|
+
{/* Side Panel Header */}
|
|
125
|
+
<div className="p-4 border-b border-border bg-muted/30">
|
|
126
|
+
<div className="flex items-center justify-between">
|
|
127
|
+
<h3 className="font-semibold">Recent Transactions</h3>
|
|
128
|
+
<Button
|
|
129
|
+
variant="ghost"
|
|
130
|
+
size="sm"
|
|
131
|
+
onClick={() => setShowSidePanel(false)}
|
|
132
|
+
>
|
|
133
|
+
×
|
|
134
|
+
</Button>
|
|
135
|
+
</div>
|
|
136
|
+
<p className="text-sm text-muted-foreground mt-1">
|
|
137
|
+
Latest financial activity
|
|
138
|
+
</p>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
{/* Transaction Summary Cards */}
|
|
142
|
+
<div className="p-4 space-y-3 border-b border-border">
|
|
143
|
+
<Card className="p-3">
|
|
144
|
+
<div className="flex items-center justify-between">
|
|
145
|
+
<div className="flex items-center gap-2">
|
|
146
|
+
<TrendingUp className="w-4 h-4 text-green-600" />
|
|
147
|
+
<span className="text-sm font-medium">Today's Income</span>
|
|
148
|
+
</div>
|
|
149
|
+
<span className="text-green-600 font-semibold">+$2,649.98</span>
|
|
150
|
+
</div>
|
|
151
|
+
</Card>
|
|
152
|
+
|
|
153
|
+
<Card className="p-3">
|
|
154
|
+
<div className="flex items-center justify-between">
|
|
155
|
+
<div className="flex items-center gap-2">
|
|
156
|
+
<TrendingDown className="w-4 h-4 text-red-600" />
|
|
157
|
+
<span className="text-sm font-medium">Today's Expenses</span>
|
|
158
|
+
</div>
|
|
159
|
+
<span className="text-red-600 font-semibold">-$299.99</span>
|
|
160
|
+
</div>
|
|
161
|
+
</Card>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
{/* Transaction List */}
|
|
165
|
+
<div className="flex-1 overflow-auto p-4">
|
|
166
|
+
<DataTable
|
|
167
|
+
data={recentTransactions}
|
|
168
|
+
columns={transactionColumns}
|
|
169
|
+
showSearch={true}
|
|
170
|
+
searchPlaceholder="Search transactions..."
|
|
171
|
+
showPagination={false}
|
|
172
|
+
onRowClick={handleTransactionClick}
|
|
173
|
+
className="text-xs"
|
|
174
|
+
compact={true}
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
{/* Side Panel Footer */}
|
|
179
|
+
<div className="p-4 border-t border-border bg-muted/30">
|
|
180
|
+
<Button variant="outline" size="sm" className="w-full">
|
|
181
|
+
<DollarSign className="w-4 h-4 mr-2" />
|
|
182
|
+
View All Transactions
|
|
183
|
+
</Button>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
}
|
|
187
|
+
>
|
|
188
|
+
<EntityPerformanceDashboardTemplate
|
|
189
|
+
config={financialConfig}
|
|
190
|
+
data={sampleFinancialData}
|
|
191
|
+
isLoading={false}
|
|
192
|
+
layout="standard"
|
|
193
|
+
showInsights={true}
|
|
194
|
+
showTrends={true}
|
|
195
|
+
showCategories={true}
|
|
196
|
+
onMetricClick={(metric, value) => {
|
|
197
|
+
console.log('Metric clicked:', metric.label, value);
|
|
198
|
+
}}
|
|
199
|
+
onCategoryClick={(category) => {
|
|
200
|
+
console.log('Category clicked:', category);
|
|
201
|
+
}}
|
|
202
|
+
onTrendPeriodChange={(period) => {
|
|
203
|
+
console.log('Trend period changed:', period);
|
|
204
|
+
}}
|
|
205
|
+
onExport={(type, data) => {
|
|
206
|
+
console.log('Export requested:', type, data);
|
|
207
|
+
}}
|
|
208
|
+
headerSlot={
|
|
209
|
+
<div className="flex gap-2">
|
|
210
|
+
<Button
|
|
211
|
+
variant="outline"
|
|
212
|
+
size="sm"
|
|
213
|
+
onClick={() => setShowSidePanel(!showSidePanel)}
|
|
214
|
+
>
|
|
215
|
+
<Eye className="w-4 h-4 mr-2" />
|
|
216
|
+
{showSidePanel ? 'Hide' : 'Show'} Transactions
|
|
217
|
+
</Button>
|
|
218
|
+
<Button variant="outline" size="sm">
|
|
219
|
+
<Filter className="w-4 h-4 mr-2" />
|
|
220
|
+
Filter Data
|
|
221
|
+
</Button>
|
|
222
|
+
</div>
|
|
223
|
+
}
|
|
224
|
+
/>
|
|
225
|
+
</DashboardWithSidePanel>
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export default EntityTemplateExample;
|