From 61bbe89d7885d8911f0b3d9650d7bd14d28001e1 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 11 Oct 2024 11:14:33 -0600 Subject: [PATCH] Add folder icon Resolves #2741 --- CHANGELOG.md | 1 + scripts/build_themes.js | 2 +- .../themes/default/assets/typedoc/Navigation.ts | 5 +++-- src/lib/output/themes/default/partials/icon.tsx | 15 +++++++++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6247b40..83206f526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - Added `headings` option to control optional headings, #2729. +- Added a folder icon to page navigation elements which are not links, #2741. ### Bug Fixes diff --git a/scripts/build_themes.js b/scripts/build_themes.js index d1b255b72..ca847f1d3 100644 --- a/scripts/build_themes.js +++ b/scripts/build_themes.js @@ -2,7 +2,7 @@ const esbuild = require("esbuild"); const fs = require("fs"); -const watch = process.argv.slice(2).includes("--watch"); +const watch = process.argv.slice(2).some((t) => t == "--watch" || t == "-w"); // It's convenient to be able to build the themes in watch mode without rebuilding the whole docs // to test some change to the frontend JS. diff --git a/src/lib/output/themes/default/assets/typedoc/Navigation.ts b/src/lib/output/themes/default/assets/typedoc/Navigation.ts index 5c6a4f682..a5e15435b 100644 --- a/src/lib/output/themes/default/assets/typedoc/Navigation.ts +++ b/src/lib/output/themes/default/assets/typedoc/Navigation.ts @@ -103,7 +103,8 @@ function addNavText( } a.appendChild(document.createElement("span")).textContent = el.text; } else { - parent.appendChild(document.createElement("span")).textContent = - el.text; + const span = parent.appendChild(document.createElement("span")); + span.innerHTML = ``; + span.appendChild(document.createElement("span")).textContent = el.text; } } diff --git a/src/lib/output/themes/default/partials/icon.tsx b/src/lib/output/themes/default/partials/icon.tsx index b50eddeeb..8c242de37 100644 --- a/src/lib/output/themes/default/partials/icon.tsx +++ b/src/lib/output/themes/default/partials/icon.tsx @@ -47,7 +47,7 @@ export function buildRefIcons JSX.Element>>( } export const icons: Record< - ReflectionKind | "chevronDown" | "checkbox" | "menu" | "search" | "chevronSmall" | "anchor", + ReflectionKind | "chevronDown" | "checkbox" | "menu" | "search" | "chevronSmall" | "anchor" | "folder", () => JSX.Element > = { [ReflectionKind.Accessor]: () => @@ -186,14 +186,21 @@ export const icons: Record< ), [ReflectionKind.Document]: () => kindIcon( - - - + + + , "var(--color-document)", ), + folder: () => + kindIcon( + + + , + "var(--color-document)", + ), chevronDown: () => (