Skip to content

Build your personal knowledge base with Trilium Notes

style(share): draw the app views' context menus as the app does

Elian Doran5401080cd865
diff --git a/apps/client/src/stylesheets/menus.css b/apps/client/src/stylesheets/menus.css
new file mode 100644
index 0000000000..f337dd60ff
--- /dev/null
+++ b/apps/client/src/stylesheets/menus.css
@@ -0,0 +1,240 @@
+.dropdown-divider {
+ border-color: var(--dropdown-border-color);
+}
+
+@keyframes dropdown-menu-opening {
+ from {
+ opacity: 0;
+ }
+ to {
+ opacity: 1;
+ }
+}
+
+.dropdown-menu,
+.tabulator-popup-container,
+:root .excalidraw .popover {
+ color: var(--menu-text-color) !important;
+ font-size: inherit;
+ background: var(--menu-background-color) !important;
+ user-select: none;
+ -webkit-user-select: none;
+ --bs-dropdown-zindex: 999;
+ --bs-dropdown-link-active-bg: var(--active-item-background-color) !important;
+}
+
+/* Only carries the dropdown's classes to the menu, for the CSS scoped under them, so it takes no
+ part in the page's layout. */
+.tn-dropdown-portal {
+ display: contents;
+}
+
+/* Just under its popup, whose z-index (1200) is set in `Popup.css`. Styled as a dialog's
+ backdrop. */
+body > .tn-dropdown-portal > .tn-dropdown-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 1199;
+ background-color: var(--modal-backdrop-color);
+ opacity: var(--bs-backdrop-opacity, 0.5);
+}
+
+body.desktop .dropdown-menu,
+body.desktop .tabulator-popup-container,
+:root .excalidraw .dropdown-menu .dropdown-menu-container,
+:root .excalidraw .popover {
+ border: 1px solid var(--dropdown-border-color);
+ box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
+ animation: dropdown-menu-opening 100ms ease-in;
+}
+
+@supports (animation-fill-mode: forwards) {
+ /* Delay the opening of submenus */
+ body.desktop:not(.motion-disabled) .dropdown-submenu .dropdown-menu {
+ opacity: 0;
+ animation-fill-mode: forwards;
+ animation-delay: var(--submenu-opening-delay);
+ }
+}
+
+.dropdown-menu.static {
+ box-shadow: unset;
+ backdrop-filter: unset !important;
+}
+
+.dropend .dropdown-toggle::after {
+ margin-inline-start: 0.5em;
+ color: var(--muted-text-color);
+}
+
+.dropdown-menu .disabled {
+ color: #888 !important;
+ pointer-events: none;
+}
+
+.dropdown-menu .disabled .contextual-help {
+ pointer-events: all;
+ margin-inline-start: 8px;
+ font-size: 0.75rem;
+ color: var(--contextual-help-icon-color);
+ cursor: help;
+ opacity: 0.75;
+}
+
+.dropdown-menu .disabled .contextual-help:hover {
+ opacity: 1;
+}
+
+.dropdown-item:hover:not(.disabled, .active, .dropdown-container-item),
+.tabulator-menu-item:hover,
+:root .excalidraw .context-menu .context-menu-item:hover {
+ color: var(--hover-item-text-color) !important;
+ background-color: var(--hover-item-background-color) !important;
+ border-color: var(--hover-item-border-color) !important;
+ cursor: pointer;
+}
+
+.dropdown-container-item,
+.dropdown-item.dropdown-container-item:hover,
+.dropdown-container-item:active {
+ background: transparent;
+ cursor: default;
+}
+
+.dropdown-menu a:not(.selected) .check {
+ visibility: hidden;
+}
+
+.dropdown-menu:not(#context-menu-container) .dropdown-item,
+body.desktop .dropdown-menu .dropdown-toggle,
+.dropdown-item > span:not([class]),
+body.mobile .dropdown-menu .dropdown-submenu > span {
+ display: flex;
+ align-items: center;
+}
+
+
+.dropdown-item span.keyboard-shortcut,
+.dropdown-item span.menu-trailing-icon,
+.dropdown-item *:not(.keyboard-shortcut) > kbd {
+ flex-grow: 1;
+ text-align: end;
+ padding-inline-start: 12px;
+}
+
+.dropdown-menu kbd {
+ color: var(--muted-text-color);
+ border: none;
+ background-color: transparent;
+ box-shadow: none;
+ padding-bottom: 0;
+ padding: 0;
+}
+
+.dropdown-item,
+.dropdown-header,
+:root .excalidraw .context-menu .context-menu-item:hover {
+ color: var(--menu-text-color) !important;
+ border: 1px solid transparent !important;
+}
+
+.dropdown-item.disabled,
+.dropdown-item.disabled kbd {
+ color: #aaa !important;
+}
+
+.dropdown-item.active,
+.dropdown-item:focus {
+ color: var(--active-item-text-color);
+ background-color: var(--active-item-background-color);
+ border-color: var(--active-item-border-color);
+ outline: none;
+}
+
+.dropdown-item .destructive-action-icon {
+ color: var(--dropdown-item-icon-destructive-color);
+}
+
+.dropdown-item .tn-icon.use-note-color {
+ --menu-item-icon-color: var(--custom-color);
+ color: var(--custom-color, inherit);
+}
+
+.dropdown-item > span:not([class]) {
+ width: 100%;
+}
+
+.dropdown-menu .note-color-picker {
+ padding: 4px 12px 8px 12px;
+}
+
+#context-menu-cover.show {
+ position: fixed;
+ top: 0;
+ inset-inline-start: 0;
+ inset-inline-end: 0;
+ bottom: 0;
+ z-index: 2500;
+ background: rgba(0, 0, 0, 0.1);
+}
+
+#context-menu-container {
+ max-height: 100vh;
+}
+
+body.mobile #context-menu-container.mobile-bottom-menu {
+ position: fixed !important;
+ inset-inline-start: 0 !important;
+ inset-inline-end: 0 !important;
+ bottom: 0 !important;
+ top: unset !important;
+ max-height: var(--tn-modal-max-height);
+ overflow-y: auto !important;
+ user-select: none;
+ -webkit-user-select: none;
+ padding-bottom: max(var(--safe-area-inset-bottom, env(safe-area-inset-bottom)), var(--padding, var(--menu-padding-size))) !important;
+}
+
+body.mobile .dropdown-menu {
+ position: fixed !important;
+ z-index: 3000 !important;
+}
+
+#context-menu-container,
+#context-menu-container .dropdown-menu,
+.tabulator-popup-container {
+ padding: 3px 0;
+ z-index: 2000;
+}
+
+#context-menu-container .dropdown-item,
+.tabulator-menu .tabulator-menu-item {
+ padding: 0 7px 0 10px;
+ cursor: pointer;
+ user-select: none;
+ -webkit-user-select: none;
+}
+
+/* What stands between a menu item's icon and its title. */
+.dropdown-item .tn-menu-gap {
+ flex: none;
+ width: 0.5em;
+}
+
+/* A name the user wrote, boxed by `menuName()`: clipped rather than widening the menu. */
+.dropdown-item .tn-menu-name {
+ display: block;
+ max-width: 300px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.dropdown-submenu {
+ position: relative;
+}
+
+body.desktop .dropdown-submenu > .dropdown-menu {
+ min-width: max-content;
+ max-width: 300px;
+}
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 9c6e41dd51..184f99eb40 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -1,5 +1,6 @@
@import "./boxicons-compat.css";
@import "./adaptive-colors.css";
+@import "./menus.css";
@font-face {
font-family: Montserrat;
@@ -421,176 +422,6 @@ button kbd {
display: none;
}
-.dropdown-divider {
- border-color: var(--dropdown-border-color);
-}
-
-@keyframes dropdown-menu-opening {
- from {
- opacity: 0;
- }
- to {
- opacity: 1;
- }
-}
-
-.dropdown-menu,
-.tabulator-popup-container,
-:root .excalidraw .popover {
- color: var(--menu-text-color) !important;
- font-size: inherit;
- background: var(--menu-background-color) !important;
- user-select: none;
- -webkit-user-select: none;
- --bs-dropdown-zindex: 999;
- --bs-dropdown-link-active-bg: var(--active-item-background-color) !important;
-}
-
-/* Only carries the dropdown's classes to the menu, for the CSS scoped under them, so it takes no
- part in the page's layout. */
-.tn-dropdown-portal {
- display: contents;
-}
-
-/* Just under its popup, whose z-index (1200) is set in `Popup.css`. Styled as a dialog's
- backdrop. */
-body > .tn-dropdown-portal > .tn-dropdown-backdrop {
- position: fixed;
- inset: 0;
- z-index: 1199;
- background-color: var(--modal-backdrop-color);
- opacity: var(--bs-backdrop-opacity, 0.5);
-}
-
-body.desktop .dropdown-menu,
-body.desktop .tabulator-popup-container,
-:root .excalidraw .dropdown-menu .dropdown-menu-container,
-:root .excalidraw .popover {
- border: 1px solid var(--dropdown-border-color);
- box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
- animation: dropdown-menu-opening 100ms ease-in;
-}
-
-@supports (animation-fill-mode: forwards) {
- /* Delay the opening of submenus */
- body.desktop:not(.motion-disabled) .dropdown-submenu .dropdown-menu {
- opacity: 0;
- animation-fill-mode: forwards;
- animation-delay: var(--submenu-opening-delay);
- }
-}
-
-.dropdown-menu.static {
- box-shadow: unset;
- backdrop-filter: unset !important;
-}
-
-.dropend .dropdown-toggle::after {
- margin-inline-start: 0.5em;
- color: var(--muted-text-color);
-}
-
-.dropdown-menu .disabled {
- color: #888 !important;
- pointer-events: none;
-}
-
-.dropdown-menu .disabled .contextual-help {
- pointer-events: all;
- margin-inline-start: 8px;
- font-size: 0.75rem;
- color: var(--contextual-help-icon-color);
- cursor: help;
- opacity: 0.75;
-}
-
-.dropdown-menu .disabled .contextual-help:hover {
- opacity: 1;
-}
-
-.dropdown-item:hover:not(.disabled, .active, .dropdown-container-item),
-.tabulator-menu-item:hover,
-:root .excalidraw .context-menu .context-menu-item:hover {
- color: var(--hover-item-text-color) !important;
- background-color: var(--hover-item-background-color) !important;
- border-color: var(--hover-item-border-color) !important;
- cursor: pointer;
-}
-
-.dropdown-container-item,
-.dropdown-item.dropdown-container-item:hover,
-.dropdown-container-item:active {
- background: transparent;
- cursor: default;
-}
-
-.dropdown-menu a:not(.selected) .check {
- visibility: hidden;
-}
-
-.dropdown-menu:not(#context-menu-container) .dropdown-item,
-body.desktop .dropdown-menu .dropdown-toggle,
-.dropdown-item > span:not([class]),
-body.mobile .dropdown-menu .dropdown-submenu > span {
- display: flex;
- align-items: center;
-}
-
-
-.dropdown-item span.keyboard-shortcut,
-.dropdown-item span.menu-trailing-icon,
-.dropdown-item *:not(.keyboard-shortcut) > kbd {
- flex-grow: 1;
- text-align: end;
- padding-inline-start: 12px;
-}
-
-.dropdown-menu kbd {
- color: var(--muted-text-color);
- border: none;
- background-color: transparent;
- box-shadow: none;
- padding-bottom: 0;
- padding: 0;
-}
-
-.dropdown-item,
-.dropdown-header,
-:root .excalidraw .context-menu .context-menu-item:hover {
- color: var(--menu-text-color) !important;
- border: 1px solid transparent !important;
-}
-
-.dropdown-item.disabled,
-.dropdown-item.disabled kbd {
- color: #aaa !important;
-}
-
-.dropdown-item.active,
-.dropdown-item:focus {
- color: var(--active-item-text-color);
- background-color: var(--active-item-background-color);
- border-color: var(--active-item-border-color);
- outline: none;
-}
-
-.dropdown-item .destructive-action-icon {
- color: var(--dropdown-item-icon-destructive-color);
-}
-
-.dropdown-item .tn-icon.use-note-color {
- --menu-item-icon-color: var(--custom-color);
- color: var(--custom-color, inherit);
-}
-
-.dropdown-item > span:not([class]) {
- width: 100%;
-}
-
-.dropdown-menu .note-color-picker {
- padding: 4px 12px 8px 12px;
-}
-
.cm-editor {
height: 100%;
outline: none !important;
@@ -1618,77 +1449,6 @@ body.mobile .modal-content-with-sidebar > .modal-main > .modal-header > .modal-t
display: none;
}
-#context-menu-cover.show {
- position: fixed;
- top: 0;
- inset-inline-start: 0;
- inset-inline-end: 0;
- bottom: 0;
- z-index: 2500;
- background: rgba(0, 0, 0, 0.1);
-}
-
-#context-menu-container {
- max-height: 100vh;
-}
-
-body.mobile #context-menu-container.mobile-bottom-menu {
- position: fixed !important;
- inset-inline-start: 0 !important;
- inset-inline-end: 0 !important;
- bottom: 0 !important;
- top: unset !important;
- max-height: var(--tn-modal-max-height);
- overflow-y: auto !important;
- user-select: none;
- -webkit-user-select: none;
- padding-bottom: max(var(--safe-area-inset-bottom, env(safe-area-inset-bottom)), var(--padding, var(--menu-padding-size))) !important;
-}
-
-body.mobile .dropdown-menu {
- position: fixed !important;
- z-index: 3000 !important;
-}
-
-#context-menu-container,
-#context-menu-container .dropdown-menu,
-.tabulator-popup-container {
- padding: 3px 0;
- z-index: 2000;
-}
-
-#context-menu-container .dropdown-item,
-.tabulator-menu .tabulator-menu-item {
- padding: 0 7px 0 10px;
- cursor: pointer;
- user-select: none;
- -webkit-user-select: none;
-}
-
-/* What stands between a menu item's icon and its title. */
-.dropdown-item .tn-menu-gap {
- flex: none;
- width: 0.5em;
-}
-
-/* A name the user wrote, boxed by `menuName()`: clipped rather than widening the menu. */
-.dropdown-item .tn-menu-name {
- display: block;
- max-width: 300px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.dropdown-submenu {
- position: relative;
-}
-
-body.desktop .dropdown-submenu > .dropdown-menu {
- min-width: max-content;
- max-width: 300px;
-}
-
.right-dropdown-widget {
flex-shrink: 0;
}
diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.css
index 4fc252bb21..b0b9c0f998 100644
--- a/apps/client/src/stylesheets/theme-next/base.css
+++ b/apps/client/src/stylesheets/theme-next/base.css
@@ -6,6 +6,7 @@
@import url(./notes/text.css);
@import url(./notes/canvas.css);
@import url(./notes/collections/table.css);
+@import url(./menus.css);
@font-face {
font-family: "Inter";
@@ -145,402 +146,6 @@ body.backdrop-effects-disabled {
--menu-background-color: var(--menu-background-color-no-backdrop);
}
-/*
- * MENUS
- *
- * Note: apply the "tn-dropdown-list" class for scrollable dropdown menus. Submenus are not
- * supported when this class is used.
- */
-
- .dropdown-menu:not(.static),
- :root .excalidraw .popover {
- border-radius: var(--dropdown-border-radius);
- padding: var(--padding, var(--menu-padding-size)) !important;
- font-size: 0.9rem !important;
-}
-
-.dropdown-menu.note-autocomplete-menu {
- --padding: var(--suggestion-list-padding);
-}
-
-/* Use this class for non-legacy menus */
-.dropdown-menu.tn-dropdown-menu {
- --menu-item-icon-vert-offset: 0;
- white-space-collapse: discard;
-}
-
-/* The row's own icon is spaced by the `.tn-menu-gap` beside it. */
-.dropdown-menu.tn-dropdown-menu .dropdown-item .tn-icon:not(.dropdown-item > span > :first-child, .menu-trailing-icon) {
- margin-inline-end: 6px;
-}
-
-body.desktop .dropdown-menu::before,
-:root .ck.ck-dropdown__panel::before,
-:root .excalidraw .popover::before {
- content: "";
- backdrop-filter: var(--dropdown-backdrop-filter);
- border-radius: var(--dropdown-border-radius);
- position: absolute;
- top: 0;
- inset-inline-start: 0;
- inset-inline-end: 0;
- bottom: 0;
- z-index: -1;
-}
-
-body.desktop .dropdown-menu.tn-dropdown-list {
- backdrop-filter: var(--dropdown-backdrop-filter);
-}
-
-body.desktop .dropdown-submenu .dropdown-menu::before {
- content: unset;
-}
-
-body.desktop .dropdown-menu.tn-dropdown-list::before {
- display: none;
-}
-
-body.desktop .dropdown-submenu .dropdown-menu {
- backdrop-filter: var(--dropdown-backdrop-filter);
- background: transparent;
-}
-
-/*
- * With background effects on, the Electron window is transparent, and that breaks the
- * list-style menus specifically: they carry `backdrop-filter` on the menu element itself
- * (a scrollable menu can't use the `::before` layer — the pseudo scrolls away with the
- * content), and an element that both filters and paints a translucent background gets
- * flattened into one render surface, which composites wrongly over window-transparent
- * regions — the background is lost with the filter and the menu renders see-through.
- * Regular menus survive because their filter is isolated on the background-less pseudo.
- * The blur also has nothing to sample there anyway: CSS can only blur web-painted pixels,
- * never the OS-composited material behind the window. So list menus fall back to the
- * opaque menu color, the same one used when backdrop effects are disabled.
- */
-body.background-effects .dropdown-menu.tn-dropdown-list {
- --menu-background-color: var(--menu-background-color-no-backdrop);
- backdrop-filter: none;
-}
-
-.dropdown-item,
-.excalidraw .context-menu .context-menu-item {
- --menu-item-start-padding: 8px;
- --menu-item-end-padding: 22px;
- --menu-item-vertical-padding: 2px;
-
- /* Note: the right padding should also accommodate the submenu arrow. */
- border-radius: 6px;
- cursor: default !important;
-}
-
-.dropdown-item:not(.dropdown-submenu),
-body.desktop .dropdown-item.dropdown-submenu .dropdown-toggle,
-.excalidraw .context-menu .context-menu-item {
- padding-top: var(--menu-item-vertical-padding) !important;
- padding-bottom: var(--menu-item-vertical-padding) !important;
- padding-inline-start: var(--menu-item-start-padding) !important;
- padding-inline-end: var(--menu-item-end-padding) !important;
-}
-
-.dropdown-item:not(.dropdown-submenu) span.menu-trailing-icon {
- margin-inline-end: calc(var(--menu-item-start-padding) - var(--menu-item-end-padding));
-}
-
-.dropdown-item.dropdown-submenu {
- padding: 0 !important;
-
- .dropdown-toggle {
- flex-grow: 1;
- }
-}
-
-:root .dropdown-item:focus-visible {
- outline: 2px solid var(--input-focus-outline-color) !important;
- background-color: transparent;
- color: unset;
-}
-
-:root .dropdown-item:active {
- background: unset;
-}
-
-body.mobile .dropdown-submenu {
- padding: 0 !important;
-}
-
-body.mobile .dropdown-item:not(:last-of-type):where(:not(.note-autocomplete-menu .dropdown-item)) {
- margin-bottom: 0.5em;
-}
-
-html body .dropdown-item.disabled,
-html body .dropdown-item[disabled] {
- color: var(--menu-text-color) !important;
- opacity: var(--menu-item-disabled-opacity);
-}
-
-.dropdown-item:not(.disabled) .destructive-action-icon,
-.dropdown-item:not(.disabled) .bx-trash {
- --menu-item-icon-color: var(--dropdown-item-icon-destructive-color);
-}
-/* Badges */
-:root .badge {
- --bs-badge-color: var(--badge-text-color);
- --bs-badge-font-weight: 500;
-
- background: var(--badge-background-color);
- text-transform: uppercase;
- letter-spacing: .2pt;
-}
-
-/* Menu item icon */
-.dropdown-item .tn-icon {
- translate: 0 var(--menu-item-icon-vert-offset);
- color: var(--menu-item-icon-color) !important;
- font-size: 1.1em;
-}
-
-/* Menu item keyboard shortcut */
-.dropdown-item kbd,
-.excalidraw .context-menu-item__shortcut {
- font-family: unset !important;
- font-size: unset !important;
- color: var(--menu-item-keyboard-shortcut-color) !important;
- padding-top: 0;
-}
-
-.dropdown-item span.keyboard-shortcut {
- color: var(--menu-item-keyboard-shortcut-color) !important;
- margin-inline-start: 16px;
-}
-
-.dropdown-divider,
-.excalidraw .context-menu hr {
- position: relative;
- border-color: transparent !important;
- overflow: visible;
-}
-
-.dropdown-divider::after,
-.excalidraw .context-menu hr::before {
- position: absolute;
- content: "";
- top: -1px;
- inset-inline-start: calc(0px - var(--padding, var(--menu-padding-size)));
- inset-inline-end: calc(0px - var(--padding, var(--menu-padding-size)));
- border-top: 1px solid var(--menu-item-delimiter-color);
-}
-
-/* Menu item arrow */
-body.mobile .dropdown-submenu .dropdown-toggle::after,
-body.desktop .dropdown-submenu .dropdown-toggle::after {
- content: "\ed3b" !important;
- position: absolute;
- display: flex !important;
- align-items: center;
- justify-content: center;
- top: 0;
- inset-inline-end: 0;
- margin: unset !important;
- border: unset !important;
- padding: 0 4px;
- font-family: boxicons;
- font-size: 1.2em;
- color: var(--menu-item-arrow-color) !important;
-}
-
-/* Right to left, the end side is the left, so the arrow points the other way. */
-body[dir=rtl] .dropdown-submenu .dropdown-toggle::after {
- content: "\ea4d" !important;
-}
-
-/* Menu item group heading */
-
-/* The heading body */
-.dropdown-menu h6,
-.excalidraw .dropdown-menu-container .dropdown-menu-group-title,
-.excalidraw .dropdown-menu-container div[data-testid="canvas-background-label"] {
- position: relative;
- background: transparent;
- padding: 1em 8px 14px 8px;
- text-transform: uppercase;
- font-size: 0.8em;
- letter-spacing: 1pt;
- color: var(--menu-item-group-header-color) !important;
-}
-
-/* The delimiter line */
-.dropdown-menu h6::before,
-.excalidraw .dropdown-menu-container .dropdown-menu-group-title::before,
-.excalidraw .dropdown-menu-container div[data-testid="canvas-background-label"]::before {
- content: "";
- position: absolute;
- bottom: 8px;
- inset-inline-start: calc(0px - var(--menu-padding-size));
- inset-inline-end: calc(0px - var(--menu-padding-size));
- border-top: 1px solid var(--menu-item-delimiter-color);
-}
-
-/* Static menus (used as a list, such as on the note revisions dialog) */
-body.desktop .dropdown-menu.static {
- box-shadow: unset;
- border-radius: 4px;
- border: unset;
- background-color: var(--card-background-color) !important;
- padding: var(--menu-padding-size) !important;
- user-select: none;
-}
-
-body.desktop .dropdown-menu.static .dropdown-item.active {
- --active-item-text-color: var(--menu-text-color);
-}
-
-/* #region Mobile tweaks for dropdown menus */
-body.mobile #context-menu-cover {
- transition: background-color 150ms ease-in;
-
- &.show {
- background: rgba(0, 0, 0, 0.32);
-
- /* A tablet's menus open beside what opened them, undimmed; the cover only takes the tap
- that closes them. */
- @media (min-width: 992px) {
- background: transparent;
- }
- }
-
- &.global-menu-cover {
- bottom: calc(var(--mobile-bottom-offset) + var(--launcher-pane-size));
-
- @media (min-width: 992px) {
- bottom: 0;
- }
- }
-}
-
-body.mobile .dropdown-menu.mobile-bottom-menu {
- border-radius: var(--dropdown-border-radius) var(--dropdown-border-radius) 0 0;
-}
-
-/* A list of suggestions keeps its desktop look, in place of the context menu's cards. */
-body.mobile .dropdown-menu.note-autocomplete-menu {
- /* Matches `body.desktop .dropdown-menu` in style.css. */
- border: 1px solid var(--dropdown-border-color);
- box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
- backdrop-filter: var(--dropdown-backdrop-filter);
- --padding: 6px;
- font-size: 0.95rem !important;
-
- .dropdown-item {
- --menu-item-vertical-padding: 7px;
- --menu-item-start-padding: 12px;
- --menu-item-end-padding: 12px;
- }
-}
-
-/* Pinned to the bottom like a sheet only in the phone layout; see style.css. */
-@media (max-width: 991px) {
- body.mobile .tn-dropdown-portal.global-menu .dropdown-menu {
- border-radius: var(--dropdown-border-radius) var(--dropdown-border-radius) 0 0;
- }
-}
-
-/* Beside its toggle in a tablet's wider mobile layout, wide enough for its rows to be tapped. */
-@media (min-width: 992px) {
- body.mobile .tn-popup.tn-menu {
- min-width: 260px;
- }
-
- /* Matches `body.desktop .dropdown-menu` in style.css. */
- body.mobile .tn-popup.dropdown-menu {
- box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
- }
-}
-
-body.mobile .dropdown-menu:where(:not(.note-autocomplete-menu)) {
- --dropdown-menu-padding-vertical: 0.7em;
- --dropdown-menu-padding-horizontal: 1em;
- --hover-item-background-color: var(--card-background-color);
- font-size: 1rem !important;
- backdrop-filter: var(--dropdown-backdrop-filter);
- position: relative;
-
- .dropdown-submenu .dropdown-toggle::after {
- bottom: 0;
- inset-inline-end: calc(var(--dropdown-menu-padding-horizontal) / 2);
- }
-
- .dropdown-item,
- .dropdown-custom-item {
- margin-bottom: 0;
- padding: var(--dropdown-menu-padding-vertical) var(--dropdown-menu-padding-horizontal) !important;
- background: var(--card-background-color);
- border-bottom: 1px solid var(--menu-item-delimiter-color) !important;
- border-radius: 0;
- }
-
- .dropdown-item:first-of-type,
- .dropdown-divider + .dropdown-item,
- .dropdown-custom-item:first-of-type,
- .dropdown-divider + .dropdown-custom-item {
- border-top-left-radius: 6px;
- border-top-right-radius: 6px;
- }
-
- .dropdown-item:last-of-type,
- .dropdown-item:has(+ .dropdown-divider),
- .dropdown-custom-item:last-of-type,
- .dropdown-custom-item:has(+ .dropdown-divider) {
- border-bottom-left-radius: 6px;
- border-bottom-right-radius: 6px;
- border-bottom: 0 !important;
- }
-
- .dropdown-divider {
- visibility: hidden;
- }
-
- .dropdown-custom-item:has(.note-color-picker) {
- overflow-x: auto;
- }
-
- .note-color-picker {
- padding: 0;
- width: fit-content;
-
- .color-cell {
- --color-picker-cell-size: 26px;
- flex-shrink: 0;
- }
- }
-}
-/* #endregion */
-
-body.desktop .dropdown-menu .dropdown-toggle::after {
- height: 100%;
-}
-
-
-
-/* Dropdown item button (used in zoom buttons in global menu) */
-
-li.dropdown-item a.dropdown-item-button {
- border: unset;
-}
-
-li.dropdown-item a.dropdown-item-button.tn-icon {
- color: var(--menu-text-color) !important;
-}
-
-li.dropdown-item a.dropdown-item-button:focus-visible {
- outline: 2px solid var(--input-focus-outline-color) !important;
-}
-
-:root .dropdown-menu .note-color-picker {
- padding: 4px 10px;
- --note-color-picker-clear-color-cell-background: var(--main-text-color);
- --note-color-picker-clear-color-cell-selection-outline-color: var(--main-text-color);
-}
-
/*
* TOASTS
*/
diff --git a/apps/client/src/stylesheets/theme-next/menus.css b/apps/client/src/stylesheets/theme-next/menus.css
new file mode 100644
index 0000000000..e4c07a5a31
--- /dev/null
+++ b/apps/client/src/stylesheets/theme-next/menus.css
@@ -0,0 +1,395 @@
+/*
+ * MENUS
+ *
+ * Note: apply the "tn-dropdown-list" class for scrollable dropdown menus. Submenus are not
+ * supported when this class is used.
+ */
+
+ .dropdown-menu:not(.static),
+ :root .excalidraw .popover {
+ border-radius: var(--dropdown-border-radius);
+ padding: var(--padding, var(--menu-padding-size)) !important;
+ font-size: 0.9rem !important;
+}
+
+.dropdown-menu.note-autocomplete-menu {
+ --padding: var(--suggestion-list-padding);
+}
+
+/* Use this class for non-legacy menus */
+.dropdown-menu.tn-dropdown-menu {
+ --menu-item-icon-vert-offset: 0;
+ white-space-collapse: discard;
+}
+
+/* The row's own icon is spaced by the `.tn-menu-gap` beside it. */
+.dropdown-menu.tn-dropdown-menu .dropdown-item .tn-icon:not(.dropdown-item > span > :first-child, .menu-trailing-icon) {
+ margin-inline-end: 6px;
+}
+
+body.desktop .dropdown-menu::before,
+:root .ck.ck-dropdown__panel::before,
+:root .excalidraw .popover::before {
+ content: "";
+ backdrop-filter: var(--dropdown-backdrop-filter);
+ border-radius: var(--dropdown-border-radius);
+ position: absolute;
+ top: 0;
+ inset-inline-start: 0;
+ inset-inline-end: 0;
+ bottom: 0;
+ z-index: -1;
+}
+
+body.desktop .dropdown-menu.tn-dropdown-list {
+ backdrop-filter: var(--dropdown-backdrop-filter);
+}
+
+body.desktop .dropdown-submenu .dropdown-menu::before {
+ content: unset;
+}
+
+body.desktop .dropdown-menu.tn-dropdown-list::before {
+ display: none;
+}
+
+body.desktop .dropdown-submenu .dropdown-menu {
+ backdrop-filter: var(--dropdown-backdrop-filter);
+ background: transparent;
+}
+
+/*
+ * With background effects on, the Electron window is transparent, and that breaks the
+ * list-style menus specifically: they carry `backdrop-filter` on the menu element itself
+ * (a scrollable menu can't use the `::before` layer — the pseudo scrolls away with the
+ * content), and an element that both filters and paints a translucent background gets
+ * flattened into one render surface, which composites wrongly over window-transparent
+ * regions — the background is lost with the filter and the menu renders see-through.
+ * Regular menus survive because their filter is isolated on the background-less pseudo.
+ * The blur also has nothing to sample there anyway: CSS can only blur web-painted pixels,
+ * never the OS-composited material behind the window. So list menus fall back to the
+ * opaque menu color, the same one used when backdrop effects are disabled.
+ */
+body.background-effects .dropdown-menu.tn-dropdown-list {
+ --menu-background-color: var(--menu-background-color-no-backdrop);
+ backdrop-filter: none;
+}
+
+.dropdown-item,
+.excalidraw .context-menu .context-menu-item {
+ --menu-item-start-padding: 8px;
+ --menu-item-end-padding: 22px;
+ --menu-item-vertical-padding: 2px;
+
+ /* Note: the right padding should also accommodate the submenu arrow. */
+ border-radius: 6px;
+ cursor: default !important;
+}
+
+.dropdown-item:not(.dropdown-submenu),
+body.desktop .dropdown-item.dropdown-submenu .dropdown-toggle,
+.excalidraw .context-menu .context-menu-item {
+ padding-top: var(--menu-item-vertical-padding) !important;
+ padding-bottom: var(--menu-item-vertical-padding) !important;
+ padding-inline-start: var(--menu-item-start-padding) !important;
+ padding-inline-end: var(--menu-item-end-padding) !important;
+}
+
+.dropdown-item:not(.dropdown-submenu) span.menu-trailing-icon {
+ margin-inline-end: calc(var(--menu-item-start-padding) - var(--menu-item-end-padding));
+}
+
+.dropdown-item.dropdown-submenu {
+ padding: 0 !important;
+
+ .dropdown-toggle {
+ flex-grow: 1;
+ }
+}
+
+:root .dropdown-item:focus-visible {
+ outline: 2px solid var(--input-focus-outline-color) !important;
+ background-color: transparent;
+ color: unset;
+}
+
+:root .dropdown-item:active {
+ background: unset;
+}
+
+body.mobile .dropdown-submenu {
+ padding: 0 !important;
+}
+
+body.mobile .dropdown-item:not(:last-of-type):where(:not(.note-autocomplete-menu .dropdown-item)) {
+ margin-bottom: 0.5em;
+}
+
+html body .dropdown-item.disabled,
+html body .dropdown-item[disabled] {
+ color: var(--menu-text-color) !important;
+ opacity: var(--menu-item-disabled-opacity);
+}
+
+.dropdown-item:not(.disabled) .destructive-action-icon,
+.dropdown-item:not(.disabled) .bx-trash {
+ --menu-item-icon-color: var(--dropdown-item-icon-destructive-color);
+}
+/* Badges */
+:root .badge {
+ --bs-badge-color: var(--badge-text-color);
+ --bs-badge-font-weight: 500;
+
+ background: var(--badge-background-color);
+ text-transform: uppercase;
+ letter-spacing: .2pt;
+}
+
+/* Menu item icon */
+.dropdown-item .tn-icon {
+ translate: 0 var(--menu-item-icon-vert-offset);
+ color: var(--menu-item-icon-color) !important;
+ font-size: 1.1em;
+}
+
+/* Menu item keyboard shortcut */
+.dropdown-item kbd,
+.excalidraw .context-menu-item__shortcut {
+ font-family: unset !important;
+ font-size: unset !important;
+ color: var(--menu-item-keyboard-shortcut-color) !important;
+ padding-top: 0;
+}
+
+.dropdown-item span.keyboard-shortcut {
+ color: var(--menu-item-keyboard-shortcut-color) !important;
+ margin-inline-start: 16px;
+}
+
+.dropdown-divider,
+.excalidraw .context-menu hr {
+ position: relative;
+ border-color: transparent !important;
+ overflow: visible;
+}
+
+.dropdown-divider::after,
+.excalidraw .context-menu hr::before {
+ position: absolute;
+ content: "";
+ top: -1px;
+ inset-inline-start: calc(0px - var(--padding, var(--menu-padding-size)));
+ inset-inline-end: calc(0px - var(--padding, var(--menu-padding-size)));
+ border-top: 1px solid var(--menu-item-delimiter-color);
+}
+
+/* Menu item arrow */
+body.mobile .dropdown-submenu .dropdown-toggle::after,
+body.desktop .dropdown-submenu .dropdown-toggle::after {
+ content: "\ed3b" !important;
+ position: absolute;
+ display: flex !important;
+ align-items: center;
+ justify-content: center;
+ top: 0;
+ inset-inline-end: 0;
+ margin: unset !important;
+ border: unset !important;
+ padding: 0 4px;
+ font-family: boxicons;
+ font-size: 1.2em;
+ color: var(--menu-item-arrow-color) !important;
+}
+
+/* Right to left, the end side is the left, so the arrow points the other way. */
+body[dir=rtl] .dropdown-submenu .dropdown-toggle::after {
+ content: "\ea4d" !important;
+}
+
+/* Menu item group heading */
+
+/* The heading body */
+.dropdown-menu h6,
+.excalidraw .dropdown-menu-container .dropdown-menu-group-title,
+.excalidraw .dropdown-menu-container div[data-testid="canvas-background-label"] {
+ position: relative;
+ background: transparent;
+ padding: 1em 8px 14px 8px;
+ text-transform: uppercase;
+ font-size: 0.8em;
+ letter-spacing: 1pt;
+ color: var(--menu-item-group-header-color) !important;
+}
+
+/* The delimiter line */
+.dropdown-menu h6::before,
+.excalidraw .dropdown-menu-container .dropdown-menu-group-title::before,
+.excalidraw .dropdown-menu-container div[data-testid="canvas-background-label"]::before {
+ content: "";
+ position: absolute;
+ bottom: 8px;
+ inset-inline-start: calc(0px - var(--menu-padding-size));
+ inset-inline-end: calc(0px - var(--menu-padding-size));
+ border-top: 1px solid var(--menu-item-delimiter-color);
+}
+
+/* Static menus (used as a list, such as on the note revisions dialog) */
+body.desktop .dropdown-menu.static {
+ box-shadow: unset;
+ border-radius: 4px;
+ border: unset;
+ background-color: var(--card-background-color) !important;
+ padding: var(--menu-padding-size) !important;
+ user-select: none;
+}
+
+body.desktop .dropdown-menu.static .dropdown-item.active {
+ --active-item-text-color: var(--menu-text-color);
+}
+
+/* #region Mobile tweaks for dropdown menus */
+body.mobile #context-menu-cover {
+ transition: background-color 150ms ease-in;
+
+ &.show {
+ background: rgba(0, 0, 0, 0.32);
+
+ /* A tablet's menus open beside what opened them, undimmed; the cover only takes the tap
+ that closes them. */
+ @media (min-width: 992px) {
+ background: transparent;
+ }
+ }
+
+ &.global-menu-cover {
+ bottom: calc(var(--mobile-bottom-offset) + var(--launcher-pane-size));
+
+ @media (min-width: 992px) {
+ bottom: 0;
+ }
+ }
+}
+
+body.mobile .dropdown-menu.mobile-bottom-menu {
+ border-radius: var(--dropdown-border-radius) var(--dropdown-border-radius) 0 0;
+}
+
+/* A list of suggestions keeps its desktop look, in place of the context menu's cards. */
+body.mobile .dropdown-menu.note-autocomplete-menu {
+ /* Matches `body.desktop .dropdown-menu` in style.css. */
+ border: 1px solid var(--dropdown-border-color);
+ box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
+ backdrop-filter: var(--dropdown-backdrop-filter);
+ --padding: 6px;
+ font-size: 0.95rem !important;
+
+ .dropdown-item {
+ --menu-item-vertical-padding: 7px;
+ --menu-item-start-padding: 12px;
+ --menu-item-end-padding: 12px;
+ }
+}
+
+/* Pinned to the bottom like a sheet only in the phone layout; see style.css. */
+@media (max-width: 991px) {
+ body.mobile .tn-dropdown-portal.global-menu .dropdown-menu {
+ border-radius: var(--dropdown-border-radius) var(--dropdown-border-radius) 0 0;
+ }
+}
+
+/* Beside its toggle in a tablet's wider mobile layout, wide enough for its rows to be tapped. */
+@media (min-width: 992px) {
+ body.mobile .tn-popup.tn-menu {
+ min-width: 260px;
+ }
+
+ /* Matches `body.desktop .dropdown-menu` in style.css. */
+ body.mobile .tn-popup.dropdown-menu {
+ box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
+ }
+}
+
+body.mobile .dropdown-menu:where(:not(.note-autocomplete-menu)) {
+ --dropdown-menu-padding-vertical: 0.7em;
+ --dropdown-menu-padding-horizontal: 1em;
+ --hover-item-background-color: var(--card-background-color);
+ font-size: 1rem !important;
+ backdrop-filter: var(--dropdown-backdrop-filter);
+ position: relative;
+
+ .dropdown-submenu .dropdown-toggle::after {
+ bottom: 0;
+ inset-inline-end: calc(var(--dropdown-menu-padding-horizontal) / 2);
+ }
+
+ .dropdown-item,
+ .dropdown-custom-item {
+ margin-bottom: 0;
+ padding: var(--dropdown-menu-padding-vertical) var(--dropdown-menu-padding-horizontal) !important;
+ background: var(--card-background-color);
+ border-bottom: 1px solid var(--menu-item-delimiter-color) !important;
+ border-radius: 0;
+ }
+
+ .dropdown-item:first-of-type,
+ .dropdown-divider + .dropdown-item,
+ .dropdown-custom-item:first-of-type,
+ .dropdown-divider + .dropdown-custom-item {
+ border-top-left-radius: 6px;
+ border-top-right-radius: 6px;
+ }
+
+ .dropdown-item:last-of-type,
+ .dropdown-item:has(+ .dropdown-divider),
+ .dropdown-custom-item:last-of-type,
+ .dropdown-custom-item:has(+ .dropdown-divider) {
+ border-bottom-left-radius: 6px;
+ border-bottom-right-radius: 6px;
+ border-bottom: 0 !important;
+ }
+
+ .dropdown-divider {
+ visibility: hidden;
+ }
+
+ .dropdown-custom-item:has(.note-color-picker) {
+ overflow-x: auto;
+ }
+
+ .note-color-picker {
+ padding: 0;
+ width: fit-content;
+
+ .color-cell {
+ --color-picker-cell-size: 26px;
+ flex-shrink: 0;
+ }
+ }
+}
+/* #endregion */
+
+body.desktop .dropdown-menu .dropdown-toggle::after {
+ height: 100%;
+}
+
+
+
+/* Dropdown item button (used in zoom buttons in global menu) */
+
+li.dropdown-item a.dropdown-item-button {
+ border: unset;
+}
+
+li.dropdown-item a.dropdown-item-button.tn-icon {
+ color: var(--menu-text-color) !important;
+}
+
+li.dropdown-item a.dropdown-item-button:focus-visible {
+ outline: 2px solid var(--input-focus-outline-color) !important;
+}
+
+:root .dropdown-menu .note-color-picker {
+ padding: 4px 10px;
+ --note-color-picker-clear-color-cell-background: var(--main-text-color);
+ --note-color-picker-clear-color-cell-selection-outline-color: var(--main-text-color);
+}
diff --git a/packages/share-theme/src/base.css b/packages/share-theme/src/base.css
index 02f37fd6e8..d5a64e43e1 100644
--- a/packages/share-theme/src/base.css
+++ b/packages/share-theme/src/base.css
@@ -59,6 +59,23 @@ html.theme-light {
--tooltip-background-color: rgba(0, 0, 0, 0.818);
--tooltip-foreground-color: #ffffffeb;
--tooltip-shadow-color: rgba(0, 0, 0, 0.2);
+ --dropdown-item-icon-destructive-color: #de4027;
+ --dropdown-shadow-opacity: 0.2;
+ --hover-item-background-color: #0000001a;
+ --hover-item-border-color: transparent;
+ --active-item-border-color: transparent;
+ --menu-background-color-no-backdrop: #fdfdfd;
+ --menu-item-arrow-color: #00000080;
+ --menu-item-delimiter-color: #00000030;
+ --menu-item-disabled-opacity: 0.6;
+ --menu-item-group-header-color: #00000061;
+ --menu-item-icon-color: #727272;
+ --menu-item-keyboard-shortcut-color: #666666a8;
+ --contextual-help-icon-color: #004382;
+ --badge-background-color: #00000011;
+ --badge-text-color: var(--muted-text-color);
+ --input-focus-outline-color: #00000063;
+ --modal-backdrop-color: #7c7c7c;
--muted-text-color: #666;
--card-background-color: #0000000d;
--card-background-hover-color: #0000001c;
@@ -131,6 +148,23 @@ html.theme-dark {
--tooltip-background-color: rgba(67, 67, 67, 0.86);
--tooltip-foreground-color: #ffffffeb;
--tooltip-shadow-color: rgba(0, 0, 0, 0.4);
+ --dropdown-item-icon-destructive-color: #d58477;
+ --dropdown-shadow-opacity: 0.6;
+ --hover-item-background-color: #ffffff16;
+ --hover-item-border-color: transparent;
+ --active-item-border-color: transparent;
+ --menu-background-color-no-backdrop: #1b1b1b;
+ --menu-item-arrow-color: #ffffffa3;
+ --menu-item-delimiter-color: #ffffff1c;
+ --menu-item-disabled-opacity: 0.5;
+ --menu-item-group-header-color: #ffffff91;
+ --menu-item-icon-color: #8c8c8c;
+ --menu-item-keyboard-shortcut-color: #ffffff8f;
+ --contextual-help-icon-color: #7fd2ef;
+ --badge-background-color: #ffffff1a;
+ --badge-text-color: var(--muted-text-color);
+ --input-focus-outline-color: #ffffff57;
+ --modal-backdrop-color: #000;
--muted-text-color: #bbb;
--card-background-color: #ffffff12;
--card-background-hover-color: #ffffff20;
@@ -175,6 +209,11 @@ html.theme-dark {
--tooltip-font-size: 0.9rem;
--tooltip-border: none;
--tooltip-arrow-display: none;
+ /* The menus of `theme-next/menus.css` and `style.css`, which the app's context menus draw from. */
+ --dropdown-border-radius: 10px;
+ --menu-padding-size: 8px;
+ --menu-item-icon-vert-offset: -2px;
+ --submenu-opening-delay: 150ms;
/* The frosting of `theme-next/base.css` behind the translucent overlay buttons. */
--overlay-button-backdrop-filter: blur(32px) saturate(1000%);
--opaque-icon-button-hover-color: var(--hover-item-text-color);
diff --git a/packages/share-theme/src/content/app_globals.ts b/packages/share-theme/src/content/app_globals.ts
index 06ca4d4790..e74c03bfe2 100644
--- a/packages/share-theme/src/content/app_globals.ts
+++ b/packages/share-theme/src/content/app_globals.ts
@@ -1,5 +1,7 @@
-// Ahead of the views' own stylesheets, which draw the bubble over Bootstrap's tooltip.
-import "./tooltip.scss";
+// Ahead of the views' own stylesheets, which draw over Bootstrap's tooltips and menus.
+import "./bootstrap.scss";
+import "@triliumnext/client/src/stylesheets/menus.css";
+import "@triliumnext/client/src/stylesheets/theme-next/menus.css";
import $ from "jquery";
diff --git a/packages/share-theme/src/content/app_view.ts b/packages/share-theme/src/content/app_view.ts
index dda853ada2..41a4b6c1c5 100644
--- a/packages/share-theme/src/content/app_view.ts
+++ b/packages/share-theme/src/content/app_view.ts
@@ -34,6 +34,9 @@ async function mountAppView(container: string, load: () => Promise<AppViewModule
}
const payload = JSON.parse(data.textContent) as AppPayload;
+ // The views behave as on desktop, `isMobile()` being false on a shared page, and the app's
+ // stylesheets draw them so from this class.
+ document.body.classList.add("desktop");
await import("./app_globals.js");
await import("@triliumnext/client/src/components/app_context.js");
diff --git a/packages/share-theme/src/content/bootstrap.scss b/packages/share-theme/src/content/bootstrap.scss
new file mode 100644
index 0000000000..38334a89f5
--- /dev/null
+++ b/packages/share-theme/src/content/bootstrap.scss
@@ -0,0 +1,9 @@
+// The parts of Bootstrap the app's views use on a shared page, a page that loads no Bootstrap
+// stylesheet: its tooltips and its dropdown menus, which the app's own stylesheets draw over.
+@import "bootstrap/scss/functions";
+@import "bootstrap/scss/variables";
+@import "bootstrap/scss/variables-dark";
+@import "bootstrap/scss/maps";
+@import "bootstrap/scss/mixins";
+@import "bootstrap/scss/tooltip";
+@import "bootstrap/scss/dropdown";
diff --git a/packages/share-theme/src/content/tooltip.scss b/packages/share-theme/src/content/tooltip.scss
deleted file mode 100644
index 9b81cae614..0000000000
--- a/packages/share-theme/src/content/tooltip.scss
+++ /dev/null
@@ -1,8 +0,0 @@
-// Bootstrap's tooltip, which the app's views open on a shared page, a page that loads no Bootstrap
-// stylesheet. The app's `tooltip.css` draws the bubble over it.
-@import "bootstrap/scss/functions";
-@import "bootstrap/scss/variables";
-@import "bootstrap/scss/variables-dark";
-@import "bootstrap/scss/maps";
-@import "bootstrap/scss/mixins";
-@import "bootstrap/scss/tooltip";