Skip to content

Build your personal knowledge base with Trilium Notes

3.7 KB
Raw Blame
/*
 * The backlinks of a note, as the sidebar's connections tab and the mobile note menu show them —
 * read as the quick search reads its results (see quick_search.ts and theme-next/shell.css): the note
 * named on a line of its own, its excerpt quoted in the block below, and the link the excerpt is
 * about picked out the way a search picks out its match. Both are already framed by what holds them,
 * a card or a modal, so the items carry no frame of their own.
 */
.tn-backlinks-widget .backlinks-items {
    list-style-type: none;
    margin: 0;
    padding: 0;

    > li {
        padding-block: 8px;

        &:first-child {
            padding-top: 0;
        }
    }

    /* The note the backlink comes from: its ancestors above it, as the quick search sets its path.
       The link builder nests the parts in a span of its own (see createLink in services/link.ts). */
    .backlink-header {
        display: block;

        > span {
            display: flex;
            flex-wrap: wrap;
            align-items: center;

            /* The path comes after the note in the markup, and reads before it. */
            > small {
                flex: 100%;
                order: -1;
                opacity: .5;
                font-size: .75em;

                .note-path {
                    padding: 0;
                }
            }

            > .tn-icon {
                color: var(--menu-item-icon-color);
            }

            > a {
                margin-inline-start: 4px;
                color: currentColor;
                font-weight: 500;
            }
        }
    }

    /* What the note says around the link, in the block the search snippets are set in. */
    .backlink-excerpt {
        margin-top: 8px;
        border-radius: 4px;
        /* The colour the theme gives a search snippet, falling back — as the quick search does — to
           what every theme defines, since only theme-next names one of its own. */
        background: var(--quick-search-result-content-background, var(--accented-background-color));
        padding: 8px;
        font-size: .85em;

        p {
            margin: 0;
        }

        /* An excerpt is a slice of a note, headings and all, and a heading is sized for a page it
           titles — in `rem` at that (Bootstrap's), so it ignores the size of the excerpt around it
           entirely. Brought back to that size, with a step between the levels and the weight the
           theme takes off a page's headings, so they still read as headings at nearly the text's size. */
        h1, h2, h3, h4, h5, h6 {
            margin: .4em 0 .15em;
            font-weight: 600;
        }

        h1:first-child, h2:first-child, h3:first-child,
        h4:first-child, h5:first-child, h6:first-child {
            margin-top: 0;
        }

        h1 { font-size: 1.15em; }
        h2 { font-size: 1.1em; }
        h3 { font-size: 1.05em; }
        h4, h5, h6 { font-size: 1em; }

        /* Only the link the excerpt is quoted for is picked out — the others are links like any
           other in a note, and colouring them all says nothing about which one is the backlink. */
        .backlink-link {
            color: var(--quick-search-result-highlight-color, var(--admonition-warning-accent-color));
            font-weight: 600;
        }
    }

    /* A backlink that is a relation rather than a link in the text names the relation instead, as
       quietly as the quick search names the attributes it matched. */
    .backlink-relation {
        margin: 4px 0 0;
        opacity: .5;
        font-size: .85em;
    }
}

.dropdown-menu.dropdown-backlinks {
    --menu-padding-size: .9em;

    width: max-content;
    min-width: 300px;
    max-width: 500px;

    > .tn-panel-scroll {
        max-height: 60vh;
    }
}