Переписал уведомления: toast/confirm вместо alert; объединил профиль+инвентарь; починил ленту активности

This commit is contained in:
root
2026-07-05 15:05:04 +00:00
parent fe6bf5cf29
commit 50535ec777
15 changed files with 1523 additions and 1111 deletions
+214
View File
@@ -4486,4 +4486,218 @@ a:not(.btn):not(.nav-link):not(.logo) {
}
a:not(.btn):not(.nav-link):not(.logo):hover {
border-bottom-color: var(--primary-color);
}
/* =============================================
🍞 Уведомления (Toast + Confirm)
============================================= */
.toast-container {
position: fixed;
top: 72px;
right: 16px;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 8px;
pointer-events: none;
max-width: 380px;
width: 100%;
}
.toast {
background: var(--bg-elevated);
border: 1px solid var(--border-light);
border-radius: 10px;
padding: 12px 16px;
display: flex;
align-items: flex-start;
gap: 10px;
pointer-events: auto;
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
transform-origin: top right;
position: relative;
overflow: hidden;
}
.toast::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
border-radius: 3px 0 0 3px;
}
.toast-success::before { background: var(--success); }
.toast-error::before { background: var(--danger); }
.toast-info::before { background: var(--primary); }
.toast-warning::before { background: var(--warning); }
.toast-icon {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
border-radius: 6px;
font-size: 0.85rem;
}
.toast-success .toast-icon { background: rgba(16,185,129,0.15); }
.toast-error .toast-icon { background: rgba(239,68,68,0.15); }
.toast-info .toast-icon { background: rgba(245,158,11,0.15); }
.toast-warning .toast-icon { background: rgba(245,158,11,0.15); }
.toast-content {
flex: 1;
min-width: 0;
}
.toast-title {
font-size: 0.82rem;
font-weight: 600;
color: var(--text);
line-height: 1.3;
}
.toast-message {
font-size: 0.75rem;
color: var(--text-dim);
margin-top: 2px;
line-height: 1.3;
}
.toast-close {
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
font-size: 0.75rem;
flex-shrink: 0;
border-radius: 4px;
transition: all 0.15s;
}
.toast-close:hover {
background: rgba(255,255,255,0.06);
color: var(--text);
}
.toast-removing {
animation: toastSlideOut 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes toastSlideIn {
from { opacity: 0; transform: translateX(100%) scale(0.9); }
to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastSlideOut {
from { opacity: 1; transform: translateX(0) scale(1); }
to { opacity: 0; transform: translateX(100%) scale(0.9); }
}
/* =============================================
⚠️ Confirm диалог
============================================= */
.confirm-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 10000;
animation: confirmFadeIn 0.2s ease;
}
.confirm-dialog {
background: var(--bg-card);
border: 1px solid var(--border-light);
border-radius: 14px;
padding: 24px;
max-width: 400px;
width: 90%;
animation: confirmScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.confirm-dialog-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 12px;
}
.confirm-dialog-icon {
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
font-size: 1.1rem;
flex-shrink: 0;
}
.confirm-dialog-icon-warning { background: rgba(239,68,68,0.15); }
.confirm-dialog-icon-info { background: rgba(245,158,11,0.15); }
.confirm-dialog-title {
font-size: 1rem;
font-weight: 600;
color: var(--text);
}
.confirm-dialog-message {
font-size: 0.88rem;
color: var(--text-dim);
line-height: 1.5;
margin-bottom: 20px;
padding-left: 46px;
}
.confirm-dialog-actions {
display: flex;
gap: 10px;
justify-content: flex-end;
}
.confirm-dialog-actions .btn {
min-width: 90px;
padding: 0.55rem 1.2rem;
font-size: 0.8rem;
}
.confirm-dialog .btn-danger {
background: var(--danger);
color: white;
border: none;
}
.confirm-dialog .btn-danger:hover {
background: #dc2626;
box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}
@keyframes confirmFadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes confirmScaleIn {
from { opacity: 0; transform: scale(0.9) translateY(10px); }
to { opacity: 1; transform: scale(1) translateY(0); }
}
+137
View File
@@ -0,0 +1,137 @@
(function() {
'use strict';
let toastId = 0;
const container = document.createElement('div');
container.className = 'toast-container';
container.id = 'toastContainer';
document.body.appendChild(container);
function escapeHtml(text) {
const d = document.createElement('div');
d.textContent = text || '';
return d.innerHTML;
}
window.Notify = {
toast: function(message, type, title) {
if (!message) return;
type = type || 'info';
const icons = { success: '✓', error: '✕', info: '', warning: '⚠' };
const titles = { success: title || 'Успешно', error: title || 'Ошибка', info: title || 'Информация', warning: title || 'Внимание' };
const icon = icons[type] || '';
const t = titles[type];
const id = ++toastId;
const el = document.createElement('div');
el.className = 'toast toast-' + type;
el.id = 'toast-' + id;
el.innerHTML =
'<div class="toast-icon">' + icon + '</div>' +
'<div class="toast-content">' +
'<div class="toast-title">' + escapeHtml(t) + '</div>' +
'<div class="toast-message">' + escapeHtml(message) + '</div>' +
'</div>' +
'<button class="toast-close" onclick="Notify.dismiss(' + id + ')">✕</button>';
container.appendChild(el);
const timeout = setTimeout(function() {
Notify.dismiss(id);
}, 4000);
el._timeout = timeout;
el._id = id;
return id;
},
success: function(message) {
return this.toast(message, 'success');
},
error: function(message) {
return this.toast(message, 'error');
},
info: function(message) {
return this.toast(message, 'info');
},
warning: function(message) {
return this.toast(message, 'warning');
},
dismiss: function(id) {
var el = document.getElementById('toast-' + id);
if (!el) return;
if (el._timeout) clearTimeout(el._timeout);
if (el.classList.contains('toast-removing')) return;
el.classList.add('toast-removing');
setTimeout(function() {
if (el.parentNode) el.parentNode.removeChild(el);
}, 250);
},
confirm: function(message, title, callback) {
if (typeof title === 'function') {
callback = title;
title = 'Подтверждение';
}
title = title || 'Подтверждение';
var overlay = document.createElement('div');
overlay.className = 'confirm-overlay';
overlay.innerHTML =
'<div class="confirm-dialog">' +
'<div class="confirm-dialog-header">' +
'<div class="confirm-dialog-icon confirm-dialog-icon-warning">⚠</div>' +
'<div class="confirm-dialog-title">' + escapeHtml(title) + '</div>' +
'</div>' +
'<div class="confirm-dialog-message">' + escapeHtml(message) + '</div>' +
'<div class="confirm-dialog-actions">' +
'<button class="btn btn-outline confirm-cancel">Отмена</button>' +
'<button class="btn btn-danger confirm-ok">Подтвердить</button>' +
'</div>' +
'</div>';
document.body.appendChild(overlay);
var result = false;
function close() {
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
if (callback) callback(result);
}
overlay.querySelector('.confirm-cancel').addEventListener('click', function() {
result = false;
close();
});
overlay.querySelector('.confirm-ok').addEventListener('click', function() {
result = true;
close();
});
overlay.addEventListener('click', function(e) {
if (e.target === overlay) {
result = false;
close();
}
});
document.addEventListener('keydown', function handler(e) {
if (e.key === 'Escape') {
result = false;
close();
document.removeEventListener('keydown', handler);
}
});
return overlay;
}
};
})();