feat: enhance comment button visibility and interaction in UIManager

This commit is contained in:
2025-01-25 19:51:35 +02:00
parent e59feebcf1
commit dbb02ba4e1
2 changed files with 48 additions and 51 deletions

View File

@@ -57,6 +57,15 @@ export class UIManager {
const buttonsDiv = document.createElement('div'); const buttonsDiv = document.createElement('div');
buttonsDiv.className = 'snippet-buttons'; buttonsDiv.className = 'snippet-buttons';
const commentButton = this.createButton('💬', 'comment-snippet', (e) => {
e.stopPropagation();
this.openCommentModal(snippet.id);
});
if (snippet.comment && snippet.comment.trim() !== '') {
commentButton.classList.add('has-comment');
}
buttonsDiv.appendChild(commentButton);
buttonsDiv.appendChild(this.createButton('✏️', 'edit-snippet', (e) => { buttonsDiv.appendChild(this.createButton('✏️', 'edit-snippet', (e) => {
e.stopPropagation(); e.stopPropagation();
this.snippetManager.renameSnippet(snippet.id); this.snippetManager.renameSnippet(snippet.id);
@@ -72,15 +81,6 @@ export class UIManager {
this.snippetManager.duplicateSnippet(snippet.id); this.snippetManager.duplicateSnippet(snippet.id);
})); }));
const commentButton = this.createButton('💬', 'comment-snippet', (e) => {
e.stopPropagation();
this.openCommentModal(snippet.id);
});
if (snippet.comment && snippet.comment.trim() !== '') {
commentButton.classList.add('has-comment');
}
buttonsDiv.appendChild(commentButton);
div.appendChild(buttonsDiv); div.appendChild(buttonsDiv);
container.appendChild(div); container.appendChild(div);
}); });

View File

@@ -210,22 +210,44 @@
white-space: nowrap; white-space: nowrap;
} }
.delete-snippet { .delete-snippet,
opacity: 0.4; .edit-snippet,
.duplicate-snippet,
.comment-snippet {
opacity: 0.2;
font-size: 14px; font-size: 14px;
padding: 2px 4px; padding: 2px 4px;
background: none; background: none;
border: none; border: none;
cursor: pointer; cursor: pointer;
min-width: 24px; min-width: 24px;
transition: opacity 0.2s;
} }
.delete-snippet:hover { .snippet-item:hover .delete-snippet,
.snippet-item:hover .edit-snippet,
.snippet-item:hover .duplicate-snippet,
.snippet-item:hover .comment-snippet {
opacity: 0.6;
}
.snippet-item.active .delete-snippet,
.snippet-item.active .edit-snippet,
.snippet-item.active .duplicate-snippet,
.snippet-item.active .comment-snippet {
opacity: 1; opacity: 1;
} }
.snippet-item:hover .delete-snippet { .comment-snippet.has-comment {
opacity: 0.8; opacity: 0.4;
}
.snippet-item:hover .comment-snippet.has-comment {
opacity: 0.6;
}
.snippet-item.active .comment-snippet.has-comment {
opacity: 1;
} }
.snippet-buttons { .snippet-buttons {
@@ -233,42 +255,6 @@
gap: 4px; gap: 4px;
} }
.edit-snippet {
opacity: 0.4;
font-size: 14px;
padding: 2px 4px;
background: none;
border: none;
cursor: pointer;
min-width: 24px;
}
.edit-snippet:hover {
opacity: 1;
}
.snippet-item:hover .edit-snippet {
opacity: 0.8;
}
.duplicate-snippet {
opacity: 0.4;
font-size: 14px;
padding: 2px 4px;
background: none;
border: none;
cursor: pointer;
min-width: 24px;
}
.duplicate-snippet:hover {
opacity: 1;
}
.snippet-item:hover .duplicate-snippet {
opacity: 0.8;
}
.comment-modal { .comment-modal {
display: none; display: none;
position: fixed; position: fixed;
@@ -308,16 +294,27 @@
} }
.comment-snippet { .comment-snippet {
opacity: 0.4; opacity: 0;
font-size: 14px; font-size: 14px;
padding: 2px 4px; padding: 2px 4px;
background: none; background: none;
border: none; border: none;
cursor: pointer; cursor: pointer;
min-width: 24px; min-width: 24px;
transition: opacity 0.2s;
} }
.comment-snippet.has-comment { .comment-snippet.has-comment {
opacity: 0.4;
}
.snippet-item:hover .comment-snippet,
.snippet-item.active .comment-snippet {
opacity: 0.4;
}
.snippet-item:hover .comment-snippet.has-comment,
.snippet-item.active .comment-snippet.has-comment {
opacity: 1; opacity: 1;
} }