Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
/* Colors come from the theme's `--quick-search-*` variables; the fallbacks cover the themes that
define none of them. */
.quick-search {
--quick-search-button-active-background:
var(--left-pane-item-action-button-background, var(--hover-item-background-color));
--quick-search-button-hover-background:
var(--left-pane-item-action-button-hover-background, var(--hover-item-background-color));
--quick-search-button-active-color:
var(--left-pane-item-action-button-color, var(--main-text-color));
display: flex;
padding: 8px;
/* `.component`, which `BasicWidget` adds, sets `contain: size` and would collapse the box. */
&.component {
contain: unset;
}
.quick-search-box {
display: flex;
flex: 1 1 auto;
flex-direction: row-reverse;
align-items: center;
min-width: 0;
border: 2px solid transparent;
border-radius: 6px;
background: var(--quick-search-background, var(--accented-background-color));
transition: background-color 200ms ease-in;
}
&:hover .quick-search-box {
background: var(--quick-search-hover-background, var(--accented-background-color));
transition: background-color 75ms ease-out;
}
&:focus-within .quick-search-box {
border-color: var(--quick-search-focus-border, var(--main-border-color));
background: var(--quick-search-focus-background, var(--main-background-color));
transition: background-color 100ms ease-out;
}
.search-string {
display: flex;
flex: 1 1 auto;
align-items: center;
min-width: 0;
/* With the box's 2px border, a 34px box around a line of text, the height of a
`.form-control-sm`. */
padding-block: 3px;
padding-inline: 8px;
border: 0;
font-size: 100% !important;
/* The box behind the field takes the place of the field's own fill and focus outline. */
&,
&:hover,
&:focus-within {
background: transparent;
outline: none;
box-shadow: none;
}
.cm-editor {
width: 100%;
}
/* Overrides the shared `pre-wrap`, which wraps a long query and grows the field. */
.cm-line {
white-space: pre;
}
.cm-placeholder {
color: var(--quick-search-color, var(--muted-text-color));
}
}
&:focus-within .search-string {
color: var(--quick-search-focus-color, var(--main-text-color));
}
/* `!important` outranks Bootstrap's `.btn` state rules (`:hover`, `:active`, `.active`). */
.search-button {
display: flex;
align-items: center;
justify-content: center;
flex: none;
width: 25px;
height: 25px;
margin-inline-end: 8px;
padding: 0;
border: 0;
border-radius: 50%;
background: transparent;
font-size: 100% !important;
color: var(--quick-search-color, var(--muted-text-color)) !important;
transition: background-color 200ms ease-in !important;
&:active {
transform: scale(0.85);
}
}
&.has-query:focus-within .search-button {
background: var(--quick-search-button-active-background) !important;
color: var(--quick-search-button-active-color) !important;
transition: background-color 500ms ease-out !important;
}
&:focus-within .search-button:hover,
.search-button.active {
background: var(--quick-search-button-hover-background) !important;
color: var(--quick-search-button-active-color) !important;
transition: background-color 100ms ease-out !important;
}
}
/* The popup is portaled to `<body>`, outside `.quick-search`. */
.dropdown-menu.quick-search-menu {
--quick-search-item-delimiter-color: var(--dropdown-border-color);
max-height: 80vh;
/* A fixed popup is otherwise as wide as the room right of its `left`, so each pass of `shift()`
away from the viewport's edge widens it, and the next pass moves it again. */
width: max-content;
/* The 10px are the 5px `Popup` keeps from each edge of the viewport. */
min-width: min(400px, calc(100vw - 10px));
max-width: min(720px, calc(100vw - 10px));
overflow: hidden;
text-overflow: ellipsis;
box-shadow: -30px 50px 93px -50px black;
/* Outranks Bootstrap's `.dropdown-menu.show { display: block }` and the theme's
`.dropdown-menu:not(.static)` padding. */
&.show {
display: flex;
flex-direction: column;
padding: 0 !important;
}
.quick-search-results {
flex: 1 1 auto;
min-height: 0;
padding: var(--menu-padding-size, .5rem 0);
overflow-y: auto;
overflow-x: hidden;
}
.quick-search-footer {
display: flex;
flex: 0 0 auto;
align-items: center;
padding: var(--menu-padding-size, .5rem);
border-top: 1px solid var(--dropdown-border-color, var(--main-border-color));
.show-in-full-search {
margin-inline-start: auto;
}
}
.dropdown-item {
white-space: normal;
padding: 12px 16px;
line-height: 1.4;
position: relative;
& + .dropdown-item::after {
content: '';
position: absolute;
inset-inline-start: 0;
top: 0;
width: 100%;
height: 1px;
border-bottom: 1px solid var(--quick-search-item-delimiter-color);
}
&:last-child::after,
&.disabled::after {
display: none;
}
/* Hover and keyboard focus share the active-item fill used by other menus. */
&:not(.disabled):hover,
&:not(.disabled):focus {
background-color: var(--active-item-background-color);
color: var(--active-item-text-color);
outline: none;
}
}
.quick-search-item {
width: 100%;
}
.quick-search-item-header {
padding: 0 8px;
}
.quick-search-item-icon {
margin-inline-end: 2px;
}
.search-result-title {
font-weight: 500;
}
.search-result-attributes {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 4px;
padding: 0 8px;
.ext-badge {
--color: var(--muted-text-color);
}
}
.search-result-content {
margin-top: 8px;
padding: 8px;
background-color: var(--accented-background-color);
color: var(--main-text-color);
font-size: .85em;
overflow: hidden;
text-overflow: ellipsis;
}
/* Uses the same highlight variables as SearchResultsList.css and ListOrGridView.css. */
:is(.search-result-title, .search-result-content, .search-result-attributes) b {
background: var(--note-list-view-search-result-highlight-background, transparent);
color:
var(--note-list-view-search-result-highlight-color, var(--admonition-warning-accent-color));
font-weight: 600;
text-decoration: underline;
&.search-fuzzy-match {
color: var(--quick-search-result-fuzzy-highlight-color, #e47b19);
font-weight: 400;
text-decoration: underline dotted;
}
}
.bx-loader {
margin-inline-end: 4px;
}
.quick-search-error {
margin: 4px 8px;
white-space: normal;
}
}