Try a more Basecamp style activity event card

This commit is contained in:
Jason Zimdars
2025-02-19 14:02:07 -06:00
parent 0fc85f11a5
commit b3b881da17
5 changed files with 33 additions and 41 deletions
+5
View File
@@ -81,6 +81,11 @@
margin-block-start: calc(var(--grid-lines) * -1);
}
.event__title {
font-size: 1.1em;
line-height: 1.2;
}
.event__wrapper {
align-content: end;
display: grid;
+1
View File
@@ -39,6 +39,7 @@
.txt-nowrap { white-space: nowrap; }
.txt-break { word-break: break-word; }
.txt-uppercase { text-transform: uppercase; }
.txt-link { color: var(--color-link); text-decoration: underline; }
/* Flexbox and Grid */
.justify-end { justify-content: end; }
+11 -28
View File
@@ -67,44 +67,27 @@ module EventsHelper
def event_action_sentence(event)
case event.action
when "assigned"
"Assigned to <strong>#{ event.assignees.pluck(:name).to_sentence }</strong>".html_safe
"#{ event.creator.name } assigned #{ event.assignees.pluck(:name).to_sentence } to <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "unassigned"
"Unassigned <strong>#{ event.assignees.pluck(:name).to_sentence }</strong>".html_safe
"#{ event.creator.name } unassigned #{ event.assignees.pluck(:name).to_sentence } from <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "boosted"
"Boosted by <strong>#{ event.creator.name }</strong>".html_safe
"#{ event.creator.name } boosted <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "commented"
"#{ strip_tags(event.comment.body_html).blank? ? "<strong>#{ event.creator.name }</strong> replied.".html_safe : "<strong>#{ event.creator.name }:</strong>" } #{ strip_tags(event.comment.body_html).truncate(200) }".html_safe
"#{ event.creator.name } commented on <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "published"
"Added by <strong>#{ event.creator.name }</strong>".html_safe
"#{ event.creator.name } added <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "popped"
"Popped by <strong>#{ event.creator.name }</strong>".html_safe
"#{ event.creator.name } popped <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "staged"
"<strong>#{event.creator.name}</strong> moved to #{event.stage_name}.".html_safe
"#{event.creator.name} changed the stage to #{event.stage_name} on <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "due_date_added"
"<strong>#{event.creator.name}</strong> set the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}".html_safe
"#{event.creator.name} set the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')} on <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "due_date_changed"
"<strong>#{event.creator.name}</strong> changed the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}".html_safe
"#{event.creator.name} changed the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')} on <span class='txt-link'>#{ event.bubble.title }</span>".html_safe
when "due_date_removed"
"#{event.creator.name} removed the date"
"#{event.creator.name} removed the date on <span class='txt-link'>#{ event.bubble.title }</span>"
when "title_changed"
"<strong>#{event.creator.name}</strong> renamed this (was: '#{event.particulars.dig('particulars', 'old_title')})'".html_safe
end
end
def event_action_icon(event)
case event.action
when "assigned"
"arrow-right"
when "boosted"
"thumb-up"
when "staged"
"bolt"
when "unassigned"
"remove-med"
when "due_date_added", "due_date_changed"
"calendar"
else
"person"
"#{event.creator.name} renamed on <span class='txt-link'>#{ event.bubble.title }</span> (was: '#{event.particulars.dig('particulars', 'old_title')})'".html_safe
end
end
end
+14 -11
View File
@@ -10,18 +10,21 @@
animation_play_class: "bubble--wobble",
animation_play_on_load_value: "true",
action: "mouseover->animation#play mouseover->related-element#highlight mouseout->related-element#unhighlight" } do %>
<div class="bubble__shape flex-item-no-shrink txt-large"></div>
<div class="avatar txt-x-small flex-item-no-shrink">
<%= avatar_image_tag(event.creator) %>
</div>
<div class="flex flex-column min-width txt-small txt-tight-lines align-start txt-align-start">
<strong style="font-size: 1.1em;" class="txt-break overflow-line-clamp">
<%= event.action == "commented" ? "RE: #{ bubble.title }" : bubble.title %>
<div class="flex flex-column min-width txt-small align-start txt-align-start">
<strong class="event__title txt-break overflow-line-clamp">
<%= event_action_sentence(event) %>
</strong>
<span class="flex align-center gap-half align-start">
<% if event_column(event) == 1 %>
<span class="flex-item-no-shrink"><%= image_tag "#{event_action_icon(event)}.svg", aria: { hidden: true }, size: 13, class: "colorize--black" %></span>
<% end %>
<span class="txt-break overflow-line-clamp" style="--lines: 3;"><%= event_action_sentence(event) %></span>
</span>
<span class="translucent"><%= bubble.bucket.name %></span>
<% if event.action == "commented" && !strip_tags(event&.comment&.body_html).blank? %>
<span class="txt-break overflow-line-clamp">
<%= strip_tags(event.comment.body_html).truncate(200) -%>
</span>
<% end %>
<span class="event__bucket translucent"><%= bubble.bucket.name %></span>
</div>
<% end %>
+2 -2
View File
@@ -12,7 +12,7 @@ class EventsControllerTest < ActionDispatch::IntegrationTest
get events_url
assert_select "div.event__wrapper[style='grid-area: 17/1']" do
assert_select "strong", text: "Layout is broken"
assert_select "strong", text: "David assigned JZ to Layout is broken"
end
end
@@ -22,7 +22,7 @@ class EventsControllerTest < ActionDispatch::IntegrationTest
get events_url
assert_select "div.event__wrapper[style='grid-area: 22/1']" do
assert_select "strong", text: "Layout is broken"
assert_select "strong", text: "David assigned JZ to Layout is broken"
end
end
end