feat: add frontend UI for SimpleNote Web
- 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
This commit is contained in:
46
public/js/components/modal.js
Normal file
46
public/js/components/modal.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user