Extract component to render a single stat box
This commit is contained in:
committed by
taitus
parent
b6c269008f
commit
205cbd7d82
@@ -4,11 +4,7 @@
|
|||||||
|
|
||||||
<div class="stats-numbers">
|
<div class="stats-numbers">
|
||||||
<% stats.each do |text, amount, options = {}| %>
|
<% stats.each do |text, amount, options = {}| %>
|
||||||
<div class="small-12 medium-4 column">
|
<%= render Admin::Stats::StatComponent.new(text: text, amount: amount, options: options) %>
|
||||||
<%= tag.p(options) do %>
|
|
||||||
<%= text %> <br><span class="number"><%= amount %></span>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
5
app/components/admin/stats/stat_component.html.erb
Normal file
5
app/components/admin/stats/stat_component.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= tag.p(options) do %>
|
||||||
|
<%= text %> <br><span class="number"><%= amount %></span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
9
app/components/admin/stats/stat_component.rb
Normal file
9
app/components/admin/stats/stat_component.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class Admin::Stats::StatComponent < ApplicationComponent
|
||||||
|
attr_reader :text, :amount, :options
|
||||||
|
|
||||||
|
def initialize(text:, amount:, options: {})
|
||||||
|
@text = text
|
||||||
|
@amount = amount
|
||||||
|
@options = options
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user