Skip to content

Build your personal knowledge base with Trilium Notes

4.5 KB
Raw Blame
#toast-container {
    display: flex;
    flex-direction: column;
    /* The vertical gap between stacked toasts. Bootstrap's own spacing rule targets `.toast-container`,
       which this element isn't, so without this stacked toasts touch. */
    gap: 10px;
    justify-content: center;
    align-items: center;
    position: absolute;
    width: 100%;
    top: calc(var(--safe-area-inset-top, env(safe-area-inset-top)) + 20px);
    pointer-events: none;
    contain: none;
}

/* Fallback colours for a theme that dresses no toast of its own. Kept at this specificity so a theme's
   own `#toast-container .toast` still wins — the layout below deliberately sits a level higher. */
.toast {
    --bs-toast-bg: var(--accented-background-color);
    --bs-toast-color: var(--main-text-color);
}

/* Scoped to the container so the `display` beats Bootstrap's `.toast:not(.show) { display: none }` —
   the toast is rendered by Preact and never carries Bootstrap's `show` class, so without this the
   layout comes from whichever theme happens to define it, and toasts vanish under every other one. */
#toast-container .toast {
    display: flex;
    flex-direction: column;
    z-index: 9999999999 !important;
    pointer-events: all;
    overflow: hidden;
}

/* Wider variant for toasts with richer content (e.g. a reference-note list); capped to the
   viewport so it stays within bounds on narrow screens. */
.toast.wide {
    --bs-toast-max-width: min(500px, 90vw);
}

.toast-header {
    background-color: var(--more-accented-background-color) !important;
    color: var(--main-text-color) !important;
}

.toast-body {
    white-space: preserve-breaks;
    user-select: text;
    overflow: hidden;
}

.toast-body.monospace {
    font-family: var(--monospace-font-family);
    font-size: var(--monospace-font-size);
    overflow-wrap: anywhere;
}

.toast.no-title .toast-main-row {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.toast.no-title .toast-icon {
    display: flex;
    align-items: center;
    padding: var(--bs-toast-padding-y) var(--bs-toast-padding-x);
}

.toast.no-title .toast-body {
    flex: 1;
    padding-block: var(--bs-toast-padding-y);
    padding-inline: 0;
}

.toast.no-title .toast-close {
    display: flex;
    align-items: center;
    padding: var(--bs-toast-padding-y) var(--bs-toast-padding-x);
}

/* Without the close button the body would otherwise butt against the toast edge, since the body itself
   carries no inline padding in the no-title layout (it relies on the icon/close padding for breathing room). */
.toast.no-title.not-dismissible .toast-body {
    padding-inline-end: var(--bs-toast-padding-x);
}

.toast {
    .toast-buttons {
        padding: 0.5em var(--bs-toast-padding-x) var(--bs-toast-padding-y) var(--bs-toast-padding-x);
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.5em;

        .btn {
            flex: 0 1 auto;
            white-space: nowrap;
            color: var(--bs-toast-color);
            background: var(--modal-control-button-background);

            &:only-child {
                flex: 1;
            }

            &:hover {
                background: var(--modal-control-button-hover-background);
                color: var(--bs-toast-color);
            }
        }
    }

    .toast-notes {
        padding: 0 var(--bs-toast-padding-x) var(--bs-toast-padding-y) var(--bs-toast-padding-x);
        user-select: text;

        .toast-notes-heading {
            opacity: 0.75;
            margin-bottom: 0.25em;
        }

        .toast-notes-list {
            display: flex;
            flex-direction: column;
            gap: 0.15em;

            a {
                color: inherit;
            }

            .note-path {
                display: block;
                opacity: 0.5;
                margin-inline-start: 2.1em;
            }

            /* Annotation injected inline after the note title (see NoteLink's titleSuffix). It rides
               the title's line; the block-level .note-path drops below both. */
            .note-link-suffix {
                opacity: 0.75;
                font-size: 0.9em;

                &::before {
                    content: " — ";
                }
            }
        }
    }

    .toast-progress {
        position: absolute;
        bottom: 0;
        inset-inline-start: 0;
        inset-inline-end: 0;
        background-color: var(--toast-text-color) !important;
        height: 4px;
        transition: width 0.1s linear;
    }
}