From 970092fccb8b4c5eea28bb6e6eae05b295195a16 Mon Sep 17 00:00:00 2001 From: Hyko Date: Fri, 24 Apr 2026 20:27:30 -0400 Subject: [PATCH] feat(admin): add devkit developer tools section - add `ZEN_DEVKIT` env variable to enable/disable devkit - add `isDevkitEnabled()` utility and export it from public api - register devkit nav section and items conditionally when devkit is enabled - add devkit route handling in admin page client and server - add DevkitPage, ComponentsPage, and IconsPage client components --- .env.example | 5 +- src/features/admin/AdminPage.client.js | 6 +- src/features/admin/AdminPage.server.js | 3 + .../admin/devkit/ComponentsPage.client.js | 173 ++++++++++++++++++ .../admin/devkit/DevkitPage.client.js | 23 +++ src/features/admin/devkit/IconsPage.client.js | 73 ++++++++ src/features/admin/navigation.js | 7 + src/index.js | 2 +- src/shared/lib/appConfig.js | 4 + 9 files changed, 293 insertions(+), 3 deletions(-) create mode 100644 src/features/admin/devkit/ComponentsPage.client.js create mode 100644 src/features/admin/devkit/DevkitPage.client.js create mode 100644 src/features/admin/devkit/IconsPage.client.js diff --git a/.env.example b/.env.example index 896fa60..bf254c3 100644 --- a/.env.example +++ b/.env.example @@ -49,4 +49,7 @@ ZEN_PUBLIC_LOGO_BLACK= ZEN_PUBLIC_LOGO_URL= # OTHERS -NEXT_TELEMETRY_DISABLED=1 \ No newline at end of file +NEXT_TELEMETRY_DISABLED=1 + +# DEVKIT (developer tools) +ZEN_DEVKIT=false \ No newline at end of file diff --git a/src/features/admin/AdminPage.client.js b/src/features/admin/AdminPage.client.js index 388283b..260a05c 100644 --- a/src/features/admin/AdminPage.client.js +++ b/src/features/admin/AdminPage.client.js @@ -8,8 +8,9 @@ import './pages/ProfilePage.client.js'; import './pages/SettingsPage.client.js'; import './pages/ConfirmEmailChangePage.client.js'; import './widgets/index.client.js'; +import './devkit/DevkitPage.client.js'; -export default function AdminPageClient({ params, user, widgetData, appConfig }) { +export default function AdminPageClient({ params, user, widgetData, appConfig, devkitEnabled }) { const parts = params?.admin || []; const [first] = parts; @@ -25,5 +26,8 @@ export default function AdminPageClient({ params, user, widgetData, appConfig }) if (slug === 'settings') { return ; } + if (slug === 'devkit') { + return ; + } return ; } diff --git a/src/features/admin/AdminPage.server.js b/src/features/admin/AdminPage.server.js index ab77ac0..f019332 100644 --- a/src/features/admin/AdminPage.server.js +++ b/src/features/admin/AdminPage.server.js @@ -2,12 +2,14 @@ import AdminPageClient from './AdminPage.client.js'; import { protectAdmin } from './protect.js'; import { collectWidgetData } from './registry.js'; import { getAppConfig, getPublicBaseUrl } from '@zen/core'; +import { isDevkitEnabled } from '../../shared/lib/appConfig.js'; export default async function AdminPage({ params }) { const resolvedParams = await params; const session = await protectAdmin(); const widgetData = await collectWidgetData(); const appConfig = { ...getAppConfig(), siteUrl: getPublicBaseUrl() }; + const devkitEnabled = isDevkitEnabled(); return ( ); } diff --git a/src/features/admin/devkit/ComponentsPage.client.js b/src/features/admin/devkit/ComponentsPage.client.js new file mode 100644 index 0000000..abecb14 --- /dev/null +++ b/src/features/admin/devkit/ComponentsPage.client.js @@ -0,0 +1,173 @@ +'use client'; + +import { + Button, + Card, + Badge, + StatusBadge, + Input, + Select, + Textarea, + Switch, + StatCard, + Loading, +} from '@zen/core/shared/components'; +import { UserCircle02Icon } from '@zen/core/shared/icons'; +import AdminHeader from '../components/AdminHeader.js'; + +function PreviewBlock({ title, children }) { + return ( +
+

{title}

+
+ {children} +
+
+ ); +} + +export default function ComponentsPage() { + return ( +
+ + + + + + + + + + + + + + + + + + + + + + + + + Default + Primary + Success + Warning + Danger + Info + Purple + Pink + Orange + + + + + + + + + + + + + + {['default', 'elevated', 'outline', 'success', 'info', 'warning', 'danger'].map(v => ( + + {v} + + ))} + + + + + + + + + +
+ {}} /> + {}} /> + {}} /> + {}} /> + {}} /> +
+
+ + +
+ {}} + /> +