mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
feat(toast): improve layout for toasts without title
This commit is contained in:
parent
120324c3f0
commit
15f344fe4a
@ -4,7 +4,7 @@ import utils from "./utils.js";
|
||||
export interface ToastOptions {
|
||||
id?: string;
|
||||
icon: string;
|
||||
title: string;
|
||||
title?: string;
|
||||
message: string;
|
||||
delay?: number;
|
||||
autohide?: boolean;
|
||||
@ -12,20 +12,32 @@ export interface ToastOptions {
|
||||
}
|
||||
|
||||
function toast(options: ToastOptions) {
|
||||
const $toast = $(
|
||||
`<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto">
|
||||
const $toast = $(options.title
|
||||
? `\
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto">
|
||||
<span class="bx bx-${options.icon}"></span>
|
||||
<span class="toast-title"></span>
|
||||
</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body"></div>
|
||||
</div>`
|
||||
: `
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-icon">
|
||||
<span class="bx bx-${options.icon}"></span>
|
||||
<span class="toast-title"></span>
|
||||
</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body"></div>
|
||||
</div>`
|
||||
</div>
|
||||
<div class="toast-body"></div>
|
||||
<div class="toast-header">
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>`
|
||||
);
|
||||
|
||||
$toast.find(".toast-title").text(options.title);
|
||||
$toast.toggleClass("no-title", !options.title);
|
||||
$toast.find(".toast-title").text(options.title ?? "");
|
||||
$toast.find(".toast-body").html(options.message);
|
||||
|
||||
if (options.id) {
|
||||
|
@ -1141,6 +1141,26 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.toast.no-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.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 {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.toast.no-title .toast-header {
|
||||
background-color: unset !important;
|
||||
}
|
||||
|
||||
.ck-mentions .ck-button {
|
||||
font-size: var(--detail-font-size) !important;
|
||||
padding: 5px;
|
||||
|
@ -342,7 +342,10 @@ li.dropdown-item a.dropdown-item-button:focus-visible {
|
||||
|
||||
#toast-container .toast .toast-header .btn-close {
|
||||
margin: 0 0 0 12px;
|
||||
}
|
||||
|
||||
#toast-container .toast.no-title {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#toast-container .toast .toast-body {
|
||||
@ -350,6 +353,22 @@ li.dropdown-item a.dropdown-item-button:focus-visible {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding-top: 0;
|
||||
color: var(--muted-text-color);
|
||||
}
|
||||
|
||||
#toast-container .toast:not(.no-title) .bx {
|
||||
margin-right: 0.5em;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
#toast-container .toast.no-title .bx {
|
||||
margin-right: 0;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
#toast-container .toast.no-title .toast-body {
|
||||
padding-top: var(--bs-toast-padding-x);
|
||||
color: var(--toast-text-color);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user