Skip to content

Build your personal knowledge base with Trilium Notes

style(client): draw tooltips from one component stylesheet, on shared pages too

Elian Doran0feed43a07d6
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 32cf9dc1f6..9c6e41dd51 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -757,27 +757,6 @@ table.promoted-attributes-in-tooltip th {
padding: 10px;
}
-.tooltip {
- font-size: var(--main-font-size) !important;
- /* Above every layer the app opens over the page: a tooltip is appended to `<body>`, so it
- competes with a dialog in the root stacking context rather than painting inside it, and any
- lower layer leaves it unreadable behind the very dialog it was asked for. Bootstrap's modal
- sits at 1055, the dialogs the app lifts itself at up to 3000, the context menu at 2500.
-
- This layer used to be chained to CKEditor's own — `calc(var(--ck-z-panel) - 1)` — which
- `ckeditor-theme.css` raised to 10000 for exactly this reason, landing tooltips at 9999.
- Upstream renamed the variable (`--ck-z-modal` → `--ck-z-panel`) and the override went dead
- with the old name, dropping tooltips to 999 — under every dialog. Nothing showed it because
- the math form's rescue rule named a bare `[role="tooltip"]`, lifting every tooltip in the app
- to 3000; keeping that rule to MathLive's own UI is what finally uncovered it. Stated here in
- full, and no longer read from a variable another package owns. */
- z-index: 9999 !important;
-}
-
-.tooltip.tooltip-top {
- z-index: 32767 !important;
-}
-
/* Note tooltips are appended to <body> and are frequently triggered from inside a dialog (a link,
a deleted-note entry), including the few that lift themselves above the base tooltip layer — the
content manager's active-content overlay among them. Held at the same "above everything" layer
@@ -889,18 +868,6 @@ table.promoted-attributes-in-tooltip th {
display: none;
}
-.tooltip-inner {
- padding: 15px;
- background-color: var(--tooltip-background-color) !important;
- border: 1px solid var(--main-border-color);
- border-radius: 5px;
- text-align: start;
- color: var(--main-text-color) !important;
- max-width: 500px;
- white-space: pre-line;
- box-shadow: 10px 10px 93px -25px #aaaaaa;
-}
-
.tooltip-inner p:last-of-type {
margin-bottom: 0;
}
@@ -958,10 +925,6 @@ table.promoted-attributes-in-tooltip th {
float: inline-end;
}
-.tooltip.show {
- opacity: 1;
-}
-
.help-button,
.custom-title-bar-button {
float: inline-end;
diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.css
index 1d7334356d..4fc252bb21 100644
--- a/apps/client/src/stylesheets/theme-next/base.css
+++ b/apps/client/src/stylesheets/theme-next/base.css
@@ -125,6 +125,8 @@
2px 2px 8px var(--tooltip-shadow-color);
--tooltip-backdrop-filter: blur(5px);
--tooltip-font-size: 0.9rem;
+ --tooltip-border: none;
+ --tooltip-arrow-display: none;
--note-tooltip-box-shadow: 10px 10px 93px -25px var(--tool-dialog-shadow-color);
}
diff --git a/apps/client/src/stylesheets/theme-next/shell.css b/apps/client/src/stylesheets/theme-next/shell.css
index 9e8fc9e3c6..ffa2e48cd0 100644
--- a/apps/client/src/stylesheets/theme-next/shell.css
+++ b/apps/client/src/stylesheets/theme-next/shell.css
@@ -368,20 +368,6 @@ body.layout-horizontal > .horizontal {
--hover-item-background-color: transparent;
}
-.tooltip .tooltip-arrow {
- display: none;
-}
-
-.tooltip .tooltip-inner {
- padding: var(--tooltip-padding) !important;
- box-shadow: var(--tooltip-box-shadow) !important;
- border: unset !important;
- border-radius: var(--tooltip-border-radius);
- backdrop-filter: var(--tooltip-backdrop-filter);
- font-size: var(--tooltip-font-size);
- color: var(--tooltip-foreground-color) !important;
-}
-
/*
* Calendar
*/
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 88131f06e3..06e26f07af 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -1,3 +1,5 @@
+import "./tooltip.css";
+
import type { CKTextEditor } from "@triliumnext/ckeditor5";
import { FilterLabelsByType, HighlightedTokenInfo, KeyboardActionNames, NoteType, OptionNames, RelationNames } from "@triliumnext/commons";
import { Tooltip } from "bootstrap";
diff --git a/apps/client/src/widgets/react/tooltip.css b/apps/client/src/widgets/react/tooltip.css
new file mode 100644
index 0000000000..b32f98ed5e
--- /dev/null
+++ b/apps/client/src/widgets/react/tooltip.css
@@ -0,0 +1,32 @@
+.tooltip {
+ /* A tooltip is appended to `<body>`, so it competes with dialogs in the root stacking context:
+ Bootstrap's modal is at 1055, the app's dialogs up to 3000 and the context menu at 2500. */
+ z-index: 9999 !important;
+ font-size: var(--main-font-size) !important;
+
+ &.show {
+ opacity: 1;
+ }
+
+ &.tooltip-top {
+ z-index: 32767 !important;
+ }
+
+ .tooltip-arrow {
+ display: var(--tooltip-arrow-display, block);
+ }
+}
+
+.tooltip-inner {
+ max-width: 500px;
+ padding: var(--tooltip-padding, 15px) !important;
+ border: var(--tooltip-border, 1px solid var(--main-border-color)) !important;
+ border-radius: var(--tooltip-border-radius, 5px);
+ box-shadow: var(--tooltip-box-shadow, 10px 10px 93px -25px #aaaaaa) !important;
+ backdrop-filter: var(--tooltip-backdrop-filter, none);
+ background-color: var(--tooltip-background-color) !important;
+ color: var(--tooltip-foreground-color, var(--main-text-color)) !important;
+ font-size: var(--tooltip-font-size, inherit);
+ text-align: start;
+ white-space: pre-line;
+}
diff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mts
index 1e29b44bfb..4f47f9bfee 100644
--- a/apps/client/vite.config.mts
+++ b/apps/client/vite.config.mts
@@ -66,7 +66,11 @@ export default defineConfig(() => ({
},
css: {
transformer: 'lightningcss',
- devSourcemap: isDev
+ devSourcemap: isDev,
+ preprocessorOptions: {
+ // The share theme builds Bootstrap's tooltips from its partials, which only `@import` loads.
+ scss: { silenceDeprecations: [ "import" ], quietDeps: true }
+ }
},
server: {
watch: {
diff --git a/packages/share-theme/src/base.css b/packages/share-theme/src/base.css
index cbb36f30c0..02f37fd6e8 100644
--- a/packages/share-theme/src/base.css
+++ b/packages/share-theme/src/base.css
@@ -58,6 +58,7 @@ html.theme-light {
--main-border-color: #dbdbdb;
--tooltip-background-color: rgba(0, 0, 0, 0.818);
--tooltip-foreground-color: #ffffffeb;
+ --tooltip-shadow-color: rgba(0, 0, 0, 0.2);
--muted-text-color: #666;
--card-background-color: #0000000d;
--card-background-hover-color: #0000001c;
@@ -129,6 +130,7 @@ html.theme-dark {
--main-border-color: #454545;
--tooltip-background-color: rgba(67, 67, 67, 0.86);
--tooltip-foreground-color: #ffffffeb;
+ --tooltip-shadow-color: rgba(0, 0, 0, 0.4);
--muted-text-color: #bbb;
--card-background-color: #ffffff12;
--card-background-hover-color: #ffffff20;
@@ -165,6 +167,14 @@ html.theme-dark {
--main-text-color: var(--text-primary);
/* The frosting of `theme-next/shell.css` behind the translucent menus. */
--dropdown-backdrop-filter: blur(20px) saturate(6);
+ /* The tooltips of `theme-next/base.css`, which the app's `tooltip.css` draws from. */
+ --tooltip-border-radius: 6px;
+ --tooltip-padding: 2px 8px 4px 8px;
+ --tooltip-box-shadow: -1px -1px 2px var(--tooltip-shadow-color), 2px 2px 8px var(--tooltip-shadow-color);
+ --tooltip-backdrop-filter: blur(5px);
+ --tooltip-font-size: 0.9rem;
+ --tooltip-border: none;
+ --tooltip-arrow-display: none;
/* 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 77b6363237..06ca4d4790 100644
--- a/packages/share-theme/src/content/app_globals.ts
+++ b/packages/share-theme/src/content/app_globals.ts
@@ -1,3 +1,6 @@
+// Ahead of the views' own stylesheets, which draw the bubble over Bootstrap's tooltip.
+import "./tooltip.scss";
+
import $ from "jquery";
Object.assign(window, { $, jQuery: $ });
diff --git a/packages/share-theme/src/content/tooltip.scss b/packages/share-theme/src/content/tooltip.scss
new file mode 100644
index 0000000000..9b81cae614
--- /dev/null
+++ b/packages/share-theme/src/content/tooltip.scss
@@ -0,0 +1,8 @@
+// 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";