- Vanilla JS frontend with dark theme - Dashboard with sidebar (libraries tree, tags), document grid, search - Document viewer with markdown rendering and metadata panel - Document editor with split write/preview and formatting toolbar - Login screen with token authentication - All styled according to UI/UX specs (dark theme, accent #00d4aa) - API client for all endpoints - Responsive design
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
// Modal Component
|
|
|
|
export function showModal({ title, content, onConfirm, onCancel, confirmText = 'Confirm', cancelText = 'Cancel', danger = false }) {
|
|
const backdrop = document.createElement('div');
|
|
backdrop.className = 'modal-backdrop';
|
|
backdrop.innerHTML = `
|
|
<div class="modal">
|
|
<div class="modal-header">
|
|
<h3>${title}</h3>
|
|
</div>
|
|
<div class="modal-body">
|
|
${content}
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-ghost" id="modal-cancel">${cancelText}</button>
|
|
<button class="btn ${danger ? 'btn-danger' : 'btn-primary'}" id="modal-confirm">${confirmText}</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
document.body.appendChild(backdrop);
|
|
|
|
backdrop.querySelector('#modal-cancel').onclick = () => {
|
|
backdrop.remove();
|
|
if (onCancel) onCancel();
|
|
};
|
|
|
|
backdrop.querySelector('#modal-confirm').onclick = () => {
|
|
backdrop.remove();
|
|
if (onConfirm) onConfirm();
|
|
};
|
|
|
|
backdrop.onclick = (e) => {
|
|
if (e.target === backdrop) {
|
|
backdrop.remove();
|
|
if (onCancel) onCancel();
|
|
}
|
|
};
|
|
|
|
return backdrop;
|
|
}
|
|
|
|
export function hideModal(backdrop) {
|
|
if (backdrop && backdrop.parentElement) {
|
|
backdrop.remove();
|
|
}
|
|
}
|