Skip to content

Build your personal knowledge base with Trilium Notes

3.6 KB
Raw Blame
div.note-icon-widget {
    /* The size of the icon */
    --note-icon-size: 30px;
    /* The padding size for the icon container */
    --note-icon-container-padding-size: 10px;
    contain: unset;
}

.note-icon-widget button.note-icon {
    /* `1em` is this button's font size, which `--note-icon-size` already set: naming that variable
       here again would scale a value given in `em` a second time. */
    --size: calc(1em + var(--note-icon-container-padding-size) * 2);

    width: var(--size);
    height: var(--size);
    padding: 0;
    border: 1px solid transparent;
    background-color: transparent;
    color: var(--muted-text-color);
    cursor: pointer;
    font-size: var(--note-icon-size);
}

/* A glyph rasterises on whole pixels while the disc behind it does not, so a gap of half a pixel
   between the two puts the icon high or low depending on where the widget lands on the page.
   Rounding both leaves a gap of twice the ring, which is always whole. */
@supports (width: round(1px, 1px)) {
    .note-icon-widget button.note-icon {
        --size: calc(1em + round(var(--note-icon-container-padding-size), 1px) * 2);

        font-size: round(var(--note-icon-size), 1px);
    }
}

.note-icon-widget button.note-icon:disabled {
    cursor: default;
    opacity: .75;
}

.note-icon-widget .dropdown-menu {
    border-radius: 10px;
    border-width: 2px;
    box-shadow: 10px 10px 93px -25px black;
    --padding: 0;
    padding: 0 !important;
    overflow: clip;

    .filter-row {
        padding: 10px 15px 0;
    }
}

.note-icon-widget button.note-icon {
    --input-focus-outline-color: var(--note-icon-hover-background-color);

    position: relative;
    background: transparent !important;

    &, &:hover {
        border-radius: 50%;
    }

    /* The icon */
    &::before {
        position: relative;
        z-index: 1;
        color: var(--note-icon-custom-color, var(--note-icon-color));
    }

    /* The background circle */
    &:not(.bx-empty:disabled)::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: var(--note-icon-custom-background-color, var(--note-icon-background-color));
    }

    &:focus-visible {
        outline: 2px solid var(--note-icon-custom-color, var(--note-icon-color));
    }

    &:hover:not(.bx-empty:disabled)::after {
        background: var(--note-icon-hover-custom-background-color, var(--note-icon-hover-background-color));
        transition: background 200ms ease-out;
    }
}

body.mobile .modal.icon-switcher {
    .modal-dialog {
        left: 0;
        right: 0;
        margin: unset;
        transform: unset;
        max-width: 100%;
        height: 100%;
    }

    /* Every box from `.modal-content` down to `.icon-list` needs a bounded height: react-window
       renders as many rows as the grid is tall, which unbounded is every icon. */
    .modal-content {
        height: 100%;
    }

    .modal-body {
        padding: 0;
        display: flex;
        flex-direction: column;
    }

    .icon-picker {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        min-height: 0;

        > .filter-row {
            padding: 0.25em var(--bs-modal-padding) 0.5em var(--bs-modal-padding);
            border-bottom: 1px solid var(--main-border-color);
        }
    }

    .icon-list {
        --scroll-fade-top: 0px;
        --icon-list-inset: 0px;
        display: flex;
        flex-direction: column;
        margin: 0 auto;
        flex-grow: 1;
        min-height: 0;
        height: auto;

        span {
            padding: 12px;
        }
    }
}