@donotdev/ui 0.0.31 → 0.1.1
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/LICENSE.md +3 -3
- package/dist/{GoToDialog-CR4VOVXT.js → GoToDialog-RU5RP7S2.js} +1 -1
- package/dist/chunk-ETE4RC7M.js +1 -0
- package/dist/components/auth/AuthHeader.d.ts +8 -3
- package/dist/components/auth/AuthHeader.d.ts.map +1 -1
- package/dist/components/auth/AuthHeader.js +6 -6
- package/dist/components/auth/AuthMenu.d.ts +2 -2
- package/dist/components/auth/AuthMenu.js +1 -1
- package/dist/components/common/FeatureCard.d.ts +2 -0
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +1 -1
- package/dist/components/common/FeatureDisabled.d.ts +2 -1
- package/dist/components/common/FeatureDisabled.d.ts.map +1 -1
- package/dist/components/common/FeatureDisabled.js +2 -2
- package/dist/components/common/ProgressBar.d.ts +1 -1
- package/dist/components/common/ProgressBar.js +2 -2
- package/dist/components/common/RedirectOverlay.d.ts +1 -1
- package/dist/components/common/RedirectOverlay.js +2 -2
- package/dist/components/common/Skeleton.d.ts +7 -7
- package/dist/components/common/Skeleton.js +8 -8
- package/dist/components/common/TechBento.d.ts +1 -0
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/icon.d.ts +2 -1
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +2 -2
- package/dist/components/common/index.d.ts +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/cookie-consent/ConsentBanner.d.ts +1 -1
- package/dist/components/cookie-consent/ConsentBanner.js +2 -2
- package/dist/components/cookie-consent/CookieConsent.d.ts +1 -0
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/index.d.ts +1 -1
- package/dist/components/cookie-consent/index.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/layout/GameContainer.d.ts +1 -1
- package/dist/components/layout/GameContainer.js +2 -2
- package/dist/components/layout/GameFlow.d.ts +2 -2
- package/dist/components/layout/GameFlow.js +2 -2
- package/dist/components/layout/PageConfig.d.ts +25 -0
- package/dist/components/layout/PageConfig.d.ts.map +1 -0
- package/dist/components/layout/PageConfig.js +47 -0
- package/dist/components/layout/PageContainer.d.ts +1 -1
- package/dist/components/layout/PageContainer.js +2 -2
- package/dist/components/layout/components/Breadcrumbs.d.ts +3 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +2 -2
- package/dist/components/layout/components/DropdownNavigation.d.ts +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +2 -2
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts +2 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +2 -2
- package/dist/components/layout/components/Notifications.d.ts +4 -4
- package/dist/components/layout/components/Notifications.js +3 -3
- package/dist/components/layout/components/header/AppBranding.d.ts +3 -2
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +2 -2
- package/dist/components/layout/components/header/AppIcon.d.ts +2 -1
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +2 -2
- package/dist/components/layout/components/header/AppTitle.d.ts +2 -1
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.js +2 -2
- package/dist/components/layout/components/header/CacheSettings.d.ts +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +5 -5
- package/dist/components/layout/components/header/GameTitle.d.ts +2 -1
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/GameTitle.js +2 -2
- package/dist/components/layout/components/header/HeaderMenu.d.ts +2 -1
- package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderMenu.js +2 -2
- package/dist/components/layout/components/header/HeaderNavigation.d.ts +2 -1
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +2 -2
- package/dist/components/layout/components/header/SettingsMenu.d.ts +2 -1
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +2 -2
- package/dist/components/layout/components/header/ThemeToggle.d.ts +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +2 -2
- package/dist/components/layout/components/index.d.ts +1 -1
- package/dist/components/layout/components/index.js +1 -1
- package/dist/components/layout/index.d.ts +2 -1
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +2 -1
- package/dist/components/license/LicenseWatermark.d.ts +1 -1
- package/dist/components/license/LicenseWatermark.js +2 -2
- package/dist/components/license/watermarkData.js +1 -1
- package/dist/crud/components/CrudCardLink.d.ts +1 -1
- package/dist/crud/components/EntityCardList.d.ts +1 -1
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +33 -22
- package/dist/crud/components/EntityDisplayRenderer.d.ts +1 -1
- package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityDisplayRenderer.js +14 -13
- package/dist/crud/components/EntityFormRenderer.d.ts +1 -1
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +18 -20
- package/dist/crud/components/EntityList.d.ts +1 -1
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +41 -25
- package/dist/crud/components/EntityRecommendations.d.ts +2 -2
- package/dist/crud/components/EntityRecommendations.d.ts.map +1 -1
- package/dist/crud/components/EntityRecommendations.js +6 -6
- package/dist/crud/components/EntityWorkflow.js +1 -1
- package/dist/crud/components/Form.d.ts +10 -10
- package/dist/crud/components/Form.js +12 -12
- package/dist/crud/components/index.d.ts +1 -1
- package/dist/crud/components/index.js +1 -1
- package/dist/crud/crudImports.d.ts +2 -1
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +2 -1
- package/dist/crud/index.d.ts +1 -1
- package/dist/crud/index.js +1 -1
- package/dist/data/techLogos.d.ts +1 -1
- package/dist/data/techLogos.js +1 -1
- package/dist/dndev-next.css +374 -81
- package/dist/dndev.css +455 -80
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/internal/common/DnDevErrorBoundary.d.ts +2 -2
- package/dist/internal/common/DnDevErrorBoundary.js +2 -2
- package/dist/internal/common/ErrorFallback.d.ts +1 -1
- package/dist/internal/common/ErrorFallback.js +3 -3
- package/dist/internal/common/GlobalErrorFallback.d.ts +1 -1
- package/dist/internal/common/GlobalErrorFallback.js +2 -2
- package/dist/internal/common/RouteErrorFallback.d.ts +1 -1
- package/dist/internal/common/RouteErrorFallback.js +2 -2
- package/dist/internal/devtools/DebugTools.js +2 -2
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -1
- package/dist/internal/devtools/components/ConfigTab.js +1 -1
- package/dist/internal/devtools/components/CookieTab.js +1 -1
- package/dist/internal/devtools/components/DebugDialog.js +1 -1
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/DesignTab.js +7 -3
- package/dist/internal/devtools/components/LayoutReset.js +2 -2
- package/dist/internal/devtools/components/MaskedValue.js +1 -1
- package/dist/internal/devtools/components/StoresTab.js +1 -1
- package/dist/internal/devtools/components/index.d.ts +1 -1
- package/dist/internal/devtools/components/index.js +1 -1
- package/dist/internal/devtools/index.d.ts +1 -1
- package/dist/internal/devtools/index.js +1 -1
- package/dist/internal/devtools/types.d.ts +9 -9
- package/dist/internal/devtools/utils/envVarDiscovery.d.ts.map +1 -1
- package/dist/internal/devtools/utils/envVarDiscovery.js +5 -6
- package/dist/internal/devtools/utils/index.d.ts +1 -1
- package/dist/internal/devtools/utils/index.js +1 -1
- package/dist/internal/devtools/utils/maskSensitive.js +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.js +3 -1
- package/dist/internal/initializers/BaseStoresInitializer.d.ts +3 -3
- package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/BaseStoresInitializer.js +13 -4
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.js +2 -2
- package/dist/internal/initializers/ViteStoresInitializer.d.ts +1 -1
- package/dist/internal/initializers/ViteStoresInitializer.js +2 -2
- package/dist/internal/initializers/index.d.ts +1 -1
- package/dist/internal/initializers/index.js +1 -1
- package/dist/internal/layout/DnDevLayout.d.ts +2 -2
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +45 -18
- package/dist/internal/layout/components/AutoMetaTags.d.ts +4 -2
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +193 -57
- package/dist/internal/layout/components/FaviconHead.d.ts +1 -1
- package/dist/internal/layout/components/FaviconHead.js +2 -2
- package/dist/internal/layout/components/FontPreloadLinks.d.ts +1 -1
- package/dist/internal/layout/components/FontPreloadLinks.js +1 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts +3 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.js +47 -17
- package/dist/internal/layout/components/PWAUpdateNotification.d.ts +1 -1
- package/dist/internal/layout/components/PWAUpdateNotification.d.ts.map +1 -1
- package/dist/internal/layout/components/PWAUpdateNotification.js +17 -4
- package/dist/internal/layout/components/PerformanceHints.js +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.d.ts +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +2 -2
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +2 -2
- package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts +1 -1
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +2 -2
- package/dist/internal/layout/components/index.d.ts +1 -1
- package/dist/internal/layout/components/index.js +1 -1
- package/dist/internal/layout/config/defaults.js +1 -1
- package/dist/internal/layout/config/index.d.ts +1 -1
- package/dist/internal/layout/config/index.js +1 -1
- package/dist/internal/layout/config/presets/admin.d.ts +1 -1
- package/dist/internal/layout/config/presets/blog.d.ts +1 -1
- package/dist/internal/layout/config/presets/docs.js +1 -1
- package/dist/internal/layout/config/presets/game.js +1 -1
- package/dist/internal/layout/config/presets/index.d.ts +1 -1
- package/dist/internal/layout/config/presets/landing.js +1 -1
- package/dist/internal/layout/config/presets/moolti.js +1 -1
- package/dist/internal/layout/config/presets/plain.d.ts +2 -2
- package/dist/internal/layout/config/presets/plain.d.ts.map +1 -1
- package/dist/internal/layout/config/presets/plain.js +12 -1
- package/dist/internal/layout/renderers/index.d.ts +1 -1
- package/dist/internal/layout/renderers/index.js +1 -1
- package/dist/internal/layout/zones/DnDevFooter.d.ts +3 -1
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +6 -2
- package/dist/internal/layout/zones/DnDevHeader.d.ts +3 -1
- package/dist/internal/layout/zones/DnDevHeader.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevHeader.js +8 -3
- package/dist/internal/layout/zones/DnDevMergedBar.js +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.d.ts +3 -1
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +10 -4
- package/dist/internal/layout/zones/index.d.ts +1 -1
- package/dist/internal/layout/zones/index.js +1 -1
- package/dist/internal/providers/NavigationProvider.d.ts +1 -1
- package/dist/internal/providers/NavigationProvider.js +2 -2
- package/dist/internal/providers/SentryInitializer.d.ts +1 -1
- package/dist/internal/providers/SentryInitializer.js +2 -2
- package/dist/internal/providers/UIProviders.d.ts +1 -1
- package/dist/internal/providers/UIProviders.js +3 -3
- package/dist/internal/providers/index.d.ts +1 -1
- package/dist/internal/providers/index.js +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +1 -1
- package/dist/providers/NextJsAppProviders.d.ts +1 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +5 -3
- package/dist/providers/ViteAppProviders.d.ts +1 -1
- package/dist/providers/ViteAppProviders.js +2 -2
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/routing/404.d.ts +2 -2
- package/dist/routing/404.js +3 -3
- package/dist/routing/AuthGuard.d.ts +14 -29
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +27 -72
- package/dist/routing/AuthGuardFallback.d.ts +1 -1
- package/dist/routing/AuthGuardFallback.js +2 -2
- package/dist/routing/AuthReturnTo.d.ts +13 -0
- package/dist/routing/AuthReturnTo.d.ts.map +1 -0
- package/dist/routing/AuthReturnTo.js +61 -0
- package/dist/routing/DnDevNavigationMenu.d.ts +2 -1
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +2 -2
- package/dist/routing/GoTo.d.ts +1 -0
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +1 -1
- package/dist/routing/GoToDialog.js +1 -1
- package/dist/routing/GoToInput.js +1 -1
- package/dist/routing/GoToWrapper.d.ts +1 -1
- package/dist/routing/GoToWrapper.js +2 -2
- package/dist/routing/Link.d.ts +2 -2
- package/dist/routing/Link.js +2 -2
- package/dist/routing/NavigationItem.d.ts +1 -1
- package/dist/routing/NavigationItem.js +2 -2
- package/dist/routing/hooks/hooks.next.d.ts +1 -1
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.d.ts +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/index.d.ts +1 -1
- package/dist/routing/hooks/index.js +1 -1
- package/dist/routing/hooks/types.d.ts +1 -1
- package/dist/routing/hooks/useLocation.next.js +1 -1
- package/dist/routing/hooks/useLocation.vite.js +1 -1
- package/dist/routing/hooks/useNavigate.next.d.ts +8 -0
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +59 -9
- package/dist/routing/hooks/useNavigate.vite.d.ts +8 -0
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +65 -15
- package/dist/routing/hooks/useQueryParams.next.js +1 -1
- package/dist/routing/hooks/useQueryParams.vite.js +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.d.ts +2 -0
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +12 -28
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts +2 -0
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +12 -28
- package/dist/routing/hooks/useRouteParam.next.js +1 -1
- package/dist/routing/hooks/useRouteParam.vite.js +1 -1
- package/dist/routing/index.d.ts +2 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -1
- package/dist/routing/useGoTo.js +1 -1
- package/dist/routing/useNavigation.d.ts +2 -2
- package/dist/routing/useNavigation.js +3 -3
- package/dist/routing/useRouteDiscovery.d.ts +7 -7
- package/dist/routing/useRouteDiscovery.js +6 -6
- package/dist/styles/index.css +455 -80
- package/dist/styles/index.d.ts +1 -1
- package/dist/styles/index.js +1 -1
- package/dist/styles/layoutConstants.d.ts +6 -6
- package/dist/styles/layoutConstants.js +5 -5
- package/dist/symbol-index.json +1 -0
- package/dist/utils/assetResolver.d.ts +5 -5
- package/dist/utils/assetResolver.js +4 -4
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/sanitizeSvg.d.ts +4 -0
- package/dist/utils/sanitizeSvg.d.ts.map +1 -1
- package/dist/utils/sanitizeSvg.js +5 -1
- package/dist/utils/tList.js +1 -1
- package/dist/utils/useAISafe.d.ts +28 -0
- package/dist/utils/useAISafe.d.ts.map +1 -0
- package/dist/utils/useAISafe.js +53 -0
- package/dist/utils/useAuthSafe.d.ts +39 -0
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +6 -1
- package/dist/utils/useAuthVisibility.d.ts +1 -0
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +1 -1
- package/dist/utils/useBillingVisibility.d.ts +1 -0
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +1 -1
- package/dist/utils/useCrudSafe.js +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -1
- package/dist/utils/useOAuthSafe.d.ts +1 -1
- package/dist/utils/useSeo.d.ts +121 -0
- package/dist/utils/useSeo.d.ts.map +1 -0
- package/dist/utils/useSeo.js +114 -0
- package/dist/utils/useStripeBillingSafe.js +1 -1
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +15 -5
- package/dist/vite-routing/RootLayout.d.ts +1 -1
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +11 -9
- package/dist/vite-routing/index.d.ts +1 -1
- package/dist/vite-routing/index.js +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/guidelines/COMPONENTS.md +136 -0
- package/guidelines/GOTCHAS.md +66 -0
- package/guidelines/LAYOUTS.md +310 -0
- package/guidelines/PAGES.md +205 -0
- package/guidelines/ROUTING.md +499 -0
- package/guidelines/SEO.md +275 -0
- package/package.json +12 -7
- package/dist/chunk-XHGRMKOY.js +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Gotchas: @donotdev/ui
|
|
2
|
+
|
|
3
|
+
Common mistakes related to routing, styling, layouts, and UI components.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Routing [Phase 1, 3]
|
|
8
|
+
|
|
9
|
+
**Never import from `react-router-dom` - use framework routing.**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// WRONG - breaks framework features
|
|
13
|
+
import { Link, useNavigate, useParams } from 'react-router-dom';
|
|
14
|
+
|
|
15
|
+
// CORRECT
|
|
16
|
+
import { Link, useNavigate, useParams } from '@donotdev/ui';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Routes are auto-discovered** from `src/pages/*Page.tsx` with `pageMeta`. Don't use `<Routes>`, `<Route>`, or manual `<Outlet />`.
|
|
20
|
+
|
|
21
|
+
**Use `useRouteParam('id')` for typed route params** - not `useParams()` from react-router-dom.
|
|
22
|
+
|
|
23
|
+
**Navigation is auto-built.** Use `<DnDevNavigationMenu>` or `useNavigationItems()`. Don't build nav manually - you lose auth filtering and route discovery.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Styling [Phase 3, 4]
|
|
28
|
+
|
|
29
|
+
**No inline `fontSize` or `font-size` - use `Text` level prop.**
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// WRONG
|
|
33
|
+
<Text style={{ fontSize: '18px' }}>Title</Text>
|
|
34
|
+
|
|
35
|
+
// CORRECT
|
|
36
|
+
<Text level="h2">Title</Text>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Levels: `h1`, `h2`, `h3`, `h4`, `body`, `small`, `caption`. Limit to 2-3 levels per page.
|
|
40
|
+
|
|
41
|
+
**RTL: Always use `start`/`end` - never `left`/`right`.**
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
/* WRONG - breaks RTL */
|
|
45
|
+
text-align: left;
|
|
46
|
+
|
|
47
|
+
/* CORRECT - works in both LTR and RTL */
|
|
48
|
+
text-align: start;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Same for inline styles: `textAlign: 'start'` not `textAlign: 'left'`. Same for data attributes: `data-text-align="start|center|end"`.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Components [Phase 3]
|
|
56
|
+
|
|
57
|
+
**Always `lookup_symbol` before using any `@donotdev` component.** Never guess props.
|
|
58
|
+
|
|
59
|
+
Common wrong props:
|
|
60
|
+
- `Button`: no `size`, `tone`, `gap` - use `variant`, `display`
|
|
61
|
+
- `Text`: no `size`, `tone`, `color` - use `level`, `variant`
|
|
62
|
+
- `Stack`: no `spacing`, `size` - use `gap`
|
|
63
|
+
- `Card`: no `padding`, `margin`, `size` - use `title`, `subtitle`, `content`, `footer`
|
|
64
|
+
- `Grid`: no `columns` - use `cols`
|
|
65
|
+
|
|
66
|
+
**If you can't do it with framework components:** Stop. Tell the user what's missing. Don't invent custom workarounds.
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Layouts
|
|
2
|
+
|
|
3
|
+
**Choose preset in `config/app.ts`. Framework handles header, sidebar, footer, auth, themes, languages.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Standard Use
|
|
8
|
+
|
|
9
|
+
**Choose preset:**
|
|
10
|
+
```typescript
|
|
11
|
+
// config/app.ts
|
|
12
|
+
export const appConfig: AppConfig = {
|
|
13
|
+
preset: 'landing', // landing | admin | moolti | docs | blog | game | plain
|
|
14
|
+
};
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**7 presets:** `landing` (marketing), `admin` (dashboards), `moolti` (SaaS), `docs` (documentation), `blog` (content), `game` (mobile), `plain` (minimal).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Preset Capabilities
|
|
22
|
+
|
|
23
|
+
**The `docs` preset AUTOMATICALLY generates sidebar navigation from your `src/pages` files. You do not need to configure a sidebar manually.**
|
|
24
|
+
|
|
25
|
+
All presets automatically include these components when applicable:
|
|
26
|
+
|
|
27
|
+
* **LanguageSelector** - Automatically shown if more than 1 language is configured
|
|
28
|
+
* **ThemeToggle** - Automatically shown if more than 1 theme is available
|
|
29
|
+
* **AuthMenu** - Automatically shown if auth is configured in `.env` (Firebase keys present)
|
|
30
|
+
* **Navigation Menu** - Automatically generated from `src/pages/*Page.tsx` files for sidebars
|
|
31
|
+
* **GoTo Component** - Command palette (Cmd+K) for quick navigation - always available
|
|
32
|
+
* **Footer** - Automatic footer with copyright and legal links
|
|
33
|
+
* **LegalLinks + Copyright** - Automatically included in footer from `config/legal.ts`
|
|
34
|
+
|
|
35
|
+
**You don't need to add these manually - the framework handles them based on your configuration.**
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Per-Route Layout Switching
|
|
40
|
+
|
|
41
|
+
**Override the app preset on a per-page basis via `PageMeta.preset`:**
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
// src/pages/DashboardPage.tsx
|
|
45
|
+
import type { PageMeta } from '@donotdev/core';
|
|
46
|
+
|
|
47
|
+
export const meta: PageMeta = {
|
|
48
|
+
preset: 'admin', // This route uses admin layout (sidebar, compact density)
|
|
49
|
+
auth: true,
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- If `preset` is set - that route uses the specified layout
|
|
54
|
+
- If `preset` is absent - the app's `appConfig.preset` is used
|
|
55
|
+
- The override is **transient** - navigating away restores the next route's preset or the app default
|
|
56
|
+
- No localStorage pollution - route presets are not persisted
|
|
57
|
+
|
|
58
|
+
**Common pattern (SaaS app):**
|
|
59
|
+
| Route | Preset | Purpose |
|
|
60
|
+
|-------|--------|---------|
|
|
61
|
+
| `/` | (app default: `landing`) | Marketing landing page |
|
|
62
|
+
| `/pricing` | (app default: `landing`) | Pricing page |
|
|
63
|
+
| `/dashboard` | `admin` | Dashboard with sidebar |
|
|
64
|
+
| `/products` | `admin` | CRUD with sidebar |
|
|
65
|
+
| `/changelog` | `docs` | Documentation layout |
|
|
66
|
+
|
|
67
|
+
**Reference implementation:** See `packages/cli/templates/app-demo/` for a working example of per-route switching.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Custom Presets
|
|
72
|
+
|
|
73
|
+
**Define your own presets with the same `PresetConfig` shape as built-ins.**
|
|
74
|
+
|
|
75
|
+
`config/app.ts` is strings-only (no React, no JSX). Custom presets with components go in `App.tsx`.
|
|
76
|
+
|
|
77
|
+
### Zone ownership: slots vs functions
|
|
78
|
+
|
|
79
|
+
Each zone (header, sidebar, footer) supports two config modes:
|
|
80
|
+
|
|
81
|
+
| Config shape | What it means | Framework provides |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| **Object** (slots) | "I want your layout, my content" | Structure + behavior + visual polish |
|
|
84
|
+
| **Function** | "I own this zone" | Structure + behavior only, no visual polish |
|
|
85
|
+
| **`null`** | "Hide it" | Nothing |
|
|
86
|
+
|
|
87
|
+
**Slots mode** (object) - fill framework slots, get framework styling (background, border, padding):
|
|
88
|
+
```tsx
|
|
89
|
+
sidebar: {
|
|
90
|
+
top: () => <MyBranding />,
|
|
91
|
+
content: () => <MyNav />,
|
|
92
|
+
bottom: () => <MyProfile />,
|
|
93
|
+
defaultWidth: 280,
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Custom mode** (function) - own the zone visuals, framework provides structural behavior (resize, sticky, grid placement):
|
|
98
|
+
```tsx
|
|
99
|
+
sidebar: () => <MyFullSidebar />,
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
In custom mode:
|
|
103
|
+
- **Sidebar** gets resize handle, keyboard nav, collapse for free. No framework background/border.
|
|
104
|
+
- **Header** gets grid-area, height, sticky, z-index. No framework background/border/padding.
|
|
105
|
+
- **Footer** gets grid-area, z-index, grid-column span. No framework background/border/min-height/padding.
|
|
106
|
+
|
|
107
|
+
**Your component must NOT render the semantic wrapper** (`<aside>`, `<header>`, `<footer>`) - the framework handles that. Render a `<div>` or fragment as your root.
|
|
108
|
+
|
|
109
|
+
### Example: custom preset with full zone ownership
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// App.tsx
|
|
113
|
+
import type { LayoutPreset, PresetConfig } from '@donotdev/core';
|
|
114
|
+
import { ViteAppProviders } from '@donotdev/ui/vite';
|
|
115
|
+
|
|
116
|
+
import { MyGameHud } from './components/MyGameHud';
|
|
117
|
+
import { MyToolPanel } from './components/MyToolPanel';
|
|
118
|
+
import { appConfig } from './config/app';
|
|
119
|
+
|
|
120
|
+
const customPresets: Record<string, PresetConfig> = {
|
|
121
|
+
'my-editor': {
|
|
122
|
+
name: 'my-editor' as LayoutPreset,
|
|
123
|
+
sidebar: () => <MyToolPanel />, // Custom visuals, resize for free
|
|
124
|
+
footer: () => <MyGameHud />, // Custom visuals, fixed at bottom
|
|
125
|
+
footerMode: 'fixed', // Stays pinned on mobile too
|
|
126
|
+
mobile: {
|
|
127
|
+
mergedBar: {
|
|
128
|
+
position: 'top',
|
|
129
|
+
height: '62px',
|
|
130
|
+
content: () => <MyToolPanel />,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export function App() {
|
|
137
|
+
return (
|
|
138
|
+
<ViteAppProviders
|
|
139
|
+
config={{ ...appConfig, customPresets }}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Example: custom preset with slot overrides (framework polish)
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
const customPresets: Record<string, PresetConfig> = {
|
|
149
|
+
'my-docs': {
|
|
150
|
+
name: 'my-docs' as LayoutPreset,
|
|
151
|
+
sidebar: {
|
|
152
|
+
content: () => <MyDocNav />, // Custom content, framework styling
|
|
153
|
+
defaultWidth: 300,
|
|
154
|
+
minWidth: 200,
|
|
155
|
+
maxWidth: 400,
|
|
156
|
+
},
|
|
157
|
+
footer: null, // No footer
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### CSS variables for custom presets
|
|
163
|
+
|
|
164
|
+
**Add CSS variables in `src/themes.css`:**
|
|
165
|
+
```css
|
|
166
|
+
[data-layout='my-editor'] {
|
|
167
|
+
--header-height: 0px;
|
|
168
|
+
--sidebar-width: 280px;
|
|
169
|
+
--custom-sidebar-width: 286px; /* content + 6px resize handle */
|
|
170
|
+
|
|
171
|
+
header[role='banner'] { display: none; }
|
|
172
|
+
|
|
173
|
+
@media (width <= 1023px) {
|
|
174
|
+
--sidebar-width: 0px;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Use on a page:**
|
|
180
|
+
```tsx
|
|
181
|
+
export const meta: PageMeta = {
|
|
182
|
+
preset: 'my-editor',
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**How it works:**
|
|
187
|
+
1. `customPresets` merged into config in `App.tsx` - flows through `AppConfigProvider`
|
|
188
|
+
2. Page sets `preset: 'my-editor'` - store accepts any string
|
|
189
|
+
3. `DnDevLayout` looks up `'my-editor'` in merged registry (custom overrides built-in)
|
|
190
|
+
4. Zones render from your `PresetConfig` - function zones get `data-custom` attribute, slots don't
|
|
191
|
+
5. `data-layout="my-editor"` on `<html>` - your CSS variables activate
|
|
192
|
+
6. Mobile: mergedBar shows automatically, header hidden via `data-has-mergedbar`
|
|
193
|
+
|
|
194
|
+
**Unknown presets without a custom config fall back to `landing`.**
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Advanced: Slot Overrides
|
|
199
|
+
|
|
200
|
+
**Customize zones (framework polish applies):**
|
|
201
|
+
```tsx
|
|
202
|
+
<ViteAppProviders
|
|
203
|
+
config={appConfig}
|
|
204
|
+
layout={{
|
|
205
|
+
header: {
|
|
206
|
+
start: () => <CustomLogo />, // Override start zone
|
|
207
|
+
center: () => <SearchBar />, // Override center zone
|
|
208
|
+
end: () => <UserMenu />, // Override end zone
|
|
209
|
+
},
|
|
210
|
+
sidebar: {
|
|
211
|
+
top: () => <Branding />, // Override top zone
|
|
212
|
+
content: () => <CustomNav />, // Override content zone
|
|
213
|
+
bottom: () => <UserProfile />, // Override bottom zone
|
|
214
|
+
},
|
|
215
|
+
footer: () => <CustomFooter />, // Replace entire footer (custom mode, no framework polish)
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Hide zones:**
|
|
221
|
+
```tsx
|
|
222
|
+
layout={{
|
|
223
|
+
header: {
|
|
224
|
+
center: () => null, // Hide center zone
|
|
225
|
+
},
|
|
226
|
+
footer: () => null, // Hide footer
|
|
227
|
+
}}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Available slots:** `header.start/center/end`, `sidebar.top/content/bottom`, `footer`, `mergedbar` (mobile nav).
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Advanced: Footer Mode
|
|
235
|
+
|
|
236
|
+
**Control footer scroll behavior:**
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
// Default: footer scrolls with content on mobile, fixed on desktop
|
|
240
|
+
// No footerMode needed - this is the default for all built-in presets
|
|
241
|
+
|
|
242
|
+
// Fixed on all breakpoints (footer stays pinned at bottom, even on mobile):
|
|
243
|
+
footerMode: 'fixed',
|
|
244
|
+
|
|
245
|
+
// Scroll on all breakpoints (footer scrolls with content):
|
|
246
|
+
footerMode: 'scroll',
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Set `footerMode` in your preset config or in the `layout` prop:
|
|
250
|
+
```tsx
|
|
251
|
+
<ViteAppProviders
|
|
252
|
+
config={appConfig}
|
|
253
|
+
layout={{ footerMode: 'fixed' }}
|
|
254
|
+
/>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Advanced: CSS Variable Overrides
|
|
260
|
+
|
|
261
|
+
**Override dimensions in `src/themes.css`:**
|
|
262
|
+
```css
|
|
263
|
+
:root {
|
|
264
|
+
--header-height: 96px;
|
|
265
|
+
--sidebar-width: 320px;
|
|
266
|
+
--main-max-width: 1480px;
|
|
267
|
+
--footer-height: 64px;
|
|
268
|
+
--section-gap: 2rem;
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Framework auto-computes:** Spacing, typography, responsive breakpoints.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Advanced: Density System
|
|
277
|
+
|
|
278
|
+
**Global density:**
|
|
279
|
+
```tsx
|
|
280
|
+
layout={{
|
|
281
|
+
density: 'compact', // compact | standard | expressive
|
|
282
|
+
}}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Per-page density:**
|
|
286
|
+
```tsx
|
|
287
|
+
<PageContainer density="expressive">
|
|
288
|
+
<HeroSection title="Hero" />
|
|
289
|
+
</PageContainer>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Three densities:** `compact` (1.2x), `standard` (1.25x), `expressive` (1.333x).
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Advanced: Runtime Preset Changes
|
|
297
|
+
|
|
298
|
+
**Change preset programmatically:**
|
|
299
|
+
```tsx
|
|
300
|
+
import { useLayout } from '@donotdev/core';
|
|
301
|
+
|
|
302
|
+
const setLayoutPreset = useLayout('setLayoutPreset');
|
|
303
|
+
setLayoutPreset('plain'); // Switch to plain layout
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Pre-configured:** All presets handle auth, themes, languages automatically.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
**Choose preset, get layout. Framework handles the rest.**
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Pages & Routing
|
|
2
|
+
|
|
3
|
+
**Drop `*Page.tsx` files. Routes auto-discovered, navigation auto-generated, sitemap auto-built.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## File Routing Rule
|
|
8
|
+
|
|
9
|
+
**CRITICAL: Only files ending in `Page.tsx` inside `src/pages` become routes.**
|
|
10
|
+
|
|
11
|
+
Files must be named `*Page.tsx` (e.g., `HomePage.tsx`, `AboutPage.tsx`, `BlogPostPage.tsx`). Files without the `Page.tsx` suffix are ignored by the routing system.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Standard Use
|
|
16
|
+
|
|
17
|
+
**Pattern:** `src/pages/**/*Page.tsx` - routes
|
|
18
|
+
|
|
19
|
+
**Basic page structure:**
|
|
20
|
+
```tsx
|
|
21
|
+
// src/pages/AboutPage.tsx
|
|
22
|
+
import { PageContainer } from '@donotdev/ui';
|
|
23
|
+
|
|
24
|
+
export const NAMESPACE = 'about';
|
|
25
|
+
|
|
26
|
+
export const meta: PageMeta = {
|
|
27
|
+
namespace: NAMESPACE,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default function AboutPage() {
|
|
31
|
+
return <PageContainer><h1>About</h1></PageContainer>;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Cookie-cutter pattern (Landing page):**
|
|
36
|
+
```tsx
|
|
37
|
+
import { PageContainer } from '@donotdev/ui';
|
|
38
|
+
import { HeroSection, Section, Card, CallToAction } from '@donotdev/components';
|
|
39
|
+
|
|
40
|
+
export default function HomePage() {
|
|
41
|
+
return (
|
|
42
|
+
<PageContainer>
|
|
43
|
+
<HeroSection title="Welcome" subtitle="Build fast" variant="primary" />
|
|
44
|
+
<Section title="Features" gridCols={3}>
|
|
45
|
+
<Card title="Fast" />
|
|
46
|
+
<Card title="Simple" />
|
|
47
|
+
<Card title="Powerful" />
|
|
48
|
+
</Section>
|
|
49
|
+
<CallToAction title="Get Started" primaryAction={<Button>Sign Up</Button>} />
|
|
50
|
+
</PageContainer>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Drop files, get routes. No config needed.**
|
|
56
|
+
|
|
57
|
+
**Component reference:** See the `@donotdev/components` guidelines for atomic components, and the COMPONENTS guideline for layout components.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Advanced: All PageMeta Props
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
export const meta: PageMeta = {
|
|
65
|
+
// Translation/SEO namespace
|
|
66
|
+
namespace: NAMESPACE,
|
|
67
|
+
|
|
68
|
+
// Route configuration
|
|
69
|
+
route: '/custom-url', // Override auto-generated path
|
|
70
|
+
route: { params: ['slug'] }, // Dynamic: /blog/:slug
|
|
71
|
+
|
|
72
|
+
// Page title (optional - auto-extracted from filename)
|
|
73
|
+
title: 'Custom Title',
|
|
74
|
+
|
|
75
|
+
// Navigation icon (lucide-react JSX only)
|
|
76
|
+
icon: <Rocket />, // Menu icon (default: Link)
|
|
77
|
+
|
|
78
|
+
// Hide from navigation menu
|
|
79
|
+
hideFromMenu: false, // Default: false (shows in nav)
|
|
80
|
+
|
|
81
|
+
// Layout preset override (per-route)
|
|
82
|
+
preset: 'admin', // Override app default for this route
|
|
83
|
+
|
|
84
|
+
// Authentication
|
|
85
|
+
auth: true, // Simple: auth required
|
|
86
|
+
auth: { required: true }, // Explicit: auth required
|
|
87
|
+
auth: { required: true, role: 'admin' }, // Role-based access
|
|
88
|
+
auth: { required: true, tier: 'pro' }, // Tier-based access
|
|
89
|
+
auth: {
|
|
90
|
+
required: true,
|
|
91
|
+
validate: (role, tier) => role === 'admin' && tier === 'pro'
|
|
92
|
+
}, // Custom validation
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Reference implementation:** The demo app (`packages/cli/templates/app-demo/`) shows all these patterns working together - landing, admin, docs presets, auth, showcase, CRUD, legal pages.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Advanced: Dynamic Routes & Navigation
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
// Dynamic route
|
|
104
|
+
export const meta: PageMeta = {
|
|
105
|
+
namespace: 'blog',
|
|
106
|
+
route: { params: ['slug'] }, // /blog/:slug
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default function BlogPostPage() {
|
|
110
|
+
const { slug } = useParams<{ slug: string }>();
|
|
111
|
+
return <PageContainer><h1>{slug}</h1></PageContainer>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Manual navigation
|
|
115
|
+
import { useNavigate, Link } from '@donotdev/ui';
|
|
116
|
+
const navigate = useNavigate();
|
|
117
|
+
navigate('/about');
|
|
118
|
+
<Link path="/about">About</Link>
|
|
119
|
+
|
|
120
|
+
// Card with navigation (supports middle-click)
|
|
121
|
+
import { Card } from '@donotdev/components';
|
|
122
|
+
import { Link } from '@donotdev/ui';
|
|
123
|
+
|
|
124
|
+
<Link
|
|
125
|
+
path="/about"
|
|
126
|
+
style={{ display: 'block', textDecoration: 'none', height: '100%' }}
|
|
127
|
+
aria-label="Learn more about About"
|
|
128
|
+
>
|
|
129
|
+
<Card title="About" subtitle="Learn more" />
|
|
130
|
+
</Link>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Navigation patterns:**
|
|
134
|
+
- **Link component:** Use for text links, buttons, or wrapping other components
|
|
135
|
+
- **Card navigation:** Wrap Card in Link for clickable cards with middle-click support
|
|
136
|
+
- **onClick only:** Use `onClick={() => navigate()}` for actions that don't need middle-click
|
|
137
|
+
|
|
138
|
+
**Pre-configured:** Navigation menu auto-generated, sitemap auto-built (if `generateSitemap: true`).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Import Convention
|
|
145
|
+
|
|
146
|
+
**Always import from `@donotdev/<package>` top-level.** Never use sub-paths.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { PageContainer, Link, useNavigate } from '@donotdev/ui';
|
|
150
|
+
import { Card, Button, Input } from '@donotdev/components';
|
|
151
|
+
import { useCrud } from '@donotdev/crud';
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Sub-path exceptions** (server, config, and provider-specific):
|
|
155
|
+
- **Server:** `@donotdev/core/server`, `@donotdev/firebase/server`, `@donotdev/security/server`
|
|
156
|
+
- **Config:** `@donotdev/core/vite`, `@donotdev/core/next`, `@donotdev/core/functions`
|
|
157
|
+
- **Functions:** `@donotdev/functions/firebase`, `@donotdev/functions/vercel`, `@donotdev/functions/supabase`
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## SaaS App Pattern
|
|
162
|
+
|
|
163
|
+
For SaaS apps, the standard page structure is:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
src/pages/
|
|
167
|
+
HomePage.tsx -> / -> No auth. Login form OR landing page.
|
|
168
|
+
Redirects to /dashboard when authenticated.
|
|
169
|
+
DashboardPage.tsx -> /dashboard -> auth: true. Main landing for logged-in users.
|
|
170
|
+
SettingsPage.tsx -> /settings -> auth: true.
|
|
171
|
+
...
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**HomePage is never auth-guarded.** It's the entry point for unauthenticated users. Do NOT create a separate `LoginPage` - HomePage IS the login.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
// src/pages/HomePage.tsx - SaaS pattern
|
|
178
|
+
import { useAuthSafe, useNavigate, PageContainer } from '@donotdev/ui';
|
|
179
|
+
import { LoginForm } from '@donotdev/templates';
|
|
180
|
+
|
|
181
|
+
export const meta: PageMeta = {
|
|
182
|
+
namespace: 'home',
|
|
183
|
+
// No auth - this is the public entry point
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export default function HomePage() {
|
|
187
|
+
const user = useAuthSafe('user');
|
|
188
|
+
const navigate = useNavigate();
|
|
189
|
+
|
|
190
|
+
// Redirect authenticated users to dashboard
|
|
191
|
+
if (user) { navigate('/dashboard'); return null; }
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<PageContainer>
|
|
195
|
+
<LoginForm onSuccess={() => navigate('/dashboard')} />
|
|
196
|
+
</PageContainer>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
> **Why `useAuthSafe` instead of `useAuth`?** HomePage is public - it renders before auth is guaranteed to be initialized. `useAuthSafe` (from `@donotdev/ui`) gracefully degrades if `@donotdev/auth` isn't installed or still initializing. `useAuth` (from `@donotdev/auth`) throws if auth isn't available. Use `useAuthSafe` on any page without `auth: true` in its meta.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
**Drop files, get routes. Framework handles the rest.**
|