docbrown/app/views/users/_comments_section.html.erb
ludwiczakpawel de5a22ecf7
Profile UI update (#11357)
* tooltips 1.0.1

* tooltips 1.0.1

* profile layout

* fix

* whoops

* better github repos

* spec

* brining back doc, and making liitle fixes

* button placement, stats styling

* rename
2020-11-12 08:47:04 +01:00

58 lines
2.2 KiB
Text

<% cache("user-profile-comments-#{@user.last_comment_at}-#{@user.id}-#{@comments.size}", expires_in: 2.days) do %>
<div class="profile-comment-card crayons-card mt-2 m:mt-0 mb-2">
<% if @comments.present? %>
<% if params[:view] == "comments" %>
<div class="crayons-card__header">
<h4 class="crayons-subtitle-2">
<% if @user.comments_count > 250 %>
Last 250 comments
<% else %>
All <%= @user.comments_count %> comments
<% end %>
</h4>
<div class="crayons-card__actions">
<a href="<%= @user.path %>" class="crayons-link--branded fs-base">
View all activity
</a>
</div>
</div>
<% else %>
<div class="crayons-card__header">
<h4 class="crayons-subtitle-2">
Recent comments
</h4>
</div>
<% end %>
<% end %>
<% @comments.each do |comment| %>
<% if comment.commentable.present? && comment.commentable.published && !comment.deleted %>
<a href="<%= comment.path %>" class="profile-comment-row ">
<h5 class="fw-bold fs-base m-0 mb-1">
<%= comment.commentable.title %>
</h5>
<div class="inline-flex items-center fs-s gap-2">
<p class="color-base-80">
<%= truncate(strip_tags(comment.processed_html), length: 64).html_safe %>
<p>
<small class="color-base-60 fs-s comment-date whitespace-nowrap">
<time datetime="<%= comment.decorate.published_timestamp %>"><%= comment.readable_publish_date %></time>
</small>
</div>
</a>
<% end %>
<% end %>
<% if params[:view] != "comments" && @user.comments_count > 250 %>
<div class="pt-3 pl-4 pb-3 pr-4">
<a href="<%= @user.path %>/comments" class="fs-base">
View last 250 Comments
</a>
</div>
<% elsif params[:view] != "comments" && @user.comments_count > 8 %>
<div class="py-3 px-4">
<a href="<%= @user.path %>/comments" class="fs-base">
View all <%= @user.comments_count %> comments
</a>
</div>
<% end %>
</div>
<% end %>