colors
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m7s

This commit is contained in:
2026-10-11 22:50:37 +02:00
parent 1fab8ce20d
commit f3fb4ad534
9 changed files with 104 additions and 16 deletions

View File

@@ -73,6 +73,16 @@ onMounted(() => {
height: 16px;
}
.context-menu-swatch {
width: 14px;
height: 14px;
flex-grow: 0;
padding-right: 0;
border-radius: 4px;
border: 1px solid var(--color-border);
flex-shrink: 0;
}
&:hover {
background-color: var(--color-background-softest);
}

View File

@@ -143,11 +143,11 @@ async function fetchCampaignNotes() {
}
folders.value = response.data.folders.map((folder) => ({
_id: folder._id, name: folder.name, date: folder.date
_id: folder._id, name: folder.name, date: folder.date, color: folder.color
}));
notes.value = response.data.notes.map((note) => {
return { key: note._id, title: note.title, text: note.content ?? '', date: note.date };
return { key: note._id, title: note.title, text: note.content ?? '', date: note.date, color: note.color };
});
} catch (error) {
notes.value = [];

View File

@@ -20,6 +20,18 @@ const emit = defineEmits(['open-note', 'reload-notes']);
const loadingFolders = new Set();
const dragHoveredFolderId = ref(null);
// Preset colors for notes and folders (shown as swatches in the context menu)
const entryColors = [
{ name: 'Red', value: '#e74c3c' },
{ name: 'Orange', value: '#e67e22' },
{ name: 'Yellow', value: '#f1c40f' },
{ name: 'Green', value: '#2ecc71' },
{ name: 'Teal', value: '#1abc9c' },
{ name: 'Blue', value: '#3498db' },
{ name: 'Purple', value: '#9b59b6' },
{ name: 'Pink', value: '#fd79a8' }
];
// Cache of loaded folder contents — persists across reloads until cleared
// Each entry: { [folderId]: { notes: [], subfolders: [] } }
const folderContentCache = ref({});
@@ -96,7 +108,7 @@ function loadFolderContents(folderId) {
.then(res => {
if (res.data.status !== 'ok') return;
folderContentCache.value[folderId] = {
notes: res.data.notes.map(n => ({ key: n._id, title: n.title, text: n.content || '' })),
notes: res.data.notes.map(n => ({ key: n._id, title: n.title, text: n.content || '', color: n.color })),
subfolders: res.data.subfolders || []
};
}).catch(() => {}).finally(() => {
@@ -183,6 +195,7 @@ function buildNoteContextMenu(note) {
return [
{ name: 'Open', icon: '/icons/iconoir/regular/book.svg', action: () => emit('open-note', note) },
{ name: 'Rename', icon: '/icons/iconoir/regular/edit-pencil.svg', action: () => renameNote(note) },
{ name: 'Color', icon: '/icons/iconoir/regular/palette.svg', context: buildColorMenu('note', note) },
{
name: 'Move to Folder...', icon: '/icons/iconoir/regular/folder.svg',
context: buildMoveToMenu(note)
@@ -197,10 +210,39 @@ function buildFolderContextMenu(folder) {
return [
{ name: 'New Note Here', icon: '/icons/iconoir/regular/plus.svg', action: () => createNoteInFolder(folder._id) },
{ name: 'Rename', icon: '/icons/iconoir/regular/edit-pencil.svg', action: () => renameFolder(folder._id, folder.name) },
{ name: 'Color', icon: '/icons/iconoir/regular/palette.svg', context: buildColorMenu('folder', folder) },
{ name: 'Delete Folder', icon: '/icons/iconoir/regular/trash.svg', action: () => deleteFolder(folder._id) }
];
}
function buildColorMenu(kind, item) {
const colorItems = entryColors.map((color) => ({
name: color.name, color: color.value, action: () => setEntryColor(kind, item, color.value)
}));
colorItems.push({ divider: true });
colorItems.push({ name: 'Default', icon: '/icons/iconoir/regular/xmark-circle.svg', action: () => setEntryColor(kind, item, null) });
return colorItems;
}
async function setEntryColor(kind, item, color) {
const isNote = kind === 'note';
try {
const response = await Server().post(isNote ? '/note/update' : '/folder/update', {
id: isNote ? item.key : item._id,
color
});
if (response.data.status !== 'ok') return;
item.color = color;
} catch (e) {} finally {
HideContextMenu();
}
}
function entryColorStyle(item) {
return item.color ? { '--entry-color': item.color } : null;
}
let selectedNoteForMove = {};
function buildMoveToMenu(note) {
@@ -259,7 +301,7 @@ function createNoteInFolder(folderId) {
@dragover.prevent="setDragHover(folder._id)"
@dragleave.self="clearDragHover"
@drop.stop="handleDropNoteOnFolder(folder._id, $event)">
<button type="button" class="folder-toggle" @click="toggleExpanded(folder._id)" @contextmenu.prevent="ShowContextMenu(buildFolderContextMenu(folder))">
<button type="button" class="folder-toggle" :class="{ 'has-color': !!folder.color }" :style="entryColorStyle(folder)" @click="toggleExpanded(folder._id)" @contextmenu.prevent="ShowContextMenu(buildFolderContextMenu(folder))">
<img
class="folder-arrow"
:src="expandedFolderIds.includes(folder._id) ? '/icons/iconoir/regular/nav-arrow-down.svg' : '/icons/iconoir/regular/nav-arrow-right.svg'"
@@ -297,7 +339,7 @@ function createNoteInFolder(folderId) {
<!-- Notes at this level -->
<template v-for="note in notes" :key="note.key">
<button type="button" class="note-link" draggable="true" @dragstart="startDragNote($event, note)" @click.stop="$emit('open-note', note)" @contextmenu.prevent="ShowContextMenu(buildNoteContextMenu(note))">
<button type="button" class="note-link" :class="{ 'has-color': !!note.color }" :style="entryColorStyle(note)" draggable="true" @dragstart="startDragNote($event, note)" @click.stop="$emit('open-note', note)" @contextmenu.prevent="ShowContextMenu(buildNoteContextMenu(note))">
<span class="note-link-title">{{ note.title }}</span>
</button>
</template>
@@ -318,6 +360,8 @@ function createNoteInFolder(folderId) {
.folder-toggle { width: 100%; padding: 6px 8px; margin: 0; border: none; background: transparent; display: flex; align-items: center; gap: 6px; cursor: grab; border-radius: 10px; color: var(--color-text); font-size: inherit; transition: background-color 0.15s ease; }
.folder-toggle:hover { background: var(--color-background-soft); }
.folder-toggle.has-color { background: color-mix(in srgb, var(--entry-color) 32%, transparent); }
.folder-toggle.has-color:hover { background: color-mix(in srgb, var(--entry-color) 50%, transparent); }
.folder-arrow { width: 14px; height: 14px; filter: invert(var(--color-icon-invert)); opacity: 0.5; }
.folder-icon { width: 16px; height: 16px; filter: invert(var(--color-icon-invert)); }
@@ -326,7 +370,9 @@ function createNoteInFolder(folderId) {
.folder-children { padding-left: 20px; margin-top: 2px; cursor: default; }
.folder-children.drag-over { background: #ffffff22; border-radius: 10px; }
.note-link { width: 100%; padding: 6px; margin: 0; box-shadow: none; border: none; display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: grab; }
.note-link { width: 100%; padding: 6px; margin: 0; box-shadow: none; border: none; display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: grab; border-radius: 8px; }
.note-link.has-color { background: color-mix(in srgb, var(--entry-color) 32%, transparent); }
.note-link.has-color:hover { background: color-mix(in srgb, var(--entry-color) 50%, transparent); }
.note-link-title { font-weight: 600; word-break: break-word; }
.sidebar-state { padding: 12px; border-radius: 10px; background: var(--color-background-soft); font-size: 14px; }