client/posts: reorder elements in mobile layout

Navigation is always right below the image, and comments are always
at the very bottom, to minimize scrolling for common actions.
This commit is contained in:
Eva 2023-05-20 18:00:01 +02:00
parent 6b0c3cfc7f
commit 4b6b231fc8
3 changed files with 65 additions and 36 deletions

View file

@ -15,7 +15,7 @@
border: 0 border: 0
outline: 0 outline: 0
nav.buttons >.sidebar>nav.buttons, >.content nav.buttons
margin-top: 0 margin-top: 0
display: flex display: flex
flex-wrap: wrap flex-wrap: wrap
@ -34,19 +34,23 @@
font-size: 140% font-size: 140%
text-align: center text-align: center
@media (max-width: 800px) @media (max-width: 800px)
margin-top: 2em margin-top: 0.6em
margin-bottom: 0.6em
>.content >.content
width: 100% width: 100%
.post-container .post-container
margin-bottom: 2em margin-bottom: 0.6em
.post-content .post-content
margin: 0 margin: 0
.after-mobile-controls
width: 100%
.darktheme .post-view .darktheme .post-view
>.sidebar >.sidebar, >.content
nav.buttons nav.buttons
article article
a:not(.inactive):hover a:not(.inactive):hover
@ -56,6 +60,8 @@
@media (max-width: 800px) @media (max-width: 800px)
.post-view .post-view
flex-wrap: wrap flex-wrap: wrap
>.after-mobile-controls
order: 3
>.sidebar >.sidebar
order: 2 order: 2
min-width: 100% min-width: 100%
@ -113,7 +119,6 @@
h1 h1
margin-bottom: 0.5em margin-bottom: 0.5em
.thumbnail .thumbnail
background-position: 50% 30%
width: 4em width: 4em
height: 3em height: 3em
li li

View file

@ -29,6 +29,7 @@
<span class='vim-nav-hint'>Next post &gt;</span> <span class='vim-nav-hint'>Next post &gt;</span>
</a> </a>
</article> </article>
<% if (ctx.canEditPosts || ctx.canDeletePosts || ctx.canFeaturePosts) { %>
<article class='edit-post'> <article class='edit-post'>
<% if (ctx.editMode) { %> <% if (ctx.editMode) { %>
<a href='<%= ctx.getPostUrl(ctx.post.id, ctx.parameters) %>'> <a href='<%= ctx.getPostUrl(ctx.post.id, ctx.parameters) %>'>
@ -36,16 +37,13 @@
<span class='vim-nav-hint'>Back to view mode</span> <span class='vim-nav-hint'>Back to view mode</span>
</a> </a>
<% } else { %> <% } else { %>
<% if (ctx.canEditPosts || ctx.canDeletePosts || ctx.canFeaturePosts) { %>
<a href='<%= ctx.getPostEditUrl(ctx.post.id, ctx.parameters) %>'> <a href='<%= ctx.getPostEditUrl(ctx.post.id, ctx.parameters) %>'>
<% } else { %>
<a class='inactive'>
<% } %>
<i class='fa fa-pencil'></i> <i class='fa fa-pencil'></i>
<span class='vim-nav-hint'>Edit post</span> <span class='vim-nav-hint'>Edit post</span>
</a> </a>
<% } %> <% } %>
</article> </article>
<% } %>
</nav> </nav>
<div class='sidebar-container'></div> <div class='sidebar-container'></div>
@ -54,13 +52,15 @@
<div class='content'> <div class='content'>
<div class='post-container'></div> <div class='post-container'></div>
<% if (ctx.canListComments) { %> <div class='after-mobile-controls'>
<div class='comments-container'></div>
<% } %>
<% if (ctx.canCreateComments) { %> <% if (ctx.canCreateComments) { %>
<h2>Add comment</h2> <h2>Add comment</h2>
<div class='comment-form-container'></div> <div class='comment-form-container'></div>
<% } %> <% } %>
<% if (ctx.canListComments) { %>
<div class='comments-container'></div>
<% } %>
</div>
</div> </div>
</div> </div>

View file

@ -103,6 +103,30 @@ class PostContentControl {
} }
_refreshSize() { _refreshSize() {
if (window.innerWidth <= 800) {
const buttons = document.querySelector(".sidebar > .buttons");
if (buttons) {
const content = document.querySelector(".content");
content.insertBefore(buttons, content.querySelector(".post-container + *"));
const afterControls = document.querySelector(".content > .after-mobile-controls");
if (afterControls) {
afterControls.parentElement.parentElement.appendChild(afterControls);
}
}
} else {
const buttons = document.querySelector(".content > .buttons");
if (buttons) {
const sidebar = document.querySelector(".sidebar");
sidebar.insertBefore(buttons, sidebar.firstElementChild);
}
const afterControls = document.querySelector(".content + .after-mobile-controls");
if (afterControls) {
document.querySelector(".content").appendChild(afterControls);
}
}
this._currentFitFunction(); this._currentFitFunction();
} }