From a2f39c4f993e9cf979569fb38fef61c4268b5bfd Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 2 Dec 2024 23:30:52 +0200 Subject: [PATCH] feat(tab): trigger note icons via theme variable --- src/public/app/widgets/tab_row.js | 24 +++++++++++++++++++----- src/public/stylesheets/theme-next.css | 5 ++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index e1d439d75..35b67cca1 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -243,6 +243,9 @@ const TAB_ROW_TPL = ` export default class TabRowWidget extends BasicWidget { doRender() { this.$widget = $(TAB_ROW_TPL); + + const documentStyle = window.getComputedStyle(document.documentElement); + this.showNoteIcons = (documentStyle.getPropertyValue("--tab-note-icons") === "true"); this.draggabillies = []; @@ -667,11 +670,16 @@ export default class TabRowWidget extends BasicWidget { } } + let noteIcon = ""; + if (noteContext) { const hoistedNote = froca.getNoteFromCache(noteContext.hoistedNoteId); - if (hoistedNote) { + if (hoistedNote) { $tab.find('.note-tab-wrapper').css("background", hoistedNote.getWorkspaceTabBackgroundColor()); + if (!this.showNoteIcons) { + noteIcon = hoistedNote.getWorkspaceIconClass(); + } } else { $tab.find('.note-tab-wrapper').removeAttr("style"); @@ -692,10 +700,16 @@ export default class TabRowWidget extends BasicWidget { $tab.addClass(utils.getNoteTypeClass(note.type)); $tab.addClass(utils.getMimeTypeClass(note.mime)); - $tab.find('.note-tab-icon') - .removeClass() - .addClass("note-tab-icon") - .addClass(note.getIcon()); + if (this.showNoteIcons) { + noteIcon = note.getIcon(); + } + + if (noteIcon) { + $tab.find('.note-tab-icon') + .removeClass() + .addClass("note-tab-icon") + .addClass(noteIcon); + } } async entitiesReloadedEvent({loadResults}) { diff --git a/src/public/stylesheets/theme-next.css b/src/public/stylesheets/theme-next.css index 1e225dd15..1880d024c 100644 --- a/src/public/stylesheets/theme-next.css +++ b/src/public/stylesheets/theme-next.css @@ -55,6 +55,9 @@ --menu-item-icon-vert-offset: 0; --more-accented-background-color: var(--card-background-hover-color); + + /* Theme capabilities */ + --tab-note-icons: true; } /* @@ -172,7 +175,7 @@ --scrollbar-background-color: #ddd; --link-color: blue; - --mermaid-theme: default; + --mermaid-theme: default; --code-block-box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1), 0px 0px 2px rgba(0, 0, 0, 0.2);