Skip to content

Build your personal knowledge base with Trilium Notes

3.0 KB
Raw Blame
/*
 * A field carrying chips ahead of the box typed into (see the component's `leading`) looks the same
 * here as anywhere else a field is framed, so it wears the shared `tn-field` and adds nothing of its
 * own. The class remains as the handle the dropdown is measured against.
 */

/*
 * 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 corner radius, which the older themes leave
 * out, falls back to the value those themes use for their own menus.
 */
.form-autocomplete-dropdown {
    display: flex;
    flex-direction: column;
    /* Twice `VIEWPORT_PADDING` in Popup.tsx, whose `shift()` then keeps the list on screen. */
    max-width: calc(100vw - 10px);
    font-size: 0.9rem;
    color: var(--menu-text-color);
    background-color: var(--menu-background-color);
    /* Only the themes that blur their menus define a filter; in the rest this resolves to no blur. */
    backdrop-filter: var(--dropdown-backdrop-filter);
    border: 1px solid var(--dropdown-border-color);
    border-radius: var(--dropdown-border-radius, 6px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity, 0.2));
    /* Keeps the list's scrollbar inside the rounded corners. */
    overflow: hidden;
}

/* Over a prompt (2000), which can hold a field; `body .tn-popup` sets 1200 (Popup.css). */
body .tn-popup.form-autocomplete-dropdown {
    z-index: 2000;
}

/* Scrolls inside the frame, whose height `placeFloating()` caps to the room on its side. */
.form-autocomplete-dropdown > .form-autocomplete-list {
    min-height: 0;
    max-height: 300px;
    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(--suggestion-list-padding);
    scroll-padding-block: var(--suggestion-list-padding);
    list-style: none;
    overflow-y: auto;
}

.form-autocomplete-dropdown .form-autocomplete-item {
    cursor: pointer;
    padding: var(--suggestion-item-padding-block) var(--suggestion-item-padding-inline);
    margin: 0;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pointer and keyboard share the one highlight: hovering an entry makes it the active one. */
.form-autocomplete-dropdown .form-autocomplete-item.active {
    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 var(--suggestion-item-padding-inline) 2px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.55;
    cursor: default;
}

.form-autocomplete-dropdown .form-autocomplete-heading:first-child {
    padding-top: 2px;
}