From 0a06c60cb71c7a3d4af3c3ad9fd952aaf9988579 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 3 Jul 2025 23:27:02 +0300 Subject: [PATCH 01/15] client/context menus: add support to display badges for menu items --- apps/client/src/menus/context_menu.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/client/src/menus/context_menu.ts b/apps/client/src/menus/context_menu.ts index 72519233a..f343c6c0a 100644 --- a/apps/client/src/menus/context_menu.ts +++ b/apps/client/src/menus/context_menu.ts @@ -17,11 +17,17 @@ interface MenuSeparatorItem { title: "----"; } +interface MenuItemBadge { + title: string; + className?: string; +} + export interface MenuCommandItem { title: string; command?: T; type?: string; uiIcon?: string; + badges?: MenuItemBadge[]; templateNoteId?: string; enabled?: boolean; handler?: MenuHandler; @@ -157,6 +163,18 @@ class ContextMenu { .append("   ") // some space between icon and text .append(item.title); + if ("badges" in item && item.badges) { + for (let badge of item.badges) { + const badgeElement = $(``).text(badge.title); + + if (badge.className) { + badgeElement.addClass(badge.className); + } + + $link.append(badgeElement); + } + } + if ("shortcut" in item && item.shortcut) { $link.append($("").text(item.shortcut)); } From 88d1af7210c77178a1b778f36c82db3302b32bee Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Fri, 4 Jul 2025 11:33:29 +0300 Subject: [PATCH 02/15] style/refactor: make the current badge style to be global --- apps/client/src/stylesheets/style.css | 9 +++++++++ apps/client/src/widgets/note_type.ts | 7 ------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css index 0bf0588b0..ecff3636e 100644 --- a/apps/client/src/stylesheets/style.css +++ b/apps/client/src/stylesheets/style.css @@ -26,6 +26,10 @@ --bs-body-color: var(--main-text-color) !important; --bs-body-bg: var(--main-background-color) !important; --ck-mention-list-max-height: 500px; + + --tn-bs-badge-background: var(--accented-background-color); + --bs-badge-color: var(--menu-text-color); + --bs-badge-font-weight: normal; } .table { @@ -192,6 +196,11 @@ samp { font-family: var(--monospace-font-family) !important; } +.badge { + margin-left: 8px; + background: var(--tn-bs-badge-background); +} + .input-group-text { background-color: var(--accented-background-color) !important; color: var(--muted-text-color) !important; diff --git a/apps/client/src/widgets/note_type.ts b/apps/client/src/widgets/note_type.ts index 055cdf565..747e4c3f9 100644 --- a/apps/client/src/widgets/note_type.ts +++ b/apps/client/src/widgets/note_type.ts @@ -63,13 +63,6 @@ const TPL = /*html*/` overflow-y: auto; overflow-x: hidden; } - - .note-type-dropdown .badge { - margin-left: 8px; - background: var(--accented-background-color); - font-weight: normal; - color: var(--menu-text-color); - }