From e481a7e0eabcead289aec218d43b271a6a0b57c2 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Fri, 23 Jun 2023 08:29:09 +0200 Subject: [PATCH] chore(typedoc-theme): Port navbar and sidebar from 0.22.x --- package.json | 1 - .../child-template-dropdown.html | 4 - .../child-template-list.html | 4 - .../navigation-primary.component.tsx | 165 ++++++------- .../scripts/original/bootstrap.ts | 4 +- .../scripts/types/index.ts | 2 +- .../types/jsx/jsx-navigation-primary-props.ts | 4 +- .../scripts/types/module.ts | 6 + .../scripts/types/navigation-flat.ts | 9 - .../navigation-primary-component-scope.ts | 11 +- .../styles/_bootstrap.scss | 79 ++++--- .../styles/_variables-bootstrap.scss | 6 +- .../typedoc-theme-client/styles/main.scss | 24 +- .../typedoc-theme-client/styles/original.scss | 190 +++++++-------- packages/typedoc-theme/assets/main.bundle.js | 90 ++----- .../typedoc-theme/assets/main.bundle.js.map | 2 +- packages/typedoc-theme/assets/main.css | 6 +- packages/typedoc-theme/src/jsx/jsx.ts | 44 ++-- .../typedoc-theme/src/layouts/default.tsx | 51 ++-- packages/typedoc-theme/src/lib.tsx | 63 +++-- .../typedoc-theme/src/partials/breadcrumb.tsx | 34 ++- .../src/partials/gjsify-sidebar.tsx | 27 +++ packages/typedoc-theme/src/partials/index.tsx | 8 +- .../src/partials/member.declaration.tsx | 2 +- .../src/partials/member.signature.title.tsx | 4 +- .../src/partials/member.sources.tsx | 66 +++--- .../src/partials/navigation-secondary.tsx | 125 ++++++++++ .../typedoc-theme/src/partials/navigation.tsx | 76 +++++- .../typedoc-theme/src/partials/toolbar.tsx | 134 +++++++---- packages/typedoc-theme/src/partials/type.tsx | 219 ++++++++---------- .../src/partials/typeAndParent.tsx | 8 +- .../src/services/asset.service.ts | 50 ---- .../typedoc-theme/src/theme-render-context.ts | 38 ++- packages/typedoc-theme/src/theme.tsx | 50 ++-- packages/typedoc-theme/src/types/index.ts | 3 +- packages/typedoc-theme/src/utils/array.ts | 1 + packages/typedoc-theme/src/utils/fs.ts | 10 +- packages/typedoc-theme/src/utils/html.ts | 11 + packages/typedoc-theme/src/utils/index.ts | 3 + packages/typedoc-theme/src/utils/string.ts | 16 ++ yarn.lock | 20 +- 41 files changed, 944 insertions(+), 726 deletions(-) delete mode 100644 packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-dropdown.html delete mode 100644 packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-list.html create mode 100644 packages/typedoc-theme-client/scripts/types/module.ts delete mode 100644 packages/typedoc-theme-client/scripts/types/navigation-flat.ts create mode 100644 packages/typedoc-theme/src/partials/gjsify-sidebar.tsx create mode 100644 packages/typedoc-theme/src/partials/navigation-secondary.tsx create mode 100644 packages/typedoc-theme/src/utils/array.ts create mode 100644 packages/typedoc-theme/src/utils/html.ts create mode 100644 packages/typedoc-theme/src/utils/string.ts diff --git a/package.json b/package.json index a93d63fde..10ebe0a3c 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,6 @@ "!vendor/riba/infra/schematics" ], "resolutions": { - "bootstrap": "twbs/bootstrap#main", "@ribajs/accessibility": "workspace:^", "@ribajs/artcodestudio": "workspace:^", "@ribajs/bs4": "workspace:^", diff --git a/packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-dropdown.html b/packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-dropdown.html deleted file mode 100644 index 14bcaee6c..000000000 --- a/packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-dropdown.html +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-list.html b/packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-list.html deleted file mode 100644 index 59ce1e8d9..000000000 --- a/packages/typedoc-theme-client/scripts/components/navigation-primary/child-template-list.html +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/packages/typedoc-theme-client/scripts/components/navigation-primary/navigation-primary.component.tsx b/packages/typedoc-theme-client/scripts/components/navigation-primary/navigation-primary.component.tsx index 11eaf8a71..583b5eb95 100644 --- a/packages/typedoc-theme-client/scripts/components/navigation-primary/navigation-primary.component.tsx +++ b/packages/typedoc-theme-client/scripts/components/navigation-primary/navigation-primary.component.tsx @@ -3,12 +3,10 @@ import { EventDispatcher } from "@ribajs/events"; import { Dropdown } from "@ribajs/bs5"; import { Pjax } from "@ribajs/router"; import type {} from "@ribajs/fuse"; -import childTemplateList from "./child-template-list.html?raw"; -import childTemplateDropdown from "./child-template-dropdown.html?raw"; import type { NavigationPrimaryComponentScope, - NavigationFlat, + Module, JsxTsdNavigationPrimaryProps, Dataset, } from "../../types/index.js"; @@ -17,19 +15,16 @@ export class NavigationPrimaryComponent extends Component { public static tagName = "tsd-navigation-primary"; static get observedAttributes(): (keyof JsxTsdNavigationPrimaryProps)[] { - return ["type"]; + return []; } protected requiredAttributes(): (keyof JsxTsdNavigationPrimaryProps)[] { - return ["type"]; + return []; } protected routerEvents = new EventDispatcher("main"); public scope: NavigationPrimaryComponentScope = { - childTemplateList, - childTemplateDropdown, - type: "list", selectedModule: "Modules", onModuleSelect: this.onModuleSelect, }; @@ -66,16 +61,16 @@ export class NavigationPrimaryComponent extends Component { } } - public onModuleSelect(mod: NavigationFlat) { + public onModuleSelect(mod: Module) { console.debug("onModuleSelect"); - this.scope.selectedModule = mod.parent?.name || mod.name; + this.scope.selectedModule = mod.name; const pjax = Pjax.getInstance("main"); - if (!pjax || !mod.href) { + if (!pjax || !mod.url) { console.warn("No module with href or no pjax instance found!"); return; } Dropdown.hideAll(); - pjax.goTo(mod.href); + pjax.goTo(mod.url); } protected setSelectedModule(dataset: Dataset) { @@ -90,101 +85,75 @@ export class NavigationPrimaryComponent extends Component { } protected async fetchData() { - const data = await HttpService.getJSON( - "/assets/primary-navigation.json" - ); - this.scope.primaryNav = data.body; - console.debug("NavigationPrimaryComponent", this.scope.primaryNav); + const data = await HttpService.getJSON("/assets/modules.json"); + this.scope.modules = data.body; + console.debug("NavigationPrimaryComponent", this.scope.modules); } protected template(): ReturnType { - if (this.scope.type === "list") { - return ( - - ); - } else { - return ( -