Skip to content

Commit 840d3d4

Browse files
committed
add sticky toolbox & flashes
1 parent a57a38f commit 840d3d4

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/note_mark/static/style.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ input {
187187

188188
/* flash styles */
189189
.flashes {
190+
position: fixed;
191+
float: right;
192+
top: 10px;
193+
right: 0;
194+
z-index: 99;
190195
display: flex;
191196
flex-direction: column;
192197
gap: 2px;
@@ -242,6 +247,14 @@ input {
242247
flex-wrap: nowrap;
243248
}
244249

250+
.sticky-control-bar {
251+
position: fixed;
252+
float: right;
253+
top: 10px;
254+
left: 5px;
255+
z-index: 2;
256+
}
257+
245258
#note-content {
246259
width: 100%;
247260
background-color: var(--bg-body2);

src/note_mark/static/textarea-edit.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ const text_area = document.getElementById("edit-note-content");
66
text_area.style.height = (text_area.scrollHeight + "px");
77
text_area.addEventListener("input", _event => { auto_resize_elem(text_area); });
88

9+
const toolbox = document.getElementById("edit-toolbox");
10+
const toolbox_offset = toolbox.offsetTop;
11+
window.addEventListener("scroll", toggle_sticky_toolbox);
12+
13+
/**
14+
* allow for the toolbox to stick to
15+
* top of page when it goes out of view
16+
*/
17+
function toggle_sticky_toolbox() {
18+
if (window.pageYOffset >= toolbox_offset) {
19+
toolbox.classList.add("sticky-control-bar")
20+
} else {
21+
toolbox.classList.remove("sticky-control-bar");
22+
}
23+
}
24+
925
/**
1026
* adds a event listener for handling auto-save,
1127
* should only be called once

src/note_mark/templates/personal-home/note/edit.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<button onclick="ask_before_get(`{{ url_for('personal_home.delete_note', notebook_uuid=note.notebook_id, note_uuid=note.uuid)}}`)">Delete</button>
1010
</div>
1111
<form class="container" id="form-edit-note" action="" method="post">
12-
<div class="control-bar">
12+
<div class="control-bar" id="edit-toolbox">
1313
<button type="submit">Save</button>
1414
{% include "/shared/includes/edit-toolbox.jinja2" %}
1515
</div>

src/note_mark/templates/share-link/note/edit.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a class="button" href="{{ url_for('share_link.view_note', share_link_uuid=share_link_uuid, note_uuid=note.uuid) }}">View</a>
1111
</div>
1212
<form class="container" id="form-edit-note" action="" method="post">
13-
<div class="control-bar">
13+
<div class="control-bar" id="edit-toolbox">
1414
<button type="submit">Save</button>
1515
{% include "/shared/includes/edit-toolbox.jinja2" %}
1616
</div>

0 commit comments

Comments
 (0)