Skip to content

Commit

Permalink
Add photos with author initials
Browse files Browse the repository at this point in the history
  • Loading branch information
endenwer committed Apr 3, 2016
1 parent 1a18af9 commit 840c44f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/models/telegram_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ def author_name
full_name.present? ? full_name : from_username
end

def author_initials
[from_first_name.first, from_last_name.first].join
end

end
5 changes: 5 additions & 0 deletions app/views/telegram_messages/_message.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<div class="telegram-message" data-sent-at=<%= message.sent_at.to_i %>>
<%= check_box_tag 'telegram_message_ids[]', message.id %>
<time><%= format_time message.sent_at, false %></time>
<div class="telegram-author-photo">
<span>
<%= message.author_initials %>
</span>
</div>
<div class="telegram-message-body">
<span class="telegram-message-author"><%= message.author_name %></span>
<div class="telegram-message-text">
Expand Down
26 changes: 23 additions & 3 deletions assets/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


.telegram-message{
margin: 10px;
padding: 15px 0px;
}

.telegram-message time{
Expand Down Expand Up @@ -42,9 +42,29 @@
}

.telegram-message-text{
word-wrap: break-word;
line-height: 150%;
white-space: pre-wrap;
}

.telegram-author-photo{
width: 42px;
height: 42px;
border-radius: 50%;
overflow: hidden;
margin: 0 15px 0 0;
float: left;
}

.telegram-author-photo span{
line-height: 42px;
display: block;
color: #fff;
text-align: center;
text-transform: uppercase;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background: #80d066;
}

.message-date{
Expand Down

0 comments on commit 840c44f

Please sign in to comment.