react-groundwork 0.0.0-stage → 0.1.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/.env.example +6 -0
- package/.gitattributes +2 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +12 -0
- package/README.md +24 -2
- package/cli/index.js +119 -0
- package/components.json +25 -0
- package/eslint.config.js +17 -0
- package/index.html +13 -0
- package/jsconfig.json +8 -0
- package/package.json +111 -4
- package/public/.htaccess +11 -0
- package/public/logo.png +0 -0
- package/src/App.jsx +14 -0
- package/src/api/api.routes.js +12 -0
- package/src/api/api.services.js +8 -0
- package/src/api/apiCall.js +128 -0
- package/src/api/apiHelpers.js +20 -0
- package/src/assets/css/index.css +173 -0
- package/src/assets/images/placeholders/placeholder-170x166.png +0 -0
- package/src/assets/images/placeholders/placeholder-360x260.png +0 -0
- package/src/assets/images/placeholders/placeholder-372x225.png +0 -0
- package/src/assets/images/placeholders/placeholder-40x40.png +0 -0
- package/src/assets/images/placeholders/placeholder-451x392.png +0 -0
- package/src/components/common/AppChart.jsx +56 -0
- package/src/components/common/Breadcrumbs.jsx +90 -0
- package/src/components/common/DataTable.jsx +203 -0
- package/src/components/common/DatePicker.jsx +275 -0
- package/src/components/common/DialogComponent.jsx +308 -0
- package/src/components/common/ErrorStateComponent.jsx +46 -0
- package/src/components/common/FullscreenToggle.jsx +54 -0
- package/src/components/common/HeadingComponent.jsx +29 -0
- package/src/components/common/LoadingComponent.jsx +33 -0
- package/src/components/common/NetworkStatus.jsx +103 -0
- package/src/components/common/NoDataComponent.jsx +45 -0
- package/src/components/common/Pagination.jsx +128 -0
- package/src/components/common/ParagraphComponent.jsx +14 -0
- package/src/components/common/PhoneInputComponent.jsx +242 -0
- package/src/components/common/ReactSelect.jsx +145 -0
- package/src/components/common/SearchSelect.jsx +176 -0
- package/src/components/common/SeeMore.jsx +26 -0
- package/src/components/common/SortableHeader.jsx +23 -0
- package/src/components/common/theme-toggle.jsx +39 -0
- package/src/components/layout/AuthLayout.jsx +90 -0
- package/src/components/layout/PageLayout.jsx +32 -0
- package/src/components/layout/SidebarLayout.jsx +233 -0
- package/src/components/ui/avatar.jsx +84 -0
- package/src/components/ui/badge.jsx +43 -0
- package/src/components/ui/button.jsx +44 -0
- package/src/components/ui/card.jsx +69 -0
- package/src/components/ui/checkbox.jsx +25 -0
- package/src/components/ui/dialog.jsx +149 -0
- package/src/components/ui/empty.jsx +82 -0
- package/src/components/ui/input.jsx +19 -0
- package/src/components/ui/label.jsx +19 -0
- package/src/components/ui/select.jsx +156 -0
- package/src/components/ui/skeleton.jsx +7 -0
- package/src/components/ui/sonner.jsx +37 -0
- package/src/components/ui/switch.jsx +23 -0
- package/src/components/ui/table.jsx +74 -0
- package/src/components/ui/textarea.jsx +16 -0
- package/src/constants/constant.js +16 -0
- package/src/context/theme-provider.jsx +48 -0
- package/src/features/components/ComponentFormDialog.jsx +162 -0
- package/src/features/components/ComponentsTable.jsx +219 -0
- package/src/features/components/componentStyles.js +16 -0
- package/src/features/components/mockData.js +407 -0
- package/src/features/playground/BasicsSection.jsx +122 -0
- package/src/features/playground/DataSection.jsx +210 -0
- package/src/features/playground/DemoCard.jsx +21 -0
- package/src/features/playground/FeedbackSection.jsx +309 -0
- package/src/features/playground/FormsSection.jsx +188 -0
- package/src/features/playground/UtilitiesSection.jsx +200 -0
- package/src/hooks/useApiHandler.jsx +82 -0
- package/src/hooks/useDebounce.js +12 -0
- package/src/lib/utils.js +1 -0
- package/src/main.jsx +16 -0
- package/src/pages/auth/ForgotPasswordPage.jsx +101 -0
- package/src/pages/auth/LoginPage.jsx +120 -0
- package/src/pages/auth/SignupPage.jsx +135 -0
- package/src/pages/views/ComponentsPage.jsx +316 -0
- package/src/pages/views/DashboardPage.jsx +260 -0
- package/src/pages/views/LandingPage.jsx +772 -0
- package/src/pages/views/NotFoundPage.jsx +30 -0
- package/src/pages/views/PlaygroundPage.jsx +50 -0
- package/src/routes/AppRoutes.jsx +29 -0
- package/src/routes/ProtectedRoute.jsx +18 -0
- package/src/utils/exportCsv.js +17 -0
- package/src/utils/formatCurrency.js +19 -0
- package/src/utils/formatDateTime.js +34 -0
- package/src/utils/handleSessionExpire.js +22 -0
- package/src/utils/logger.js +34 -0
- package/vite.config.js +23 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Link } from "react-router-dom";
|
|
2
|
+
import { ArrowRight, Boxes, CircleCheck, FileCode2, FlaskConical, Layers } from "lucide-react";
|
|
3
|
+
import PageLayout from "@/components/layout/PageLayout";
|
|
4
|
+
import AppChart from "@/components/common/AppChart";
|
|
5
|
+
import { Button } from "@/components/ui/button";
|
|
6
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
import { getUserName } from "@/constants/constant";
|
|
9
|
+
import { formatDateTime } from "@/utils/formatDateTime";
|
|
10
|
+
import { CategoryBadge } from "@/features/components/ComponentsTable";
|
|
11
|
+
import { COMPONENT_CATEGORIES, COMPONENT_STATUSES, INITIAL_COMPONENTS } from "@/features/components/mockData";
|
|
12
|
+
|
|
13
|
+
const CUSTOMIZE_STEPS = [
|
|
14
|
+
{ title: "Set the app name and API URL", file: ".env", detail: "VITE_APP_NAME and VITE_BASE_URL" },
|
|
15
|
+
{
|
|
16
|
+
title: "Apply your brand colors",
|
|
17
|
+
file: "src/assets/css/index.css",
|
|
18
|
+
detail: "Edit --primary and --primary-hover in both the light and dark themes",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Add your API endpoints",
|
|
22
|
+
file: "src/api/api.services.js",
|
|
23
|
+
detail: "One function per endpoint, built on apiCall()",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: "Connect real authentication",
|
|
27
|
+
file: "src/pages/auth/LoginPage.jsx",
|
|
28
|
+
detail: "Use loginApi() here and registerApi() in SignupPage.jsx instead of the mocks",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: "Add pages and navigation",
|
|
32
|
+
file: "src/routes/AppRoutes.jsx",
|
|
33
|
+
detail: "Then add the link to navItems in SidebarLayout.jsx",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: "Remove the examples",
|
|
37
|
+
file: "src/features/",
|
|
38
|
+
detail: "Delete it along with the pages, routes and nav items that use it",
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const CHART_COLORS = {
|
|
43
|
+
primary: "#3B7BF5",
|
|
44
|
+
secondary: "#2563EB",
|
|
45
|
+
neutral: "#A3A3A3",
|
|
46
|
+
grid: "rgba(115, 115, 115, 0.15)",
|
|
47
|
+
tick: "#8A8A8A",
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const STATUS_COLORS = [CHART_COLORS.primary, CHART_COLORS.neutral];
|
|
51
|
+
|
|
52
|
+
const AXIS_OPTIONS = {
|
|
53
|
+
grid: { color: CHART_COLORS.grid },
|
|
54
|
+
border: { display: false },
|
|
55
|
+
ticks: { color: CHART_COLORS.tick, font: { size: 11 }, precision: 0 },
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const BAR_OPTIONS = {
|
|
59
|
+
plugins: { legend: { display: false } },
|
|
60
|
+
scales: { x: { ...AXIS_OPTIONS, grid: { display: false } }, y: { ...AXIS_OPTIONS, beginAtZero: true } },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const components = INITIAL_COMPONENTS;
|
|
64
|
+
const stableCount = components.filter((c) => c.status === "Stable").length;
|
|
65
|
+
const betaCount = components.filter((c) => c.status === "Beta").length;
|
|
66
|
+
const usedCategories = new Set(components.map((c) => c.category)).size;
|
|
67
|
+
const categoryCounts = COMPONENT_CATEGORIES.map((category) => components.filter((c) => c.category === category).length);
|
|
68
|
+
const statusCounts = COMPONENT_STATUSES.map((status) => components.filter((c) => c.status === status).length);
|
|
69
|
+
const recentlyUpdated = [...components].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)).slice(0, 5);
|
|
70
|
+
|
|
71
|
+
const STATS = [
|
|
72
|
+
{
|
|
73
|
+
label: "Catalog entries",
|
|
74
|
+
value: components.length,
|
|
75
|
+
hint: "Components, hooks and helpers",
|
|
76
|
+
icon: Boxes,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "Stable",
|
|
80
|
+
value: stableCount,
|
|
81
|
+
hint: `${Math.round((stableCount / components.length) * 100)}% ready for production`,
|
|
82
|
+
icon: CircleCheck,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: "Beta",
|
|
86
|
+
value: betaCount,
|
|
87
|
+
hint: "API may still change",
|
|
88
|
+
icon: FlaskConical,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: "Categories",
|
|
92
|
+
value: usedCategories,
|
|
93
|
+
hint: COMPONENT_CATEGORIES.join(", "),
|
|
94
|
+
icon: Layers,
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
const categoryData = {
|
|
99
|
+
labels: COMPONENT_CATEGORIES,
|
|
100
|
+
datasets: [
|
|
101
|
+
{
|
|
102
|
+
label: "Entries",
|
|
103
|
+
data: categoryCounts,
|
|
104
|
+
backgroundColor: CHART_COLORS.primary,
|
|
105
|
+
hoverBackgroundColor: CHART_COLORS.secondary,
|
|
106
|
+
borderRadius: 6,
|
|
107
|
+
maxBarThickness: 40,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const statusData = {
|
|
113
|
+
labels: COMPONENT_STATUSES,
|
|
114
|
+
datasets: [{ data: statusCounts, backgroundColor: STATUS_COLORS, borderWidth: 0 }],
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const StatCard = ({ stat }) => (
|
|
118
|
+
<Card>
|
|
119
|
+
<CardContent className="flex items-start justify-between gap-3">
|
|
120
|
+
<div className="min-w-0">
|
|
121
|
+
<p className="text-sm text-muted-foreground">{stat.label}</p>
|
|
122
|
+
<p className="mt-1 font-heading text-3xl font-bold tracking-tight">{stat.value}</p>
|
|
123
|
+
<p className="mt-1 truncate text-xs text-muted-foreground">{stat.hint}</p>
|
|
124
|
+
</div>
|
|
125
|
+
<span
|
|
126
|
+
className={cn("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground")}
|
|
127
|
+
>
|
|
128
|
+
<stat.icon className="h-5 w-5" />
|
|
129
|
+
</span>
|
|
130
|
+
</CardContent>
|
|
131
|
+
</Card>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const DashboardPage = () => {
|
|
135
|
+
return (
|
|
136
|
+
<PageLayout showSidebar variant="primary">
|
|
137
|
+
<div className="flex flex-col gap-4">
|
|
138
|
+
<div>
|
|
139
|
+
<h1 className="font-heading text-2xl font-bold tracking-tight">Welcome, {getUserName()}</h1>
|
|
140
|
+
<p className="text-sm text-muted-foreground">
|
|
141
|
+
An overview of what this template ships with, built with its own cards, charts and layout.
|
|
142
|
+
</p>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
|
|
146
|
+
{STATS.map((stat) => (
|
|
147
|
+
<StatCard key={stat.label} stat={stat} />
|
|
148
|
+
))}
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
|
|
152
|
+
<Card className="lg:col-span-2">
|
|
153
|
+
<CardHeader>
|
|
154
|
+
<CardTitle>Entries by category</CardTitle>
|
|
155
|
+
<CardDescription>How the template is split up · bar chart via AppChart</CardDescription>
|
|
156
|
+
</CardHeader>
|
|
157
|
+
<CardContent>
|
|
158
|
+
<AppChart type="bar" data={categoryData} options={BAR_OPTIONS} height={260} />
|
|
159
|
+
</CardContent>
|
|
160
|
+
</Card>
|
|
161
|
+
|
|
162
|
+
<Card>
|
|
163
|
+
<CardHeader>
|
|
164
|
+
<CardTitle>Stability</CardTitle>
|
|
165
|
+
<CardDescription>Stable and Beta entries · doughnut chart</CardDescription>
|
|
166
|
+
</CardHeader>
|
|
167
|
+
<CardContent className="flex flex-col gap-5">
|
|
168
|
+
<div className="relative">
|
|
169
|
+
<AppChart
|
|
170
|
+
type="doughnut"
|
|
171
|
+
data={statusData}
|
|
172
|
+
options={{ cutout: "72%", plugins: { legend: { display: false } } }}
|
|
173
|
+
height={170}
|
|
174
|
+
/>
|
|
175
|
+
<div className="pointer-events-none absolute inset-0 flex flex-col items-center justify-center">
|
|
176
|
+
<span className="font-heading text-2xl font-bold">{components.length}</span>
|
|
177
|
+
<span className="text-xs text-muted-foreground">entries</span>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
<ul className="space-y-2.5">
|
|
181
|
+
{COMPONENT_STATUSES.map((status, idx) => (
|
|
182
|
+
<li key={status} className="flex items-center justify-between text-sm">
|
|
183
|
+
<span className="flex items-center gap-2 text-muted-foreground">
|
|
184
|
+
<span className="h-2.5 w-2.5 rounded-full" style={{ backgroundColor: STATUS_COLORS[idx] }} />
|
|
185
|
+
{status}
|
|
186
|
+
</span>
|
|
187
|
+
<span className="font-medium">{statusCounts[idx]}</span>
|
|
188
|
+
</li>
|
|
189
|
+
))}
|
|
190
|
+
</ul>
|
|
191
|
+
</CardContent>
|
|
192
|
+
</Card>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
|
|
196
|
+
<Card className="lg:col-span-2">
|
|
197
|
+
<CardHeader className="flex flex-row items-center justify-between">
|
|
198
|
+
<div>
|
|
199
|
+
<CardTitle>Recently updated</CardTitle>
|
|
200
|
+
<CardDescription>The latest changes to the template</CardDescription>
|
|
201
|
+
</div>
|
|
202
|
+
<Button variant="ghost" size="sm" className="text-primary" render={<Link to="/components" />}>
|
|
203
|
+
View all
|
|
204
|
+
<ArrowRight />
|
|
205
|
+
</Button>
|
|
206
|
+
</CardHeader>
|
|
207
|
+
<CardContent>
|
|
208
|
+
<ul className="divide-y divide-border">
|
|
209
|
+
{recentlyUpdated.map((item) => (
|
|
210
|
+
<li key={item.id} className="flex items-center justify-between gap-3 py-3 first:pt-0 last:pb-0">
|
|
211
|
+
<div className="min-w-0">
|
|
212
|
+
<p className="truncate text-sm font-medium">{item.name}</p>
|
|
213
|
+
<p className="mt-0.5 truncate font-mono text-[11px] text-muted-foreground">{item.path}</p>
|
|
214
|
+
</div>
|
|
215
|
+
<div className="flex shrink-0 items-center gap-4">
|
|
216
|
+
<span className="hidden sm:inline-flex">
|
|
217
|
+
<CategoryBadge category={item.category} />
|
|
218
|
+
</span>
|
|
219
|
+
<span className="w-24 text-right text-xs text-muted-foreground">
|
|
220
|
+
{formatDateTime({ dateInput: item.updatedAt, type: "date" })}
|
|
221
|
+
</span>
|
|
222
|
+
</div>
|
|
223
|
+
</li>
|
|
224
|
+
))}
|
|
225
|
+
</ul>
|
|
226
|
+
</CardContent>
|
|
227
|
+
</Card>
|
|
228
|
+
|
|
229
|
+
<Card>
|
|
230
|
+
<CardHeader>
|
|
231
|
+
<CardTitle>Make it yours</CardTitle>
|
|
232
|
+
<CardDescription>Where to start customizing the template</CardDescription>
|
|
233
|
+
</CardHeader>
|
|
234
|
+
<CardContent>
|
|
235
|
+
<ol className="space-y-4">
|
|
236
|
+
{CUSTOMIZE_STEPS.map((step, idx) => (
|
|
237
|
+
<li key={step.title} className="flex gap-3">
|
|
238
|
+
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary">
|
|
239
|
+
{idx + 1}
|
|
240
|
+
</span>
|
|
241
|
+
<div className="min-w-0">
|
|
242
|
+
<p className="text-sm font-medium">{step.title}</p>
|
|
243
|
+
<p className="mt-1 inline-flex max-w-full items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground">
|
|
244
|
+
<FileCode2 className="h-3 w-3 shrink-0" />
|
|
245
|
+
<span className="truncate">{step.file}</span>
|
|
246
|
+
</p>
|
|
247
|
+
<p className="mt-1 text-xs text-muted-foreground">{step.detail}</p>
|
|
248
|
+
</div>
|
|
249
|
+
</li>
|
|
250
|
+
))}
|
|
251
|
+
</ol>
|
|
252
|
+
</CardContent>
|
|
253
|
+
</Card>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</PageLayout>
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export default DashboardPage;
|