Skip to content

Commit 02d16d0

Browse files
committed
feat(note_tooltip): improve layout for empty notes
1 parent f77a29d commit 02d16d0

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Diff for: src/public/app/services/note_tooltip.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,28 @@ async function renderTooltip(note: FNote | null) {
140140
}
141141

142142
const noteTitleWithPathAsSuffix = await treeService.getNoteTitleWithPathAsSuffix(bestNotePath);
143-
let content = "";
144-
if (noteTitleWithPathAsSuffix) {
145-
content = `<h5 class="note-tooltip-title">${noteTitleWithPathAsSuffix.prop("outerHTML")}</h5>`;
146-
}
147143

148144
const { $renderedAttributes } = await attributeRenderer.renderNormalAttributes(note);
149145

150146
const { $renderedContent } = await contentRenderer.getRenderedContent(note, {
151147
tooltip: true,
152148
trim: true
153149
});
150+
const isContentEmpty = ($renderedContent[0].innerHTML.length === 0);
154151

155-
content = `${content}<div class="note-tooltip-attributes">${$renderedAttributes[0].outerHTML}</div>${$renderedContent[0].outerHTML}`;
152+
let content = "";
153+
if (noteTitleWithPathAsSuffix) {
154+
const classes = [ "note-tooltip-title" ];
155+
if (isContentEmpty) {
156+
classes.push("note-no-content");
157+
}
158+
content = `<h5 class="${classes.join(" ")}">${noteTitleWithPathAsSuffix.prop("outerHTML")}</h5>`;
159+
}
160+
161+
content = `${content}<div class="note-tooltip-attributes">${$renderedAttributes[0].outerHTML}</div>`;
162+
if (!isContentEmpty) {
163+
content += $renderedContent[0].outerHTML;
164+
}
156165

157166
return content;
158167
}

Diff for: src/public/stylesheets/theme-next/shell.css

+10-2
Original file line numberDiff line numberDiff line change
@@ -1206,13 +1206,21 @@ body .calendar-dropdown-widget .calendar-body a:hover {
12061206

12071207
.note-tooltip-content {
12081208
padding: 8px;
1209+
min-height: 56px;
12091210
}
12101211

1211-
.note-tooltip-content .note-title-with-path {
1212+
.note-tooltip-title .note-title-with-path {
12121213
display: flex;
12131214
flex-direction: column-reverse;
1214-
border-bottom: 2px solid currentColor;
1215+
}
1216+
1217+
.note-tooltip-title.note-no-content {
1218+
margin: 0;
1219+
}
1220+
1221+
.note-tooltip-title:not(.note-no-content) .note-title-with-path {
12151222
padding-bottom: 6px;
1223+
border-bottom: 2px solid currentColor;
12161224
}
12171225

12181226
.note-tooltip-content .note-path {

0 commit comments

Comments
 (0)