Extract component to render an initialjs avatar
This way it'll be easier to change it.
This commit is contained in:
1
app/components/shared/avatar_component.html.erb
Normal file
1
app/components/shared/avatar_component.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= avatar_image(record, options) %>
|
||||||
23
app/components/shared/avatar_component.rb
Normal file
23
app/components/shared/avatar_component.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
class Shared::AvatarComponent < ApplicationComponent
|
||||||
|
attr_reader :record, :given_options
|
||||||
|
delegate :avatar_image, to: :helpers
|
||||||
|
|
||||||
|
def initialize(record, **given_options)
|
||||||
|
@record = record
|
||||||
|
@given_options = given_options
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def default_options
|
||||||
|
{ seed: seed }
|
||||||
|
end
|
||||||
|
|
||||||
|
def options
|
||||||
|
default_options.merge(given_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def seed
|
||||||
|
record.id
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<%= link_to t("account.show.erase_account_link"), users_registrations_delete_form_path, class: "delete" %>
|
<%= link_to t("account.show.erase_account_link"), users_registrations_delete_form_path, class: "delete" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= avatar_image(@account, seed: @account.id, size: 100, class: "margin-bottom") %>
|
<%= render Shared::AvatarComponent.new(@account, size: 100, class: "margin-bottom") %>
|
||||||
|
|
||||||
<h1 class="inline-block"><%= t("account.show.title") %></h1>
|
<h1 class="inline-block"><%= t("account.show.title") %></h1>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<% elsif comment.user.organization? %>
|
<% elsif comment.user.organization? %>
|
||||||
<%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %>
|
<%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= avatar_image(comment.user, seed: comment.user_id, size: 32, class: "float-left") %>
|
<%= render Shared::AvatarComponent.new(comment.user, size: 32, class: "float-left") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="comment-body">
|
<div class="comment-body">
|
||||||
<div class="comment-info">
|
<div class="comment-info">
|
||||||
|
|
||||||
<%= avatar_image(participant, seed: participant.id, size: 32, class: "author-photo") %>
|
<%= render Shared::AvatarComponent.new(participant, size: 32, class: "author-photo") %>
|
||||||
|
|
||||||
<div class="comment-info">
|
<div class="comment-info">
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<%= t("shared.author_info.author_deleted") %>
|
<%= t("shared.author_info.author_deleted") %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= avatar_image(resource.author, seed: resource.author_id, size: 32, class: "author-photo") %>
|
<%= render Shared::AvatarComponent.new(resource.author, size: 32, class: "author-photo") %>
|
||||||
<span class="author">
|
<span class="author">
|
||||||
<%= link_to resource.author.name, user_path(resource.author) %>
|
<%= link_to resource.author.name, user_path(resource.author) %>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<h2 class="inline-block">
|
<h2 class="inline-block">
|
||||||
<%= avatar_image(@user, seed: @user.id, size: 60) %>
|
<%= render Shared::AvatarComponent.new(@user, size: 60) %>
|
||||||
<%= @user.name %>
|
<%= @user.name %>
|
||||||
<% if current_user&.administrator? %>
|
<% if current_user&.administrator? %>
|
||||||
<small><%= @user.email %></small>
|
<small><%= @user.email %></small>
|
||||||
|
|||||||
Reference in New Issue
Block a user