sync
This commit is contained in:
1 parent
a0fe4cb7b1
commit
5cb14ffd44
11 files changed
+157
-96
No files matched your search
@@ -113,23 +113,22 @@ function notify(opts) {
|
||||
timer && clearTimeout(timer);
|
||||
closeNotify(wrapper, opts?.onDismissed);
|
||||
});
|
||||
let type;
|
||||
let typeClass;
|
||||
switch (opts?.type) {
|
||||
case 'warning':
|
||||
type = 'exclamation-circle';
|
||||
typeClass = 'warning';
|
||||
break;
|
||||
case 'error':
|
||||
type = 'times-circle';
|
||||
typeClass = 'error';
|
||||
break;
|
||||
default:
|
||||
type = opts?.type ?? 'check-circle';
|
||||
typeClass = 'success';
|
||||
break;
|
||||
const typeClass = opts?.type ?? 'success';
|
||||
let fontIcon = opts?.icon;
|
||||
if (fontIcon == null) {
|
||||
switch (typeClass) {
|
||||
case 'warning':
|
||||
fontIcon = 'exclamation-circle';
|
||||
break;
|
||||
case 'error':
|
||||
fontIcon = 'times-circle';
|
||||
break;
|
||||
default:
|
||||
fontIcon = 'check-circle';
|
||||
break;
|
||||
}
|
||||
}
|
||||
const icon = createIcon('fa-solid', type);
|
||||
const icon = createIcon('fa-solid', fontIcon);
|
||||
icon.classList.add('ui-notify-type', typeClass);
|
||||
const title = opts?.title;
|
||||
const wrapper = createElement('div', 'ui-notify',
|
||||
@@ -153,7 +152,18 @@ function notify(opts) {
|
||||
closeNotify(wrapper, opts?.onDismissed, true);
|
||||
}, opts?.timeout || 3000);
|
||||
}
|
||||
(opts?.parent ?? document.body).appendChild(wrapper);
|
||||
const parent = opts?.parent ?? document.body;
|
||||
let top = 0;
|
||||
(/** @type {NodeListOf<HTMLElement>} */ (parent.querySelectorAll('.ui-notify'))).forEach(n =>{
|
||||
const t = n.offsetTop + n.offsetHeight;
|
||||
if (t > top) {
|
||||
top = t;
|
||||
}
|
||||
});
|
||||
if (top > 0) {
|
||||
wrapper.style.top = `${top + 10}px`;
|
||||
}
|
||||
parent.appendChild(wrapper);
|
||||
setTimeout(() => wrapper.classList.add('active'), 10);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user