post previews: fix thumbnail width/height outside post index.

Normally thumbnails have a fixed size of 154x154, but that's not always
desirable outside of the posts index because it creates empty gaps
around thumbnails.
This commit is contained in:
evazion
2019-10-14 21:16:04 -05:00
parent 5b0c77d126
commit f7116ad1c4
5 changed files with 9 additions and 4 deletions

View File

@@ -74,7 +74,6 @@ $tooltip-width: 164px * 3 - 10; // 3 thumbnails wide.
article.post-preview { article.post-preview {
margin: 0 8px 0 0; margin: 0 8px 0 0;
height: auto;
} }
} }

View File

@@ -42,6 +42,11 @@ article.post-preview {
vertical-align: text-top; vertical-align: text-top;
} }
&.post-preview-compact {
width: auto;
height: auto;
}
.desc { .desc {
font-size: 80%; font-size: 80%;
margin-bottom: 0; margin-bottom: 0;

View File

@@ -89,7 +89,7 @@ class PostPresenter < Presenter
ApplicationController.render(partial: "posts/partials/index/preview", locals: locals) ApplicationController.render(partial: "posts/partials/index/preview", locals: locals)
end end
def self.preview_class(post, highlight_score: nil, pool: nil, size: nil, similarity: nil, **options) def self.preview_class(post, highlight_score: nil, pool: nil, size: nil, similarity: nil, compact: nil, **options)
klass = ["post-preview"] klass = ["post-preview"]
# klass << " large-cropped" if post.has_cropped? && options[:show_cropped] # klass << " large-cropped" if post.has_cropped? && options[:show_cropped]
klass << "captioned" if pool || size || similarity klass << "captioned" if pool || size || similarity
@@ -100,6 +100,7 @@ class PostPresenter < Presenter
klass << "post-status-has-children" if post.has_visible_children? klass << "post-status-has-children" if post.has_visible_children?
klass << "post-pos-score" if highlight_score && post.score >= 3 klass << "post-pos-score" if highlight_score && post.score >= 3
klass << "post-neg-score" if highlight_score && post.score <= -3 klass << "post-neg-score" if highlight_score && post.score <= -3
klass << "post-preview-compact" if compact
klass klass
end end

View File

@@ -3,7 +3,7 @@
<p class="fineprint">Found <%= pluralize(@matches.length, "similar post") %>:</p> <p class="fineprint">Found <%= pluralize(@matches.length, "similar post") %>:</p>
<% @matches.each do |match| %> <% @matches.each do |match| %>
<%= PostPresenter.preview(match["post"], :tags => "status:any", :similarity => match["score"], :size => true) %> <%= PostPresenter.preview(match["post"], tags: "status:any", similarity: match["score"], size: true, compact: true) %>
<% end %> <% end %>
<% else %> <% else %>
<h3>Similar Posts</h3> <h3>Similar Posts</h3>

View File

@@ -38,7 +38,7 @@
<div class="post-tooltip-body <%= "has-preview" if params[:preview].truthy? %>"> <div class="post-tooltip-body <%= "has-preview" if params[:preview].truthy? %>">
<div class="post-tooltip-body-left"> <div class="post-tooltip-body-left">
<% if params[:preview].truthy? %> <% if params[:preview].truthy? %>
<%= PostPresenter.preview(@post, show_deleted: true) %> <%= PostPresenter.preview(@post, show_deleted: true, compact: true) %>
<% end %> <% end %>
</div> </div>