more explicit and versatile usage of avatar_image, changing style option by a direct size - asuming we will always use square images
This commit is contained in:
@@ -1,22 +1,11 @@
|
|||||||
module UsersHelper
|
module UsersHelper
|
||||||
def avatar_image(user, options = {})
|
def avatar_image(user, options = {})
|
||||||
style = options.fetch(:style) { :small }
|
size = options.fetch(:size) { 100 }
|
||||||
klass = options.fetch(:class) { '' }
|
klass = options.fetch(:class) { '' }
|
||||||
round_corners = options.fetch(:round_corners) { true }
|
round_corners = options.fetch(:round_corners) { true }
|
||||||
|
|
||||||
data_attributes = case style
|
data_attributes = { height: size, width: size, "font-size" => (size * 0.6) }
|
||||||
when :profile
|
data_attributes.merge!(radius: (size * 0.13).round) if round_corners
|
||||||
{ height: 100, width: 100 }
|
|
||||||
when :small
|
|
||||||
{ height: 32, width: 32, "font-size" => 20 }
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
|
|
||||||
if round_corners
|
|
||||||
radius = (data_attributes[:height].to_i * 0.13).round
|
|
||||||
data_attributes.merge!(radius: radius)
|
|
||||||
end
|
|
||||||
data_attributes.merge!(name: user.name)
|
data_attributes.merge!(name: user.name)
|
||||||
|
|
||||||
content_tag :img, nil, class: "avatar #{klass}", data: data_attributes
|
content_tag :img, nil, class: "avatar #{klass}", data: data_attributes
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<div class="small-12 medium-6 column">
|
<div class="small-12 medium-6 column">
|
||||||
<h3><%= t("account.show.avatar")%></h3>
|
<h3><%= t("account.show.avatar")%></h3>
|
||||||
<%= avatar_image(@account, style: :profile) %>
|
<%= avatar_image(@account, size: 100) %>
|
||||||
|
|
||||||
<h3><%= t("account.show.notifications")%></h3>
|
<h3><%= t("account.show.notifications")%></h3>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="comment-<%= comment.id %>" class="comment small-12 column">
|
<div id="comment-<%= comment.id %>" class="comment small-12 column">
|
||||||
|
|
||||||
<%= avatar_image(comment.user, style: :small, class: 'left') %>
|
<%= avatar_image(comment.user, size: 32, class: 'left') %>
|
||||||
|
|
||||||
<div class="comment-body">
|
<div class="comment-body">
|
||||||
<span class="comment-info">
|
<span class="comment-info">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<h1><%= @debate.title %></h1>
|
<h1><%= @debate.title %></h1>
|
||||||
|
|
||||||
<div class="debate-info">
|
<div class="debate-info">
|
||||||
<%= avatar_image(@debate.author, style: :small) %>
|
<%= avatar_image(@debate.author, size: 32) %>
|
||||||
<span class="author">
|
<span class="author">
|
||||||
<%= @debate.author.name %>
|
<%= @debate.author.name %>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user