Skip to content

Build your personal knowledge base with Trilium Notes

style(autocomplete): move the note autocomplete's rules out of style.css

Elian Doran6b244204da65
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 01774642ea..c52c38a85d 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -775,24 +775,11 @@ pre > button.copy-button:active {
cursor: pointer;
}
-.show-recent-notes-button,
-.input-clearer-button,
-.go-to-selected-note-button {
- padding-top: 8px;
-}
-
-.show-recent-notes-button,
-.full-text-search-button {
- cursor: pointer;
- font-size: 1.3em;
- padding-inline-start: 5px;
- padding-inline-end: 5px;
-}
-
.input-clearer-button {
cursor: pointer;
font-size: 1.3em;
background: inherit !important;
+ padding-top: 8px;
padding-inline-start: 5px;
padding-inline-end: 5px;
}
@@ -805,26 +792,6 @@ pre > button.copy-button:active {
padding-top: 8px;
}
-.go-to-selected-note-button {
- cursor: pointer;
- font-size: 1.3em;
- padding-inline-start: 4px;
- padding-inline-end: 3px;
-}
-
-.go-to-selected-note-button.disabled,
-.go-to-selected-note-button.disabled:hover {
- cursor: inherit;
- color: var(--button-disabled-text-color) !important;
- background-color: var(--button-disabled-background-color) !important;
- text-decoration: none;
-}
-
-.note-autocomplete-input {
- /* this is for seamless integration of "input clearer" button */
- border-inline-end: 0;
-}
-
table.promoted-attributes-in-tooltip {
margin: auto;
}
@@ -1039,74 +1006,11 @@ table.promoted-attributes-in-tooltip th {
opacity: 1;
}
-.algolia-autocomplete {
- width: calc(100% - 30px);
- z-index: 2000 !important;
-}
-
.algolia-autocomplete-container .aa-dropdown-menu {
position: inherit !important;
overflow: auto;
}
-.algolia-autocomplete .aa-input,
-.algolia-autocomplete .aa-hint {
- width: 100%;
-}
-
-.algolia-autocomplete .aa-dropdown-menu {
- width: 100%;
- background-color: var(--main-background-color);
- border: 1px solid var(--main-border-color);
- border-top: none;
- z-index: 2000 !important;
- max-height: 500px;
- overflow: auto;
- padding: 0;
- margin: 0;
-}
-
-.aa-dropdown-menu .aa-suggestion {
- cursor: pointer;
- padding: 6px 16px;
- margin: 0;
-}
-
-.aa-dropdown-menu .aa-suggestion .icon {
- display: inline-block;
- line-height: inherit;
- vertical-align: top;
-}
-
-.aa-dropdown-menu .aa-suggestion .text {
- display: inline-block;
- width: calc(100% - 20px);
- padding-inline-start: 4px;
-}
-
-.aa-dropdown-menu .aa-suggestion .search-result-title {
- display: block;
-}
-
-.aa-dropdown-menu .aa-suggestion .search-result-attributes {
- display: block;
- font-size: 0.8em;
- color: var(--muted-text-color);
- opacity: 0.6;
- line-height: 1;
- word-wrap: break-word;
-}
-
-.aa-dropdown-menu .aa-suggestion p {
- padding: 0;
- margin: 0;
-}
-
-.aa-dropdown-menu .aa-suggestion.aa-cursor {
- color: var(--active-item-text-color);
- background-color: var(--active-item-background-color);
-}
-
.help-button,
.custom-title-bar-button {
float: inline-end;
@@ -2119,29 +2023,6 @@ body.desktop .dropdown-submenu > .dropdown-menu {
word-break: break-all;
}
- body.mobile .jump-to-note-dialog {
- .modal-header {
- padding-bottom: 0.75rem !important;
- }
-
- .modal-content {
- padding-bottom: 0 !important;
- }
-
- .modal-body {
- overflow-y: auto;
- }
-
- .aa-dropdown-menu {
- max-height: unset;
- overflow: auto;
- }
-
- .aa-suggestion {
- padding-inline: 0;
- }
- }
-
body.mobile .modal-dialog .dropdown-menu {
position: static !important;
border: 0 !important;
diff --git a/apps/client/src/widgets/dialogs/jump_to_note.css b/apps/client/src/widgets/dialogs/jump_to_note.css
index e019f23d21..0af051ceda 100644
--- a/apps/client/src/widgets/dialogs/jump_to_note.css
+++ b/apps/client/src/widgets/dialogs/jump_to_note.css
@@ -98,3 +98,28 @@
opacity: 0.75;
font-family: inherit !important;
}
+
+@media (max-width: 991px) {
+ body.mobile .jump-to-note-dialog {
+ .modal-header {
+ padding-bottom: 0.75rem !important;
+ }
+
+ .modal-content {
+ padding-bottom: 0 !important;
+ }
+
+ .modal-body {
+ overflow-y: auto;
+ }
+
+ .aa-dropdown-menu {
+ max-height: unset;
+ overflow: auto;
+ }
+
+ .aa-suggestion {
+ padding-inline: 0;
+ }
+ }
+}
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.css b/apps/client/src/widgets/react/NoteAutocomplete.css
index c4dfe810db..b699b59220 100644
--- a/apps/client/src/widgets/react/NoteAutocomplete.css
+++ b/apps/client/src/widgets/react/NoteAutocomplete.css
@@ -1,14 +1,102 @@
-/* The styles `autocomplete.js` set inline on its suggestion list. */
-.algolia-autocomplete .aa-dropdown-menu,
+/*
+ * Unlike `style.css`, which loads after Bootstrap and the theme, this file has no fixed place among
+ * them. Each selector carries one more class or element than the rule it competes with (Bootstrap's
+ * `.input-group-text` and `.form-control`, the `.aa-suggestion` rules in the next theme's
+ * `base.css`), so the outcome does not depend on the order.
+ */
+
+.input-group > .note-autocomplete-input {
+ /* Lets the buttons after the input join it seamlessly. */
+ border-inline-end: 0;
+}
+
+.input-group > :is(.show-recent-notes-button, .full-text-search-button, .go-to-selected-note-button) {
+ cursor: pointer;
+ font-size: 1.3em;
+ padding-inline: 5px;
+}
+
+.input-group > :is(.show-recent-notes-button, .go-to-selected-note-button) {
+ padding-top: 8px;
+}
+
+.input-group > .go-to-selected-note-button {
+ padding-inline: 4px 3px;
+
+ &.disabled,
+ &.disabled:hover {
+ cursor: inherit;
+ color: var(--button-disabled-text-color) !important;
+ background-color: var(--button-disabled-background-color) !important;
+ text-decoration: none;
+ }
+}
+
+.algolia-autocomplete {
+ z-index: 2000 !important;
+}
+
+.algolia-autocomplete .aa-dropdown-menu {
+ /* `autocomplete.js` set it inline. */
+ display: block;
+ width: 100%;
+ background-color: var(--main-background-color);
+ border: 1px solid var(--main-border-color);
+ border-top: none;
+ max-height: 500px;
+ overflow: auto;
+ padding: 0;
+ margin: 0;
+}
+
+/* `autocomplete.js` set it inline. */
.algolia-autocomplete .aa-suggestions {
display: block;
}
-.algolia-autocomplete .aa-suggestion {
- white-space: nowrap;
+span.aa-dropdown-menu .aa-suggestion {
cursor: pointer;
+ padding: 6px 16px;
+ margin: 0;
+ /* `autocomplete.js` set these inline. */
+ white-space: nowrap;
> * {
white-space: normal;
}
+
+ .icon {
+ display: inline-block;
+ line-height: inherit;
+ vertical-align: top;
+ }
+
+ .text {
+ display: inline-block;
+ width: calc(100% - 20px);
+ padding-inline-start: 4px;
+ }
+
+ .search-result-title {
+ display: block;
+ }
+
+ .search-result-attributes {
+ display: block;
+ font-size: 0.8em;
+ color: var(--muted-text-color);
+ opacity: 0.6;
+ line-height: 1;
+ word-wrap: break-word;
+ }
+
+ p {
+ padding: 0;
+ margin: 0;
+ }
+
+ &.aa-cursor {
+ color: var(--active-item-text-color);
+ background-color: var(--active-item-background-color);
+ }
}