418 lines
12 KiB
HTML
418 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>CLAWRIZON</title>
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap');
|
|
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
body {
|
|
font-family: 'Space Grotesk', sans-serif;
|
|
background: #1a1a1a;
|
|
min-height: 100vh;
|
|
color: #e8e0d8;
|
|
}
|
|
|
|
header {
|
|
text-align: center;
|
|
padding: 2rem 1rem 0.75rem;
|
|
border-bottom: 2px solid #333;
|
|
margin-bottom: 1.25rem;
|
|
}
|
|
header h1 {
|
|
font-family: 'Space Mono', monospace;
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
color: #f0e6d6;
|
|
letter-spacing: 0.3em;
|
|
text-transform: uppercase;
|
|
}
|
|
header p {
|
|
font-size: 0.7rem;
|
|
color: #666;
|
|
margin-top: 0.4rem;
|
|
font-weight: 400;
|
|
letter-spacing: 0.15em;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.board {
|
|
display: flex;
|
|
gap: 1.25rem;
|
|
padding: 0.5rem 1.5rem 2rem;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.column {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.column-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 0.75rem;
|
|
padding: 0.5rem 0.5rem;
|
|
border-bottom: 2px solid;
|
|
}
|
|
.column-header h2 {
|
|
font-family: 'Space Mono', monospace;
|
|
font-size: 0.85rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.15em;
|
|
text-transform: uppercase;
|
|
}
|
|
.col-now .column-header { border-color: #c44; }
|
|
.col-soon .column-header { border-color: #b87a2a; }
|
|
.col-eventually .column-header { border-color: #5a8a5a; }
|
|
.col-now .column-header h2 { color: #e86060; }
|
|
.col-soon .column-header h2 { color: #d4a04a; }
|
|
.col-eventually .column-header h2 { color: #7ab87a; }
|
|
|
|
.add-btn {
|
|
background: none;
|
|
border: 1.5px solid #444;
|
|
border-radius: 3px;
|
|
width: 26px; height: 26px;
|
|
font-size: 1.1rem;
|
|
color: #666;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: all 0.2s;
|
|
line-height: 1;
|
|
}
|
|
.add-btn:hover { border-color: #888; color: #aaa; background: rgba(255,255,255,0.05); }
|
|
|
|
.notes-list {
|
|
min-height: 60px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
.notes-list.drag-over { background: rgba(255,255,255,0.03); border-radius: 4px; }
|
|
|
|
.note {
|
|
background: #242424;
|
|
border-radius: 3px;
|
|
padding: 0.65rem 0.75rem;
|
|
padding-left: 2.2rem;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
|
|
cursor: grab;
|
|
position: relative;
|
|
transition: box-shadow 0.2s, transform 0.15s, opacity 0.3s;
|
|
user-select: none;
|
|
border: 1px solid #333;
|
|
}
|
|
.note:hover { border-color: #444; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
|
|
.note.dragging { opacity: 0.4; transform: rotate(1deg); }
|
|
|
|
.col-now .note { border-left: 3px solid #c44; }
|
|
.col-soon .note { border-left: 3px solid #b87a2a; }
|
|
.col-eventually .note { border-left: 3px solid #5a8a5a; }
|
|
|
|
/* Checkbox */
|
|
.note-check {
|
|
position: absolute;
|
|
left: 0.6rem;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
width: 16px; height: 16px;
|
|
appearance: none;
|
|
-webkit-appearance: none;
|
|
border: 2px solid #555;
|
|
border-radius: 2px;
|
|
background: transparent;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
.note-check:checked {
|
|
background: #666;
|
|
border-color: #666;
|
|
}
|
|
.note-check:checked::after {
|
|
content: '✓';
|
|
position: absolute;
|
|
top: -2px; left: 1px;
|
|
font-size: 12px;
|
|
color: #1a1a1a;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.note.done {
|
|
opacity: 0.4;
|
|
}
|
|
.note.done .note-text {
|
|
text-decoration: line-through;
|
|
text-decoration-color: #666;
|
|
}
|
|
|
|
.note-text {
|
|
font-size: 0.85rem;
|
|
line-height: 1.45;
|
|
min-height: 1.3em;
|
|
outline: none;
|
|
word-break: break-word;
|
|
color: #d4ccc4;
|
|
}
|
|
.note-text:focus {
|
|
background: #2a2a2a;
|
|
border-radius: 2px;
|
|
padding: 2px 4px;
|
|
margin: -2px -4px;
|
|
color: #f0e8e0;
|
|
}
|
|
.note-text[contenteditable="true"] { cursor: text; }
|
|
|
|
.note-delete {
|
|
position: absolute;
|
|
top: 4px; right: 6px;
|
|
background: none;
|
|
border: none;
|
|
color: #444;
|
|
font-size: 0.8rem;
|
|
cursor: pointer;
|
|
opacity: 0;
|
|
transition: opacity 0.15s, color 0.15s;
|
|
padding: 2px 4px;
|
|
}
|
|
.note:hover .note-delete { opacity: 1; }
|
|
.note-delete:hover { color: #c44; }
|
|
|
|
/* Mobile */
|
|
@media (max-width: 700px) {
|
|
.board { flex-direction: column; padding: 0.75rem; gap: 1.5rem; }
|
|
.column { width: 100%; }
|
|
header h1 { font-size: 1.5rem; }
|
|
.note-delete { opacity: 0.6; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Clawrizon</h1>
|
|
<p>drag to reorder · click to edit · check when done</p>
|
|
</header>
|
|
<div class="board" id="board"></div>
|
|
|
|
<script>
|
|
const COLUMNS = [
|
|
{ key: 'now', label: 'Now' },
|
|
{ key: 'soon', label: 'Soon' },
|
|
{ key: 'eventually', label: 'Eventually' }
|
|
];
|
|
|
|
let dragItem = null;
|
|
|
|
async function api(path, opts = {}) {
|
|
const res = await fetch('/api' + path, {
|
|
headers: { 'Content-Type': 'application/json' },
|
|
...opts,
|
|
body: opts.body ? JSON.stringify(opts.body) : undefined
|
|
});
|
|
return res.json();
|
|
}
|
|
|
|
function createNoteEl(note, colKey) {
|
|
const el = document.createElement('div');
|
|
el.className = 'note' + (note.done ? ' done' : '');
|
|
el.draggable = true;
|
|
el.dataset.id = note.id;
|
|
|
|
const check = document.createElement('input');
|
|
check.type = 'checkbox';
|
|
check.className = 'note-check';
|
|
check.checked = !!note.done;
|
|
check.addEventListener('change', async () => {
|
|
const done = check.checked;
|
|
el.classList.toggle('done', done);
|
|
await api('/notes/' + note.id, { method: 'PATCH', body: { done } });
|
|
});
|
|
|
|
const text = document.createElement('div');
|
|
text.className = 'note-text';
|
|
text.contentEditable = true;
|
|
text.textContent = note.text;
|
|
text.addEventListener('focus', () => el.draggable = false);
|
|
text.addEventListener('blur', async () => {
|
|
el.draggable = true;
|
|
const newText = text.textContent.trim();
|
|
if (newText && newText !== note.text) {
|
|
note.text = newText;
|
|
await api('/notes/' + note.id, { method: 'PATCH', body: { text: newText } });
|
|
} else if (!newText) {
|
|
text.textContent = note.text;
|
|
}
|
|
});
|
|
text.addEventListener('keydown', e => {
|
|
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); text.blur(); }
|
|
});
|
|
|
|
const del = document.createElement('button');
|
|
del.className = 'note-delete';
|
|
del.textContent = '✕';
|
|
del.onclick = async () => {
|
|
el.style.transform = 'scale(0.9)'; el.style.opacity = '0';
|
|
setTimeout(() => el.remove(), 150);
|
|
await api('/notes/' + note.id, { method: 'DELETE' });
|
|
};
|
|
|
|
el.appendChild(check);
|
|
el.appendChild(text);
|
|
el.appendChild(del);
|
|
|
|
el.addEventListener('dragstart', e => {
|
|
dragItem = { el, id: note.id, fromCol: colKey };
|
|
el.classList.add('dragging');
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
});
|
|
el.addEventListener('dragend', () => {
|
|
el.classList.remove('dragging');
|
|
dragItem = null;
|
|
});
|
|
|
|
return el;
|
|
}
|
|
|
|
async function render() {
|
|
const data = await api('/notes');
|
|
const board = document.getElementById('board');
|
|
board.innerHTML = '';
|
|
|
|
COLUMNS.forEach(col => {
|
|
const colEl = document.createElement('div');
|
|
colEl.className = 'column col-' + col.key;
|
|
|
|
const header = document.createElement('div');
|
|
header.className = 'column-header';
|
|
const h2 = document.createElement('h2');
|
|
h2.textContent = col.label;
|
|
const addBtn = document.createElement('button');
|
|
addBtn.className = 'add-btn';
|
|
addBtn.textContent = '+';
|
|
addBtn.onclick = async () => {
|
|
const note = await api('/notes', { method: 'POST', body: { column: col.key, text: 'New note...' } });
|
|
const noteEl = createNoteEl(note, col.key);
|
|
list.appendChild(noteEl);
|
|
const textEl = noteEl.querySelector('.note-text');
|
|
textEl.focus();
|
|
document.execCommand('selectAll');
|
|
};
|
|
header.appendChild(h2);
|
|
header.appendChild(addBtn);
|
|
|
|
const list = document.createElement('div');
|
|
list.className = 'notes-list';
|
|
list.dataset.column = col.key;
|
|
|
|
list.addEventListener('dragover', e => {
|
|
e.preventDefault();
|
|
e.dataTransfer.dropEffect = 'move';
|
|
list.classList.add('drag-over');
|
|
const afterEl = getDragAfterElement(list, e.clientY);
|
|
const dragging = document.querySelector('.dragging');
|
|
if (dragging) {
|
|
if (afterEl) list.insertBefore(dragging, afterEl);
|
|
else list.appendChild(dragging);
|
|
}
|
|
});
|
|
list.addEventListener('dragleave', () => list.classList.remove('drag-over'));
|
|
list.addEventListener('drop', async e => {
|
|
e.preventDefault();
|
|
list.classList.remove('drag-over');
|
|
if (!dragItem) return;
|
|
const items = [];
|
|
document.querySelectorAll('.notes-list').forEach(nl => {
|
|
const colKey = nl.dataset.column;
|
|
nl.querySelectorAll('.note').forEach((n, i) => {
|
|
items.push({ id: parseInt(n.dataset.id), column: colKey, order: i });
|
|
});
|
|
});
|
|
await api('/reorder', { method: 'PUT', body: { items } });
|
|
});
|
|
|
|
(data[col.key] || []).forEach(note => {
|
|
list.appendChild(createNoteEl(note, col.key));
|
|
});
|
|
|
|
colEl.appendChild(header);
|
|
colEl.appendChild(list);
|
|
board.appendChild(colEl);
|
|
});
|
|
}
|
|
|
|
function getDragAfterElement(container, y) {
|
|
const els = [...container.querySelectorAll('.note:not(.dragging)')];
|
|
return els.reduce((closest, child) => {
|
|
const box = child.getBoundingClientRect();
|
|
const offset = y - box.top - box.height / 2;
|
|
if (offset < 0 && offset > closest.offset) return { offset, element: child };
|
|
return closest;
|
|
}, { offset: Number.NEGATIVE_INFINITY }).element;
|
|
}
|
|
|
|
// Touch drag support for mobile
|
|
let touchDragEl = null, touchClone = null, touchStartY = 0, touchStartX = 0;
|
|
document.addEventListener('touchstart', e => {
|
|
const note = e.target.closest('.note');
|
|
if (!note || e.target.closest('.note-text:focus') || e.target.closest('.note-delete') || e.target.closest('.note-check')) return;
|
|
touchStartX = e.touches[0].clientX;
|
|
touchStartY = e.touches[0].clientY;
|
|
touchDragEl = note;
|
|
}, { passive: true });
|
|
|
|
document.addEventListener('touchmove', e => {
|
|
if (!touchDragEl) return;
|
|
const dx = e.touches[0].clientX - touchStartX;
|
|
const dy = e.touches[0].clientY - touchStartY;
|
|
if (!touchClone && (Math.abs(dx) > 10 || Math.abs(dy) > 10)) {
|
|
touchClone = touchDragEl.cloneNode(true);
|
|
touchClone.style.cssText = 'position:fixed;pointer-events:none;z-index:1000;opacity:0.8;width:' + touchDragEl.offsetWidth + 'px;transform:rotate(1deg);';
|
|
document.body.appendChild(touchClone);
|
|
touchDragEl.style.opacity = '0.3';
|
|
}
|
|
if (touchClone) {
|
|
e.preventDefault();
|
|
touchClone.style.left = (e.touches[0].clientX - 20) + 'px';
|
|
touchClone.style.top = (e.touches[0].clientY - 20) + 'px';
|
|
}
|
|
}, { passive: false });
|
|
|
|
document.addEventListener('touchend', async e => {
|
|
if (!touchClone || !touchDragEl) { touchDragEl = null; return; }
|
|
const x = e.changedTouches[0].clientX, y = e.changedTouches[0].clientY;
|
|
touchClone.remove(); touchClone = null;
|
|
touchDragEl.style.opacity = '1';
|
|
const lists = document.querySelectorAll('.notes-list');
|
|
let targetList = null;
|
|
lists.forEach(l => {
|
|
const r = l.getBoundingClientRect();
|
|
if (x >= r.left && x <= r.right && y >= r.top - 50 && y <= r.bottom + 50) targetList = l;
|
|
});
|
|
if (targetList) {
|
|
const afterEl = getDragAfterElement(targetList, y);
|
|
if (afterEl) targetList.insertBefore(touchDragEl, afterEl);
|
|
else targetList.appendChild(touchDragEl);
|
|
const items = [];
|
|
document.querySelectorAll('.notes-list').forEach(nl => {
|
|
nl.querySelectorAll('.note').forEach((n, i) => {
|
|
items.push({ id: parseInt(n.dataset.id), column: nl.dataset.column, order: i });
|
|
});
|
|
});
|
|
await api('/reorder', { method: 'PUT', body: { items } });
|
|
}
|
|
touchDragEl = null;
|
|
});
|
|
|
|
render();
|
|
</script>
|
|
</body>
|
|
</html>
|