Squash boosts into one-liners between comments

This commit is contained in:
Jason Zimdars
2024-08-28 16:12:42 -05:00
parent 4cdf9ee009
commit f51104accc
3 changed files with 31 additions and 21 deletions
+1 -1
View File
@@ -61,7 +61,7 @@
}
.splat__perma & {
--splat-size: 50vh !important;
--splat-size: 40vh !important;
}
}
+12 -18
View File
@@ -1,20 +1,14 @@
<% if comment.is_a?(Boost) %>
<div class="boost flex-inline align-start gap fill-white border-radius center position-relative" id="<%= dom_id(comment) %>">
<%= comment.creator.name %> + 1
</div>
<% else %>
<div class="comment flex align-start gap fill-shade border-radius full-width <%= "comment--mine" if comment.creator == Current.user %>" id="<%= dom_id(comment) %>">
<span class="avatar fill-black txt-reversed flex-item-no-shrink"><strong><%= comment.creator.initials %></strong></span>
<div class="flex flex-column full-width">
<div class="comment__author flex align-center gap-half">
<strong><%= comment.creator.name %></strong>
<%= link_to splat_path(@splat, anchor: "comment_#{comment.id}"), class: "txt-undecorated" do %>
<time class="txt-subtle"><%= comment.created_at.strftime("%b %d").html_safe %></time>
<% end %>
</div>
<div class="comment__body txt-align-start">
<%= simple_format comment.body %>
</div>
<div class="comment flex align-start gap fill-shade border-radius full-width <%= "comment--mine" if comment.creator == Current.user %>" id="<%= dom_id(comment) %>">
<span class="avatar fill-black txt-reversed flex-item-no-shrink"><strong><%= comment.creator.initials %></strong></span>
<div class="flex flex-column full-width">
<div class="comment__author flex align-center gap-half">
<strong><%= comment.creator.name %></strong>
<%= link_to splat_path(@splat, anchor: "comment_#{comment.id}"), class: "txt-undecorated" do %>
<time class="txt-subtle"><%= comment.created_at.strftime("%b %d").html_safe %></time>
<% end %>
</div>
<div class="comment__body txt-align-start">
<%= simple_format comment.body %>
</div>
</div>
<% end %>
</div>
+18 -2
View File
@@ -24,7 +24,23 @@
<%= render @splat %>
</div>
<section class="comments align-center panel center borderless margin-block flex flex-wrap gap" style="--splat-color: <%= @splat.color %>;">
<%= render partial: "comments/comment", collection: (@splat.comments + @splat.boosts).sort_by { |comment| comment.updated_at } %>
<section class="comments align-center panel center borderless margin-block flex flex-wrap gap-half" style="--splat-color: <%= @splat.color %>;">
<% comments = (@splat.comments + @splat.boosts).sort_by(&:updated_at) %>
<% boosts = [] %>
<% comments.each_with_index do |comment, index| %>
<% if comment.is_a?(Boost) %>
<% boosts << comment %>
<% if comments[index + 1].nil? || !comments[index + 1].is_a?(Boost) %>
<% user_boosts = boosts.group_by(&:creator).transform_values(&:count) %>
<div class="boost flex-inline align-start gap fill-white border-radius center position-relative">
<%= user_boosts.map { |user, count| "#{user.name} +#{count}" }.to_sentence %>
</div>
<% boosts.clear %>
<% end %>
<% else %>
<%= render partial: "comments/comment", object: comment %>
<% end %>
<% end %>
<%= render "comments/new" %>
</section>