Skip to content

Build your personal knowledge base with Trilium Notes

style(autocomplete): share the suggestion list metrics across themes

Elian Doran82b12723da89
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index e73054a6fc..071b907934 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -1297,7 +1297,7 @@ body.mobile .modal-content-with-sidebar > .modal-main > .modal-header > .modal-t
.ck-mentions .ck-button {
font-size: var(--detail-font-size) !important;
- padding: 5px;
+ padding: var(--suggestion-item-padding-block) var(--suggestion-item-padding-inline);
}
.ck-mentions .ck-button b {
@@ -1305,9 +1305,9 @@ body.mobile .modal-content-with-sidebar > .modal-main > .modal-header > .modal-t
}
.ck-mentions {
- --ck-color-list-button-on-background: var(--active-item-background-color);
+ --ck-color-list-button-on-background: var(--suggestion-active-background-color);
--ck-color-list-button-on-background-focus: var(--ck-color-list-button-on-background);
- --ck-color-list-button-on-text: var(--active-item-text-color);
+ --ck-color-list-button-on-text: var(--suggestion-active-text-color);
}
.ck-mentions .ck-button b {
diff --git a/apps/client/src/stylesheets/theme-light.css b/apps/client/src/stylesheets/theme-light.css
index f421827d41..7e46e847c3 100644
--- a/apps/client/src/stylesheets/theme-light.css
+++ b/apps/client/src/stylesheets/theme-light.css
@@ -52,6 +52,14 @@ html {
--active-item-background-color: #ddd;
--active-item-border-color: transparent;
+ /* The highlighted row, the row padding and the list padding of every suggestion list: the
+ text editor's mentions, the search completions and `FormAutocomplete`. */
+ --suggestion-active-text-color: var(--active-item-text-color);
+ --suggestion-active-background-color: var(--active-item-background-color);
+ --suggestion-item-padding-block: 5px;
+ --suggestion-item-padding-inline: 5px;
+ --suggestion-list-padding: 6px;
+
--menu-text-color: black;
--menu-background-color: white;
diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.css
index 7bf220fb72..1f0b6f64ec 100644
--- a/apps/client/src/stylesheets/theme-next/base.css
+++ b/apps/client/src/stylesheets/theme-next/base.css
@@ -22,6 +22,13 @@
:root {
color-scheme: var(--theme-style);
+ --suggestion-active-text-color: var(--hover-item-text-color);
+ --suggestion-active-background-color: var(--hover-item-background-color);
+ /* Match `ul.ck.ck-list button.ck-button` and `--ck-editor-popup-padding` in `notes/text.css`. */
+ --suggestion-item-padding-block: 2px;
+ --suggestion-item-padding-inline: 16px;
+ --suggestion-list-padding: 4px;
+
--main-font-family: "Inter", sans-serif;
--main-font-size: normal;
diff --git a/apps/client/src/stylesheets/theme-next/notes/text.css b/apps/client/src/stylesheets/theme-next/notes/text.css
index f3303e5417..93901c3799 100644
--- a/apps/client/src/stylesheets/theme-next/notes/text.css
+++ b/apps/client/src/stylesheets/theme-next/notes/text.css
@@ -551,8 +551,6 @@ div.ck-template-form .ck-search__info span:nth-child(2) {
/* Mention list (the autocompletion list for emojis, labels and relations) */
:root .ck-mentions {
- --ck-color-list-button-on-background: var(--hover-item-background-color);
- --ck-color-list-button-on-text: var(--hover-item-text-color);
--ck-color-list-button-hover-background: var(--ck-editor-toolbar-dropdown-button-open-background);
--ck-focus-ring: 1px solid transparent;
}
diff --git a/apps/client/src/stylesheets/theme-next/ribbon.css b/apps/client/src/stylesheets/theme-next/ribbon.css
index bb37cd827a..ffba0fcac9 100644
--- a/apps/client/src/stylesheets/theme-next/ribbon.css
+++ b/apps/client/src/stylesheets/theme-next/ribbon.css
@@ -172,14 +172,3 @@ ul.editability-dropdown li.dropdown-item > div {
.note-info-widget {
container: info-section / inline-size;
}
-
-/*
- * Search string
- */
-
-/* The completion popup's selected row uses the hover colours from
- `:root .ck-mentions` in `notes/text.css` rather than the active colours. */
-.search-string-editor {
- --search-completion-selected-background: var(--hover-item-background-color);
- --search-completion-selected-text: var(--hover-item-text-color);
-}
diff --git a/apps/client/src/widgets/react/FormAutocomplete.css b/apps/client/src/widgets/react/FormAutocomplete.css
index 44029a3a41..8e3c656e02 100644
--- a/apps/client/src/widgets/react/FormAutocomplete.css
+++ b/apps/client/src/widgets/react/FormAutocomplete.css
@@ -7,8 +7,8 @@
/*
* The suggestion list, dressed as one of the application's menus — the same metrics the mention list
* in a text note is given, since both are a list of choices floating over the thing being edited.
- * Every variable below is defined by each theme; the two the older themes leave out (the inner
- * padding and the corner radius) fall back to the values those themes use for their own menus.
+ * Every variable below is defined by each theme; the corner radius, which the older themes leave
+ * out, falls back to the value those themes use for their own menus.
*/
.form-autocomplete-dropdown {
position: fixed;
@@ -16,7 +16,7 @@
margin: 0;
/* The entries sit inside the rounded border rather than against it, so a highlighted one is a
rounded chip within the menu instead of a band across it. */
- padding: var(--menu-padding-size, 6px);
+ padding: var(--suggestion-list-padding);
list-style: none;
overflow-y: auto;
font-size: 0.9rem;
@@ -31,7 +31,7 @@
.form-autocomplete-dropdown .form-autocomplete-item {
cursor: pointer;
- padding: 4px 8px;
+ padding: var(--suggestion-item-padding-block) var(--suggestion-item-padding-inline);
margin: 0;
border-radius: 6px;
white-space: nowrap;
@@ -41,13 +41,13 @@
/* Pointer and keyboard share the one highlight: hovering an entry makes it the active one. */
.form-autocomplete-dropdown .form-autocomplete-item.active {
- color: var(--active-item-text-color);
- background-color: var(--active-item-background-color);
+ color: var(--suggestion-active-text-color);
+ background-color: var(--suggestion-active-background-color);
}
/* A heading over the entries below it, not one of them (see `isHeading`). */
.form-autocomplete-dropdown .form-autocomplete-heading {
- padding: 8px 8px 2px;
+ padding: 8px var(--suggestion-item-padding-inline) 2px;
font-size: 0.8em;
font-weight: 600;
text-transform: uppercase;
diff --git a/apps/client/src/widgets/search_field_editor.css b/apps/client/src/widgets/search_field_editor.css
index 85975883dd..167060009e 100644
--- a/apps/client/src/widgets/search_field_editor.css
+++ b/apps/client/src/widgets/search_field_editor.css
@@ -1,9 +1,4 @@
.search-string-editor {
- /* The mention autocomplete's colours. The Next theme swaps in the hover pair from
- `theme-next/ribbon.css`; the legacy themes define those as transparent. */
- --search-completion-selected-background: var(--active-item-background-color, color-mix(in srgb, var(--main-text-color) 15%, transparent));
- --search-completion-selected-text: var(--active-item-text-color, inherit);
-
.cm-editor {
background: transparent;
max-height: 12em;
@@ -48,7 +43,7 @@
border-radius: var(--dropdown-border-radius, var(--bs-border-radius));
box-shadow: 0 5px 10px rgba(0, 0, 0, var(--dropdown-shadow-opacity, 0.2));
overflow: hidden;
- padding: 4px;
+ padding: var(--suggestion-list-padding);
/* CodeMirror sets monospace on the popup; the field itself is in the UI font. */
& > ul {
@@ -56,13 +51,12 @@
max-height: 18em;
}
- /* A mention row's metrics: `ul.ck.ck-list button.ck-button` in the Next theme, over the
- 1.84/13px line CKEditor gives `.ck-button__label`. 28px bare, 46px with a description. */
+ /* A mention row's metrics, over the 1.84/13px line CKEditor gives `.ck-button__label`. */
& > ul > li {
display: flex;
flex-wrap: wrap;
align-items: center;
- padding: 2px 16px;
+ padding: var(--suggestion-item-padding-block) var(--suggestion-item-padding-inline);
border-radius: 6px;
line-height: calc(1.84 * 13px);
}
@@ -84,8 +78,8 @@
}
& > ul > li[aria-selected] {
- background: var(--search-completion-selected-background);
- color: var(--search-completion-selected-text);
+ background: var(--suggestion-active-background-color);
+ color: var(--suggestion-active-text-color);
}
}