diff --git a/bookmarks/frontend/behaviors/bookmark-page.js b/bookmarks/frontend/behaviors/bookmark-page.js index eb160b28..4b5574f4 100644 --- a/bookmarks/frontend/behaviors/bookmark-page.js +++ b/bookmarks/frontend/behaviors/bookmark-page.js @@ -59,10 +59,18 @@ class BookmarkItem { constructor(element) { this.element = element; + // Toggle notes const notesToggle = element.querySelector(".toggle-notes"); if (notesToggle) { notesToggle.addEventListener("click", this.onToggleNotes.bind(this)); } + + // Add tooltip to title if it is truncated + const titleAnchor = element.querySelector(".title > a"); + const titleSpan = titleAnchor.querySelector("span"); + if (titleSpan.offsetWidth > titleAnchor.offsetWidth) { + titleAnchor.dataset.tooltip = titleSpan.textContent; + } } onToggleNotes(event) { diff --git a/bookmarks/styles/bookmark-page.scss b/bookmarks/styles/bookmark-page.scss index 3a21d9b5..983b4281 100644 --- a/bookmarks/styles/bookmark-page.scss +++ b/bookmarks/styles/bookmark-page.scss @@ -107,6 +107,18 @@ ul.bookmark-list { padding: 0; } +@keyframes appear { + 0% { + opacity: 0; + } + 90% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + /* Bookmarks */ li[ld-bookmark-item] { position: relative; @@ -122,6 +134,27 @@ li[ld-bookmark-item] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + + &[data-tooltip]:hover::after, &[data-tooltip]:focus::after { + content: attr(data-tooltip); + position: absolute; + z-index: 10; + top: 20px; + left: 50%; + transform: translateX(-50%); + width: max-content; + max-width: 100%; + height: fit-content; + background-color: #292f62; + color: #fff; + padding: $unit-1; + border-radius: $border-radius; + border: 1px solid #424a8c; + font-size: $font-size-sm; + font-style: normal; + white-space: normal; + animation: 0.3s ease 0s appear; + } } &.unread .title a { diff --git a/bookmarks/templates/bookmarks/bookmark_list.html b/bookmarks/templates/bookmarks/bookmark_list.html index 5b448439..c5b6c0a2 100644 --- a/bookmarks/templates/bookmarks/bookmark_list.html +++ b/bookmarks/templates/bookmarks/bookmark_list.html @@ -14,11 +14,11 @@
- + {% if bookmark_item.favicon_file and bookmark_list.show_favicons %} {% endif %} - {{ bookmark_item.title }} + {{ bookmark_item.title }}
{% if bookmark_list.show_url %} diff --git a/bookmarks/tests/test_bookmarks_list_template.py b/bookmarks/tests/test_bookmarks_list_template.py index af5d9d58..f897ad33 100644 --- a/bookmarks/tests/test_bookmarks_list_template.py +++ b/bookmarks/tests/test_bookmarks_list_template.py @@ -24,7 +24,7 @@ def assertBookmarksLink(self, html: str, bookmark: Bookmark, link_target: str = target="{link_target}" rel="noopener"> {favicon_img} - {bookmark.resolved_title} + {bookmark.resolved_title} ''', html