@powerhousedao/connect 6.2.3-dev.10 → 6.2.3-dev.101
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/README.md +29 -1
- package/dist/{AddDriveModal-xAw48kdl.js → AddDriveModal-zMepHdWt.js} +44 -18
- package/dist/AddDriveModal-zMepHdWt.js.map +1 -0
- package/dist/{ClearStorageModal-BHLFpni1.js → ClearStorageModal-DLt7BCd2.js} +11 -13
- package/dist/ClearStorageModal-DLt7BCd2.js.map +1 -0
- package/dist/{ConfirmDocumentUpgradeModal-FUOhZsk7.js → ConfirmDocumentUpgradeModal-CoixS60F.js} +9 -8
- package/dist/ConfirmDocumentUpgradeModal-CoixS60F.js.map +1 -0
- package/dist/{CookiesPolicyModal-BpyPPyxS.js → CookiesPolicyModal-BpFjYc7T.js} +5 -5
- package/dist/{CookiesPolicyModal-BpyPPyxS.js.map → CookiesPolicyModal-BpFjYc7T.js.map} +1 -1
- package/dist/CreateDocumentModal-CiIW3pzx.js +45 -0
- package/dist/CreateDocumentModal-CiIW3pzx.js.map +1 -0
- package/dist/{DebugSettingsModal-cFjT1zO6.js → DebugSettingsModal-DyJgAT7a.js} +11 -11
- package/dist/DebugSettingsModal-DyJgAT7a.js.map +1 -0
- package/dist/{DeleteDriveModal-Dug84t1j.js → DeleteDriveModal-1pAIayG_.js} +7 -7
- package/dist/DeleteDriveModal-1pAIayG_.js.map +1 -0
- package/dist/{DeleteItemModal-mMzy3V8o.js → DeleteItemModal-BUpqmFxS.js} +8 -8
- package/dist/DeleteItemModal-BUpqmFxS.js.map +1 -0
- package/dist/{DisclaimerModal-DvpD5dPM.js → DisclaimerModal-TIJXRYLF.js} +7 -7
- package/dist/DisclaimerModal-TIJXRYLF.js.map +1 -0
- package/dist/{DocumentVersionUnsupportedModal-C3Q0V75l.js → DocumentVersionUnsupportedModal-DH9Zzsyw.js} +6 -6
- package/dist/DocumentVersionUnsupportedModal-DH9Zzsyw.js.map +1 -0
- package/dist/{DownloadDocumentWithErrorsModal-IKl0ljQb.js → DownloadDocumentWithErrorsModal-Beh-xw8B.js} +8 -7
- package/dist/DownloadDocumentWithErrorsModal-Beh-xw8B.js.map +1 -0
- package/dist/{DriveAuthRequiredModal-DVK7ZQzO.js → DriveAuthRequiredModal-XTcoJKvj.js} +7 -7
- package/dist/DriveAuthRequiredModal-XTcoJKvj.js.map +1 -0
- package/dist/DriveSettingsModal-CGZQhzBa.js +127 -0
- package/dist/DriveSettingsModal-CGZQhzBa.js.map +1 -0
- package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js +2565 -0
- package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js.map +1 -0
- package/dist/{InspectorModal-Z7YMEHRm.js → InspectorModal-DzciPYGj.js} +71 -31
- package/dist/InspectorModal-DzciPYGj.js.map +1 -0
- package/dist/{LoginModal-CybbOm3N.js → LoginModal-O06ZvWFI.js} +8 -8
- package/dist/LoginModal-O06ZvWFI.js.map +1 -0
- package/dist/{OpenFileDocumentsModal-JcGCx1ta.js → OpenFileDocumentsModal-DJsC1oR1.js} +22 -16
- package/dist/OpenFileDocumentsModal-DJsC1oR1.js.map +1 -0
- package/dist/{UpgradeDriveModal-_8t9slxQ.js → UpgradeDriveModal-CCWKp5yn.js} +7 -7
- package/dist/UpgradeDriveModal-CCWKp5yn.js.map +1 -0
- package/dist/ai-tools-BGUMFEMV.js +42 -0
- package/dist/ai-tools-BGUMFEMV.js.map +1 -0
- package/dist/ai-tools-D_q-Whju.js +4 -0
- package/dist/app-loader-BqQxww1X.js +4 -0
- package/dist/app-loader-C3qk1eIr.js +1254 -0
- package/dist/app-loader-C3qk1eIr.js.map +1 -0
- package/dist/app-skeleton-CMUP2zaz.js +132 -0
- package/dist/app-skeleton-CMUP2zaz.js.map +1 -0
- package/dist/app-skeleton-CdD1m8G3.js +4 -0
- package/dist/boot-B3dspF_Y.js +233 -0
- package/dist/boot-B3dspF_Y.js.map +1 -0
- package/dist/buffer-DNTcuap_.js +66 -0
- package/dist/buffer-DNTcuap_.js.map +1 -0
- package/dist/{build-info-BPvkFr0E.js → build-info-BFK_O8Td.js} +10 -6
- package/dist/build-info-BFK_O8Td.js.map +1 -0
- package/dist/components-bFhETljf.js +121 -0
- package/dist/components-bFhETljf.js.map +1 -0
- package/dist/{connect.config-DaHDEUrw.js → connect.config-DL9nKtlW.js} +28 -15
- package/dist/connect.config-DL9nKtlW.js.map +1 -0
- package/dist/{connection-state-3w4liC1X.js → connection-state-0ippUGEC.js} +28 -12
- package/dist/connection-state-0ippUGEC.js.map +1 -0
- package/dist/context-De2EB1AA-Ni0d829Q.js +1759 -0
- package/dist/context-De2EB1AA-Ni0d829Q.js.map +1 -0
- package/dist/{cookie-banner-BH6bIq24.js → cookie-banner-NclLYtB0.js} +7 -7
- package/dist/{cookie-banner-BH6bIq24.js.map → cookie-banner-NclLYtB0.js.map} +1 -1
- package/dist/document-editor-container-C91BsZkt.js +4 -0
- package/dist/document-editor-container-Dkk87_q1.js +311 -0
- package/dist/document-editor-container-Dkk87_q1.js.map +1 -0
- package/dist/drive-icon-BIpd8edR.js +49 -0
- package/dist/drive-icon-BIpd8edR.js.map +1 -0
- package/dist/drive-placements-DjeVpTTm.js +38 -0
- package/dist/drive-placements-DjeVpTTm.js.map +1 -0
- package/dist/error-boundary-BsUBww61.js +155 -0
- package/dist/error-boundary-BsUBww61.js.map +1 -0
- package/dist/esm-BDACZntJ.js +148 -0
- package/dist/esm-BDACZntJ.js.map +1 -0
- package/dist/generic.d.ts +140 -0
- package/dist/generic.d.ts.map +1 -0
- package/dist/generic.js +31 -0
- package/dist/generic.js.map +1 -0
- package/dist/{i18n-CWO0vYVd.js → i18n-D9WYPgk9.js} +4 -4
- package/dist/{i18n-CWO0vYVd.js.map → i18n-D9WYPgk9.js.map} +1 -1
- package/dist/index-D7c2WAbn.d.ts +4 -0
- package/dist/layout-Dj3_KscE.js +5 -0
- package/dist/layout.d.ts +3 -0
- package/dist/layout.js +4 -0
- package/dist/{load-BJ8uRKR9.js → load-BzWc_SWH.js} +48 -46
- package/dist/load-BzWc_SWH.js.map +1 -0
- package/dist/load-runtime-config-DNu6zNak.js +14 -0
- package/dist/load-runtime-config-DNu6zNak.js.map +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +8 -8
- package/dist/main.js.map +1 -1
- package/dist/open-file-uploads-B5pr1sA2.js +183 -0
- package/dist/open-file-uploads-B5pr1sA2.js.map +1 -0
- package/dist/package-manager-Be80sske.js +550 -0
- package/dist/package-manager-Be80sske.js.map +1 -0
- package/dist/{pglite-major-B39aOEiE.js → pglite-major-pao-ozRo.js} +23 -5
- package/dist/pglite-major-pao-ozRo.js.map +1 -0
- package/dist/{pglite-migrate-core-Boxqqx-c.js → pglite-migrate-core-B6FqmhH8.js} +9 -7
- package/dist/pglite-migrate-core-B6FqmhH8.js.map +1 -0
- package/dist/{pglite-seed-BqAUvNFw.js → pglite-seed-CZsMNsV8.js} +8 -4
- package/dist/pglite-seed-CZsMNsV8.js.map +1 -0
- package/dist/pglite.worker.d.ts +2 -1
- package/dist/pglite.worker.js +4 -3
- package/dist/pglite.worker.js.map +1 -1
- package/dist/pglite.worker.legacy.d.ts +2 -1
- package/dist/pglite.worker.legacy.js +4 -3
- package/dist/pglite.worker.legacy.js.map +1 -1
- package/dist/plugin-configs.d.ts +242 -0
- package/dist/plugin-configs.d.ts.map +1 -0
- package/dist/plugin-configs.js +26 -0
- package/dist/plugin-configs.js.map +1 -0
- package/dist/plugins-CC5YRuPo.js +264 -0
- package/dist/plugins-CC5YRuPo.js.map +1 -0
- package/dist/{preferences-store-_5Cw4_YV.js → preferences-store-DxYAnGCc.js} +6 -25
- package/dist/preferences-store-DxYAnGCc.js.map +1 -0
- package/dist/prerender.d.ts +38 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +195 -0
- package/dist/prerender.js.map +1 -0
- package/dist/prerendered-shell-peKE7AqI.js +51 -0
- package/dist/prerendered-shell-peKE7AqI.js.map +1 -0
- package/dist/{pwa-manifest-link-DIgOSo2Q.js → pwa-manifest-link-DNwWvnLV.js} +5 -5
- package/dist/{pwa-manifest-link-DIgOSo2Q.js.map → pwa-manifest-link-DNwWvnLV.js.map} +1 -1
- package/dist/reactor-C9uRDsXf.js +1656 -0
- package/dist/reactor-C9uRDsXf.js.map +1 -0
- package/dist/reactor-chat-C6yp2S37.js +15 -0
- package/dist/reactor-chat-C6yp2S37.js.map +1 -0
- package/dist/reactor.worker.d.ts +2 -1
- package/dist/reactor.worker.js +494 -163
- package/dist/reactor.worker.js.map +1 -1
- package/dist/{registerServiceWorker-BSzbNfvz.js → registerServiceWorker-OR8nokAn.js} +5 -5
- package/dist/{registerServiceWorker-BSzbNfvz.js.map → registerServiceWorker-OR8nokAn.js.map} +1 -1
- package/dist/root-v9fj27sn.js +27 -0
- package/dist/root-v9fj27sn.js.map +1 -0
- package/dist/route-tree.d.ts +2220 -0
- package/dist/route-tree.d.ts.map +1 -0
- package/dist/route-tree.js +135 -0
- package/dist/route-tree.js.map +1 -0
- package/dist/route-views-BovMNHyn.js +60 -0
- package/dist/route-views-BovMNHyn.js.map +1 -0
- package/dist/route-views-C-H3ofJW.js +4 -0
- package/dist/route-views-DzgRMAx8.js +55 -0
- package/dist/route-views-DzgRMAx8.js.map +1 -0
- package/dist/route-views.d.ts +7 -0
- package/dist/route-views.d.ts.map +1 -0
- package/dist/route-views.js +4 -0
- package/dist/router-CWIsjETx.js +54 -0
- package/dist/router-CWIsjETx.js.map +1 -0
- package/dist/router-CnWkTEey.js +4 -0
- package/dist/router.d.ts +2 -0
- package/dist/router.js +3 -0
- package/dist/sentry-Cuc_Nbba.js +22 -0
- package/dist/sentry-Cuc_Nbba.js.map +1 -0
- package/dist/settings-lPl17GFn.js +1089 -0
- package/dist/settings-lPl17GFn.js.map +1 -0
- package/dist/settings-tabs-DjTVYKRn.js +424 -0
- package/dist/settings-tabs-DjTVYKRn.js.map +1 -0
- package/dist/shell-core-head.html +2 -0
- package/dist/shell-core.html +1 -0
- package/dist/shell-head.html +2 -0
- package/dist/shell-plugins.json +1 -0
- package/dist/shell.html +1 -0
- package/dist/start-connect.d.ts +7 -9
- package/dist/start-connect.d.ts.map +1 -1
- package/dist/start-connect.js +9 -8
- package/dist/start-connect.js.map +1 -1
- package/dist/store-lock-Bi3B9VJD.js +159 -0
- package/dist/store-lock-Bi3B9VJD.js.map +1 -0
- package/dist/style.css +3482 -733
- package/dist/{toast-BXIGd4Eb.js → toast-C6WW-_O-.js} +3 -3
- package/dist/{toast-BXIGd4Eb.js.map → toast-C6WW-_O-.js.map} +1 -1
- package/dist/ui-B5cPb3DN.js +66 -0
- package/dist/ui-B5cPb3DN.js.map +1 -0
- package/dist/ui-C1-l-Eyh.js +170 -0
- package/dist/ui-C1-l-Eyh.js.map +1 -0
- package/dist/{use-renown-login-Cf3va6u_.js → use-renown-login-dPpDOYq5.js} +4 -4
- package/dist/use-renown-login-dPpDOYq5.js.map +1 -0
- package/dist/workflows-C3qEvx1R.js +63 -0
- package/dist/workflows-C3qEvx1R.js.map +1 -0
- package/fonts.css +177 -0
- package/generic-routes.json +9 -0
- package/package.json +87 -26
- package/scripts/assert-plugin-configs.mjs +47 -0
- package/scripts/prerender-shell.ts +51 -0
- package/skills/customize-connect/SKILL.md +80 -0
- package/skills/customize-connect/references/data-and-navigation.md +315 -0
- package/skills/customize-connect/references/drive-apps.md +44 -0
- package/skills/customize-connect/references/hosts-and-plugins.md +88 -0
- package/skills/customize-connect/references/layout.md +162 -0
- package/skills/customize-connect/references/modals.md +99 -0
- package/skills/customize-connect/references/overrides.md +177 -0
- package/skills/customize-connect/references/packages.md +41 -0
- package/skills/customize-connect/references/pages.md +141 -0
- package/skills/customize-connect/references/runtime-config.md +411 -0
- package/skills/customize-connect/references/styles-and-branding.md +76 -0
- package/skills/customize-connect/references/types-and-troubleshooting.md +64 -0
- package/src/route-tree.ts +3 -0
- package/src/routeTree.gen.ts +235 -0
- package/src/router/index.ts +2 -0
- package/src/router/register.ts +9 -0
- package/src/routes/__root.tsx +12 -0
- package/src/routes/_app/$.tsx +13 -0
- package/src/routes/_app/d/$driveSlug/{-$nodeSlug}.tsx +13 -0
- package/src/routes/_app/d/$driveSlug.tsx +13 -0
- package/src/routes/_app/index.tsx +13 -0
- package/src/routes/_app/settings/appearance.tsx +13 -0
- package/src/routes/_app/settings/packages.tsx +13 -0
- package/src/routes/_app/settings.tsx +13 -0
- package/src/routes/_app.tsx +13 -0
- package/style.css +8 -23
- package/tailwind.css +12 -0
- package/theme.css +5 -0
- package/dist/AddDriveModal-xAw48kdl.js.map +0 -1
- package/dist/ClearStorageModal-BHLFpni1.js.map +0 -1
- package/dist/ConfirmDocumentUpgradeModal-FUOhZsk7.js.map +0 -1
- package/dist/CreateDocumentModal-C45W8J0V.js +0 -35
- package/dist/CreateDocumentModal-C45W8J0V.js.map +0 -1
- package/dist/DebugSettingsModal-cFjT1zO6.js.map +0 -1
- package/dist/DeleteDriveModal-Dug84t1j.js.map +0 -1
- package/dist/DeleteItemModal-mMzy3V8o.js.map +0 -1
- package/dist/DisclaimerModal-DvpD5dPM.js.map +0 -1
- package/dist/DocumentVersionUnsupportedModal-C3Q0V75l.js.map +0 -1
- package/dist/DownloadDocumentWithErrorsModal-IKl0ljQb.js.map +0 -1
- package/dist/DriveAuthRequiredModal-DVK7ZQzO.js.map +0 -1
- package/dist/DriveSettingsModal-C6-mRQiv.js +0 -57
- package/dist/DriveSettingsModal-C6-mRQiv.js.map +0 -1
- package/dist/InspectorModal-Z7YMEHRm.js.map +0 -1
- package/dist/LoginModal-CybbOm3N.js.map +0 -1
- package/dist/MissingPackageModal-nBnExqO0.js +0 -49
- package/dist/MissingPackageModal-nBnExqO0.js.map +0 -1
- package/dist/OpenFileDocumentsModal-JcGCx1ta.js.map +0 -1
- package/dist/SettingsModal-CgqnSXs5.js +0 -569
- package/dist/SettingsModal-CgqnSXs5.js.map +0 -1
- package/dist/UpgradeDriveModal-_8t9slxQ.js.map +0 -1
- package/dist/app-loader-GDy45Yza.js +0 -2244
- package/dist/app-loader-GDy45Yza.js.map +0 -1
- package/dist/app-loader-WZecUfE8.js +0 -4
- package/dist/build-info-BPvkFr0E.js.map +0 -1
- package/dist/components-Df4NlQZz.js +0 -4
- package/dist/connect.config-DaHDEUrw.js.map +0 -1
- package/dist/connection-state-3w4liC1X.js.map +0 -1
- package/dist/load-BJ8uRKR9.js.map +0 -1
- package/dist/pglite-major-B39aOEiE.js.map +0 -1
- package/dist/pglite-migrate-core-Boxqqx-c.js.map +0 -1
- package/dist/pglite-seed-BqAUvNFw.js.map +0 -1
- package/dist/preferences-store-_5Cw4_YV.js.map +0 -1
- package/dist/reactor-CbgxQyev.js +0 -1464
- package/dist/reactor-CbgxQyev.js.map +0 -1
- package/dist/runtime-config-DL3QjcfM.js +0 -24
- package/dist/runtime-config-DL3QjcfM.js.map +0 -1
- package/dist/sentry-QXKgQmr2.js +0 -15
- package/dist/sentry-QXKgQmr2.js.map +0 -1
- package/dist/use-renown-login-Cf3va6u_.js.map +0 -1
- package/dist/useRegistryPackages-BnUcL_nZ.js +0 -390
- package/dist/useRegistryPackages-BnUcL_nZ.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Modals
|
|
2
|
+
|
|
3
|
+
Editors, drive apps and Connect open modals with `showPHModal(modal)` from `@powerhousedao/reactor-browser`; the open modal's view reads it with `usePHModal()` and closes it with `closePHModal()`.
|
|
4
|
+
|
|
5
|
+
**Routed modals live in the URL:** `?modal=<id>` plus their fields. A link opens them (`modalHref(modal)` gives the href) and a reload keeps them open. Opening and closing replace the current history entry, so a modal is never a step of its own: Back leaves the page, not the modal.
|
|
6
|
+
|
|
7
|
+
| Modal | `?modal=` | Owner |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `createDocument` | `create-document&documentType=…[&documentModelVersion=…]` | core |
|
|
10
|
+
| `login` | `login` | core |
|
|
11
|
+
| `addDrive` | `add-drive` | generic |
|
|
12
|
+
| `driveSettings` | `drive-settings&driveId=…` | generic |
|
|
13
|
+
| `debugSettings`, `inspector` | `debug-settings`, `inspector` | generic |
|
|
14
|
+
| `disclaimer` | `disclaimer` | generic |
|
|
15
|
+
| `cookiesPolicy` | `cookies-policy` | Connect (analytics consent) |
|
|
16
|
+
|
|
17
|
+
**Confirmations and notices stay out of the URL:** `deleteItem`, `confirmDocumentUpgrade`, `downloadDocumentWithErrors`, `documentVersionUnsupported` and `driveAuthRequired` (core's), `deleteDrive`, `upgradeDrive` and `clearStorage` (generic's), and `openFileDocuments` (Connect's file handler).
|
|
18
|
+
|
|
19
|
+
- **Core** has a plain view for each of its modals, so every host can show what editors and drive apps open.
|
|
20
|
+
- **With the generic plugin**, Connect shows its design-system views for all of them; without it, core's.
|
|
21
|
+
|
|
22
|
+
A plain `<a href={modalHref(modal)}>` reloads the app. `useModalLinkProps(modal)` gives a link that opens the modal in place on a plain click, and its URL to new tabs and copied links:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { useModalLinkProps } from "@powerhousedao/reactor-browser";
|
|
26
|
+
|
|
27
|
+
const modal = { type: "createDocument", documentType: "powerhouse/todo" } as const;
|
|
28
|
+
|
|
29
|
+
function NewTodoListLink() {
|
|
30
|
+
return <a {...useModalLinkProps(modal)}>New todo list</a>;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- The href follows the page's query params as they change.
|
|
35
|
+
- Confirmations (`deleteItem` and the like) aren't routed, so their link has no URL of its own; open them with `showPHModal(modal)` from a button.
|
|
36
|
+
- `createDocument` creates in the open drive, and its open folder, then opens the new document in its drive, wherever the modal was opened. Outside a drive it asks which drive, preselecting the only one, and offers to add a drive when there is none. Give it `driveId` to choose the drive yourself, e.g. `{ type: "createDocument", documentType: "powerhouse/todo", driveId }`.
|
|
37
|
+
|
|
38
|
+
## Replace a modal's view
|
|
39
|
+
|
|
40
|
+
A route's `staticData.modals` replaces the host's view of a modal while the route matches; the deepest matched route wins. The view reads the modal with `usePHModal()`. In `_app.tsx` and overrides, `ModalDialog` comes from `@powerhousedao/connect/layout`, as below; in any other route (an offered one), import it from `@powerhousedao/connect-core/router`:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
// hosts/connect/routes/_app.tsx
|
|
44
|
+
import { ModalDialog } from "@powerhousedao/connect/layout";
|
|
45
|
+
import { closePHModal, usePHModal } from "@powerhousedao/reactor-browser";
|
|
46
|
+
|
|
47
|
+
export const Route = createFileRoute("/_app")({
|
|
48
|
+
component: Layout,
|
|
49
|
+
staticData: { modals: { createDocument: CreateTodoList } },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function CreateTodoList() {
|
|
53
|
+
const modal = usePHModal();
|
|
54
|
+
if (modal?.type !== "createDocument") return null;
|
|
55
|
+
return (
|
|
56
|
+
<ModalDialog labelledBy="new-todo-list" className="rounded-xl p-6">
|
|
57
|
+
<h2 id="new-todo-list">New {modal.documentType}</h2>
|
|
58
|
+
<button onClick={closePHModal}>Cancel</button>
|
|
59
|
+
</ModalDialog>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- `ModalDialog` opens the view as a modal, centred, with a backdrop; Escape and a click on the backdrop close it. A plain `<dialog open>` gets none of that.
|
|
65
|
+
|
|
66
|
+
- On an override of one of Connect's routes, spread `options.staticData` first if it has any.
|
|
67
|
+
- A view that throws closes quietly; the error is logged.
|
|
68
|
+
|
|
69
|
+
## Frame every modal
|
|
70
|
+
|
|
71
|
+
A frame applies only in a host whose composition leaves out the generic plugin: the generic plugin, active in a default Connect, draws every modal with the design system.
|
|
72
|
+
|
|
73
|
+
A route's `staticData.modalFrame` lays out every core modal while the route matches, so one component restyles all of them. Each modal passes its title, content and buttons; `ModalDialog` keeps the dialog's behaviour (modal, Escape and the backdrop close it):
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
// hosts/connect/routes/_app.tsx
|
|
77
|
+
import type { ModalFrameProps } from "@powerhousedao/connect/layout";
|
|
78
|
+
import { ModalDialog } from "@powerhousedao/connect/layout";
|
|
79
|
+
|
|
80
|
+
export const Route = createFileRoute("/_app")({
|
|
81
|
+
component: Layout,
|
|
82
|
+
staticData: { modalFrame: Frame },
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
function Frame({ title, titleId, actions, children }: ModalFrameProps) {
|
|
86
|
+
return (
|
|
87
|
+
<ModalDialog labelledBy={titleId} className="rounded-xl p-0 shadow-2xl">
|
|
88
|
+
<h2 id={titleId}>{title}</h2>
|
|
89
|
+
<div>{children}</div>
|
|
90
|
+
<footer>{actions}</footer>
|
|
91
|
+
</ModalDialog>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- The deepest matched route's frame wins, as with `staticData.modals`. On `_app` it frames the modals opened inside the layout; on the root route, all of them.
|
|
97
|
+
- It frames core's modals only. Views a route gives in `staticData.modals` draw their own.
|
|
98
|
+
- The content and buttons keep core's markup; style them from the frame, e.g. with `[&_button]:…` classes.
|
|
99
|
+
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Override Connect's routes, loading, not found and errors
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- [Override a Connect route](#override-a-connect-route)
|
|
6
|
+
- [Build on the home page](#build-on-the-home-page)
|
|
7
|
+
- [Loading, not found and errors](#loading-not-found-and-errors)
|
|
8
|
+
- [Slow routes](#slow-routes)
|
|
9
|
+
- [Not found](#not-found)
|
|
10
|
+
- [Errors](#errors)
|
|
11
|
+
|
|
12
|
+
## Override a Connect route
|
|
13
|
+
|
|
14
|
+
Every page Connect shows is a file route in `@powerhousedao/connect`'s `src/routes/` (`node_modules/@powerhousedao/connect/src/routes/` in a project). A project file at the same path replaces Connect's file. Each of Connect's files exports `options`: everything but the component (loader, search params, pending view, title). Every route option key is present, typed `undefined` where the route doesn't set it. An override spreads them and sets its own `component`; don't call `options.loader` directly, since a loader can be an object with a `handler`:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
// hosts/connect/routes/_app/d/$driveSlug.tsx
|
|
18
|
+
import { useDriveRouteData } from "@powerhousedao/connect/layout";
|
|
19
|
+
import { options } from "@powerhousedao/connect/routes/_app/d/$driveSlug";
|
|
20
|
+
import { createFileRoute, Outlet } from "@tanstack/react-router";
|
|
21
|
+
|
|
22
|
+
export const Route = createFileRoute("/_app/d/$driveSlug")({
|
|
23
|
+
...options,
|
|
24
|
+
component: InventoryDrive,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function InventoryDrive() {
|
|
28
|
+
const { drive, folder, documentId } = useDriveRouteData();
|
|
29
|
+
if (!drive) return null;
|
|
30
|
+
// The node route renders the open document in the outlet.
|
|
31
|
+
if (documentId) return <Outlet />;
|
|
32
|
+
return <p>{folder?.name ?? drive.header.name}</p>;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Path | File | What it renders |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| (every page) | `__root.tsx` | The page, the title, the loading shell. Not overridable. |
|
|
39
|
+
| (layout) | `_app.tsx` | The sidebar beside the content; see [Replace the layout](./layout.md#replace-the-layout). |
|
|
40
|
+
| `/` | `_app/index.tsx` | Home: the drives. |
|
|
41
|
+
| `/d/$driveSlug` | `_app/d/$driveSlug.tsx` | The drive: its drive app, or the sign-in gate, around the node route. |
|
|
42
|
+
| `/d/$driveSlug/{-$nodeSlug}` | `_app/d/$driveSlug/{-$nodeSlug}.tsx` | The open document: its editor, or its revision history with `?history`. Nothing on a folder. |
|
|
43
|
+
| `/settings` | `_app/settings.tsx` | The settings page around the shown tab. |
|
|
44
|
+
| `/settings/<tab>` | `_app/settings/<tab>.tsx` | One settings tab. |
|
|
45
|
+
| unknown paths | `_app/$.tsx` | The 404 page. |
|
|
46
|
+
|
|
47
|
+
- `useDriveRouteData()` returns the open `drive`, `folder` and `documentId` from the drive routes' loaders, live.
|
|
48
|
+
- Connect's routes nested under an overridden one stay: the node route renders in an overridden drive route's `<Outlet />`, and the tabs in an overridden settings page's.
|
|
49
|
+
- Drive apps and editors come from packages, not routes ([drive-apps.md](./drive-apps.md)). Override a route only to change Connect around them.
|
|
50
|
+
- Without the generic plugin, each of Connect's files shows core's view instead (a header, an index of drives, a directory listing, a JSON view). An override shows the same view either way.
|
|
51
|
+
- `_app.tsx` and `__root.tsx` are not overridden here: a project's `_app.tsx` replaces the layout ([layout.md](./layout.md)), and the root route is Connect's.
|
|
52
|
+
- To hide a route, override it with a `beforeLoad` that throws `notFound()` or `redirect()`.
|
|
53
|
+
- `ph build` and Studio warn about an override that doesn't import its route's `options`: what Connect sets on the route is dropped.
|
|
54
|
+
|
|
55
|
+
### Build on the home page
|
|
56
|
+
|
|
57
|
+
`Home` is made of parts that `/generic` exports, so a custom home keeps Connect's drive cards and adds its own:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
// hosts/connect/routes/_app/index.tsx
|
|
61
|
+
import {
|
|
62
|
+
ConnectHomeScreen,
|
|
63
|
+
HomeAddDriveItem,
|
|
64
|
+
HomeDriveItem,
|
|
65
|
+
useVisibleDrives,
|
|
66
|
+
} from "@powerhousedao/connect/generic";
|
|
67
|
+
import { options } from "@powerhousedao/connect/routes/_app/index";
|
|
68
|
+
import { HomeScreenItem } from "@powerhousedao/design-system/connect";
|
|
69
|
+
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
|
70
|
+
|
|
71
|
+
export const Route = createFileRoute("/_app/")({
|
|
72
|
+
...options,
|
|
73
|
+
component: InventoryHome,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// A card like the drives', for a page of the project's own.
|
|
77
|
+
function OpenOrdersCard() {
|
|
78
|
+
const navigate = useNavigate();
|
|
79
|
+
return (
|
|
80
|
+
<HomeScreenItem
|
|
81
|
+
title="Open orders"
|
|
82
|
+
description="Orders on the floor"
|
|
83
|
+
onClick={() => void navigate({ to: "/orders" })}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function InventoryHome() {
|
|
89
|
+
const drives = useVisibleDrives();
|
|
90
|
+
return (
|
|
91
|
+
<ConnectHomeScreen>
|
|
92
|
+
<OpenOrdersCard />
|
|
93
|
+
{drives?.map((drive) => (
|
|
94
|
+
<HomeDriveItem key={drive.header.id} drive={drive} />
|
|
95
|
+
))}
|
|
96
|
+
<HomeAddDriveItem />
|
|
97
|
+
</ConnectHomeScreen>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- `ConnectHomeScreen` is the grid on the configured `branding.homeBackground`.
|
|
103
|
+
- `useVisibleDrives()` is `useDrives()` without the drives dismissed from the sign-in gate this session.
|
|
104
|
+
- `HomeAddDriveItem` renders nothing where adding drives is turned off.
|
|
105
|
+
- `HomeScreenItem` (`@powerhousedao/design-system/connect`) is the card the drives use: `title`, `description`, an `icon` element, and `href` or `onClick`.
|
|
106
|
+
|
|
107
|
+
## Loading, not found and errors
|
|
108
|
+
|
|
109
|
+
Connect uses the router's own states: a route's `pendingComponent`, `notFoundComponent` and `errorComponent`. A project sets them on its routes, or on its overrides of Connect's routes (see [Override a Connect route](#override-a-connect-route)). The loading screen is in [layout.md](./layout.md#the-loading-screen).
|
|
110
|
+
|
|
111
|
+
### Slow routes
|
|
112
|
+
|
|
113
|
+
A route whose loader takes longer than its `pendingMs` shows its `pendingComponent`. Connect's drive routes show a "Loading drive…" note on a cold start and keep the open view on warm navigations. An override spreads their `options` and can set its own:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
export const Route = createFileRoute("/_app/d/$driveSlug")({
|
|
117
|
+
...options,
|
|
118
|
+
pendingComponent: DriveSkeleton,
|
|
119
|
+
component: InventoryDrive,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Not found
|
|
124
|
+
|
|
125
|
+
| What | Where to change it |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| A path no route serves | Override `_app/$.tsx`, spreading its `options`. It renders inside the layout, titled `Not found · <app>`; the URL stays as typed. Its loader waits for packages' routes still loading (up to 10 s), so a deep link to a package's page shows the loading state, not this page. |
|
|
128
|
+
| A drive that isn't listed once drives arrive | `notFoundComponent` on an override of `_app/d/$driveSlug.tsx`; `isDriveNotFound(data)` gives the slug. |
|
|
129
|
+
| A project route's own `notFound()` | That route's `notFoundComponent`. |
|
|
130
|
+
| Anything else | Connect's 404 page. |
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
// hosts/connect/routes/_app/d/$driveSlug.tsx
|
|
134
|
+
import { isDriveNotFound } from "@powerhousedao/connect/router";
|
|
135
|
+
import { options } from "@powerhousedao/connect/routes/_app/d/$driveSlug";
|
|
136
|
+
import { createFileRoute, type NotFoundRouteProps } from "@tanstack/react-router";
|
|
137
|
+
|
|
138
|
+
export const Route = createFileRoute("/_app/d/$driveSlug")({
|
|
139
|
+
...options,
|
|
140
|
+
component: InventoryDrive,
|
|
141
|
+
notFoundComponent: ({ data }: NotFoundRouteProps) =>
|
|
142
|
+
isDriveNotFound(data) ? <p>No drive {data.driveSlug}.</p> : <p>Not found.</p>,
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
A project route throws `notFound()` the same way:
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { createFileRoute, notFound } from "@tanstack/react-router";
|
|
150
|
+
|
|
151
|
+
export const Route = createFileRoute("/_app/documents/$documentId")({
|
|
152
|
+
loader: async ({ context, params }) => {
|
|
153
|
+
// ...
|
|
154
|
+
throw notFound();
|
|
155
|
+
},
|
|
156
|
+
notFoundComponent: () => <p className="p-6">No such document.</p>,
|
|
157
|
+
component: DocumentSummary,
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Errors
|
|
162
|
+
|
|
163
|
+
A loader or render error shows the route's `errorComponent`, else Connect's error view (with the generic plugin) or core's. It gets `{ error, reset }`; `error` is `unknown`, since anything can be thrown, and `reset()` retries the route. Connect reports the error to Sentry when Sentry is configured.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
export const Route = createFileRoute("/_app/reports")({
|
|
167
|
+
loader: loadReports,
|
|
168
|
+
errorComponent: ({ error, reset }) => (
|
|
169
|
+
<div role="alert">
|
|
170
|
+
<p>{error instanceof Error ? error.message : "Something went wrong"}</p>
|
|
171
|
+
<button onClick={reset}>Try again</button>
|
|
172
|
+
</div>
|
|
173
|
+
),
|
|
174
|
+
component: Reports,
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Extend Connect from a package
|
|
2
|
+
|
|
3
|
+
## Offer a package's routes
|
|
4
|
+
|
|
5
|
+
A package's `hosts/connect/routes/` also adds routes to every Connect that loads the package, e.g. a Reports page or a settings tab, without code:
|
|
6
|
+
|
|
7
|
+
- Offered: every route file but `_app.tsx` and the files that override Connect's `_app/` routes. Those two only apply to the package's own host. A child of an override joins the loading Connect's route with that id.
|
|
8
|
+
- `ph build` builds them as `./connect-routes` (`dist/browser/connect-routes.js`), in the same build as the package, and sets `connectRoutes: true` in the package's manifest. A module both import, e.g. a store or a React context an editor and a route share, is one chunk, so they share its state. Connect loads the module when it loads a package with the flag, and takes the routes out when the package is removed, replaced or reinstalled.
|
|
9
|
+
- They join the loading Connect's routes by id (`/_app`, `/_app/settings`, `/_app/d/$driveSlug`, ...). A route at an id that Connect already serves is skipped with a warning; `staticData.nav` and `staticData.settings` list them as for a project's routes.
|
|
10
|
+
- A deep link or reload on a package's page waits for the package: Connect holds unknown paths while packages and their routes load (see [Not found](./overrides.md#not-found)).
|
|
11
|
+
- Removing a package while one of its pages is open takes the app home first.
|
|
12
|
+
- Bundled packages (`ph install --local`, `provider: "local"`) register in a production build through the page's import map, as on the dev server.
|
|
13
|
+
- An offered route imports `@powerhousedao/connect-core` (`ContentOutlet`, `useDriveRouteData`, `ModalDialog`), `@tanstack/react-router` and `@powerhousedao/reactor-browser`, which Connect shares with packages. `@powerhousedao/connect` is not shared, so `ph build` fails, naming the file, if an offered route imports it, or reaches a module that does. The rest of the package gets a warning: its build would bundle a copy of the Connect modules it uses, apart from the app's state.
|
|
14
|
+
- An offered route also imports its own package's code, such as `document-models/*` and editor components, which the same build bundles. Another package's runtime import, e.g. `@powerhousedao/shared` (usually only a devDependency), is bundled as a copy; take the same helper from `@powerhousedao/reactor-browser` where it has one, e.g. `isFileNodeKind`.
|
|
15
|
+
- `@powerhousedao/connect/layout` re-exports `@powerhousedao/connect-core/router` and design-system parts. An offered route imports those directly: `useNavRoutes`, `useSidebarMode` and `ContentOutlet` from `@powerhousedao/connect-core/router`, `SidebarItem` from `@powerhousedao/design-system/connect`.
|
|
16
|
+
- The project's own package is the exception: its host build already has its routes.
|
|
17
|
+
- The package's stylesheet styles its routes, as it does its editors; see [A package's styles](./styles-and-branding.md#a-packages-styles).
|
|
18
|
+
|
|
19
|
+
## Register routes from code
|
|
20
|
+
|
|
21
|
+
A package that Connect loads can also register routes from its own module. The registrations live in one registry per page, on `globalThis`, so a package bundled with its own copy of `@powerhousedao/connect-core` still reaches the app. A production build also shares `@powerhousedao/connect-core` and `@tanstack/react-router` through the import map, so the package and Connect use one router.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { registerConnectRoutes } from "@powerhousedao/connect-core/router";
|
|
25
|
+
import { createRoute } from "@tanstack/react-router";
|
|
26
|
+
|
|
27
|
+
// A settings tab; a router already running takes it in.
|
|
28
|
+
registerConnectRoutes(({ settingsRoute }) => [
|
|
29
|
+
createRoute({
|
|
30
|
+
getParentRoute: () => settingsRoute,
|
|
31
|
+
path: "inventory",
|
|
32
|
+
staticData: { settings: { label: "Inventory", order: 50 } },
|
|
33
|
+
component: InventorySettings,
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- It returns the unregister.
|
|
39
|
+
- A route at a path a route already serves is skipped with a warning.
|
|
40
|
+
- Core's views are styled with Tailwind classes and `theme.css` tokens (`bg-core-bg`, `text-core-fg`, ...). Core ships no compiled CSS: its host builds with Tailwind 4 and imports `@powerhousedao/connect-core/tailwind.css`, which imports the tokens (`theme.css`) and makes Tailwind scan core's sources. `@powerhousedao/connect/tailwind.css` does this; see [Styles](./styles-and-branding.md#styles).
|
|
41
|
+
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Pages, sidebar links and settings tabs
|
|
2
|
+
|
|
3
|
+
A project adds pages to Connect with file routes in `hosts/connect/routes/`. A route lists itself in the sidebar, changes the sidebar on its page, adds a settings tab and sets its title through its own options.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- [Add a page](#add-a-page)
|
|
8
|
+
- [Add a sidebar link](#add-a-sidebar-link)
|
|
9
|
+
- [Hide or collapse the sidebar on a page](#hide-or-collapse-the-sidebar-on-a-page)
|
|
10
|
+
- [Add a settings tab](#add-a-settings-tab)
|
|
11
|
+
- [Set the page title](#set-the-page-title)
|
|
12
|
+
|
|
13
|
+
## Add a page
|
|
14
|
+
|
|
15
|
+
Routes import `@tanstack/react-router`. A project from `ph init` has it as a `peerDependency`, and as a `devDependency` at the version Connect is built with; `ph migrate` adds it to an older project. Connect uses the project's copy, so keep that version rather than adding another.
|
|
16
|
+
|
|
17
|
+
1. Create a route file. A file in `_app/` renders inside Connect's layout; its route id starts with `/_app`, and the URL does not:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
// hosts/connect/routes/_app/inventory.tsx
|
|
21
|
+
import { useDrives } from "@powerhousedao/reactor-browser";
|
|
22
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
23
|
+
|
|
24
|
+
export const Route = createFileRoute("/_app/inventory")({
|
|
25
|
+
component: Inventory,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function Inventory() {
|
|
29
|
+
const drives = useDrives();
|
|
30
|
+
return <div className="p-6">{drives?.length ?? 0} drives</div>;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Open `/inventory` in Vetra Studio, at the `connectUrl` in `.ph/vetra-runtime.json`.
|
|
35
|
+
|
|
36
|
+
A file outside `_app/` is a full page, without Connect's layout:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// hosts/connect/routes/status.tsx
|
|
40
|
+
import { useDrives } from "@powerhousedao/reactor-browser";
|
|
41
|
+
import { createFileRoute, Link } from "@tanstack/react-router";
|
|
42
|
+
|
|
43
|
+
export const Route = createFileRoute("/status")({
|
|
44
|
+
component: Status,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
function Status() {
|
|
48
|
+
const drives = useDrives();
|
|
49
|
+
return (
|
|
50
|
+
<div className="p-6">
|
|
51
|
+
<h1>{drives?.length ?? 0} drives</h1>
|
|
52
|
+
<Link to="/">Back to Connect</Link>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Rules:
|
|
59
|
+
|
|
60
|
+
- Connect reads routes only from `hosts/connect/routes/`.
|
|
61
|
+
- Core routes are `/`, `/d/$driveSlug/{-$nodeSlug}`, `/settings` with its Appearance and Packages tabs, and the catch-all `$`. They live in `@powerhousedao/connect-core`. A file in `_app/` at a core route's path overrides it; see [Override a Connect route](./overrides.md#override-a-connect-route). Any other route at a URL Connect serves, e.g. a full page `settings.tsx` outside `_app/`, fails the build and names both files.
|
|
62
|
+
- Files and folders starting with `-` are not routes. Use them for shared components.
|
|
63
|
+
- Route groups, `(name)/`, only organize files.
|
|
64
|
+
- Each route is code-split into its own chunk.
|
|
65
|
+
- Inside a route, navigate with the router's `Link` and `useNavigate`. They are typed with the project's routes and Connect's.
|
|
66
|
+
- A route file's `createFileRoute("…")` id must match its path. While Studio runs, the router's watcher rewrites a mismatched id in the file itself, under your editor; without Studio, `tsc` reports it.
|
|
67
|
+
|
|
68
|
+
## Add a sidebar link
|
|
69
|
+
|
|
70
|
+
A route in `_app/` lists itself in the sidebar with `staticData.nav`:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
// hosts/connect/routes/_app/inventory.tsx
|
|
74
|
+
export const Route = createFileRoute("/_app/inventory")({
|
|
75
|
+
staticData: { nav: { label: "Inventory", order: 10 } },
|
|
76
|
+
component: Inventory,
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- Links come after the drives, sorted by `order`, then by `label`.
|
|
81
|
+
- `icon` is optional: any component that takes `size` (and `className`). Without one, the link shows the label's first letter.
|
|
82
|
+
- Routes with path params (`$id`) are not listed: the sidebar cannot fill in the param. `ph build` and Studio warn about a `nav` on one.
|
|
83
|
+
|
|
84
|
+
## Hide or collapse the sidebar on a page
|
|
85
|
+
|
|
86
|
+
`staticData.sidebar` changes the sidebar for a route and its children:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
// hosts/connect/routes/_app/focus.tsx
|
|
90
|
+
export const Route = createFileRoute("/_app/focus")({
|
|
91
|
+
// "hidden" drops the sidebar; "collapsed" keeps only its header and footer.
|
|
92
|
+
staticData: { sidebar: "hidden" },
|
|
93
|
+
component: () => <div className="p-6">No sidebar here.</div>,
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The deepest matched route that sets `sidebar` decides. Embedded mode (`?embed=1`) always hides the sidebar.
|
|
98
|
+
|
|
99
|
+
## Add a settings tab
|
|
100
|
+
|
|
101
|
+
Settings is the page at `/settings`, with one child route per tab. A file in `_app/settings/` with `staticData.settings` adds a tab:
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
// hosts/connect/routes/_app/settings/inventory.tsx
|
|
105
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
106
|
+
|
|
107
|
+
export const Route = createFileRoute("/_app/settings/inventory")({
|
|
108
|
+
staticData: {
|
|
109
|
+
settings: {
|
|
110
|
+
label: "Inventory",
|
|
111
|
+
// Connect's tabs use multiples of 10, from 0 to 90.
|
|
112
|
+
order: 50,
|
|
113
|
+
// Optional: the tab is hidden, and its URL redirects to the first tab, while this is false.
|
|
114
|
+
enabled: (context) => !!context.store.drives?.length,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
component: () => <div>Inventory settings</div>,
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- `icon` (a component that takes `size`, as for a sidebar link) and `destructive` are optional.
|
|
122
|
+
- The page title becomes `Settings · Inventory · <app>`. The tab needs no `head`.
|
|
123
|
+
- The generic plugin adds its tabs (Package Manager, Default Editors, Danger Zone, About, AI Assistant) as code routes and hides core's (Appearance, Packages); without it, core's are listed. A project file at a tab's path, e.g. `_app/settings/about.tsx`, replaces that tab; it spreads the tab's options from `genericSettingsTabs` (`@powerhousedao/connect/generic`), e.g. `...genericSettingsTabs.about`, to keep its label, icon and order. Like an override of Connect's routes, it stays this project's: `ph build` doesn't offer it to other Connects, so it may import `@powerhousedao/connect`.
|
|
124
|
+
|
|
125
|
+
## Set the page title
|
|
126
|
+
|
|
127
|
+
A route sets the document title with `head`. Connect's titles end with the app name:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
export const Route = createFileRoute("/_app/inventory")({
|
|
131
|
+
head: ({ match }) => ({
|
|
132
|
+
meta: [{ title: `Inventory · ${match.context.appName ?? "Connect"}` }],
|
|
133
|
+
}),
|
|
134
|
+
component: Inventory,
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- The deepest route with a title wins. Without one, the page keeps Connect's: the app name.
|
|
139
|
+
- `head` also receives `loaderData`, e.g. `` title: `${loaderData?.name} · ${appName}` ``.
|
|
140
|
+
- Connect's own titles are in `@powerhousedao/connect-core`'s `src/router/titles.ts`: `<node> · <drive> · <app>`, `Settings · <tab> · <app>`, `Not found · <app>`.
|
|
141
|
+
|