Class: AhoyCaptain::Tables::Rows::RowComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- AhoyCaptain::Tables::Rows::RowComponent
- Defined in:
- app/components/ahoy_captain/tables/rows/row_component.rb
Instance Method Summary collapse
-
#initialize(table:, item:) ⇒ RowComponent
constructor
A new instance of RowComponent.
- #item(value = nil, &block) ⇒ Object
- #percent_total(item) ⇒ Object
- #progress_bar(value, max, label) ⇒ Object
- #tooltip(value) ⇒ Object
Constructor Details
#initialize(table:, item:) ⇒ RowComponent
Returns a new instance of RowComponent.
5 6 7 8 |
# File 'app/components/ahoy_captain/tables/rows/row_component.rb', line 5 def initialize(table:, item:) @table = table @item = item end |
Instance Method Details
#item(value = nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/components/ahoy_captain/tables/rows/row_component.rb', line 20 def item(value = nil, &block) view_context.content_tag(:span, class: "w-8 ml-8 text-right ") do if value value else capture(&block) end end end |
#percent_total(item) ⇒ Object
30 31 32 |
# File 'app/components/ahoy_captain/tables/rows/row_component.rb', line 30 def percent_total(item) '%.1f' % ((item.unit_amount.to_i * 1.0 / total)*100.0) end |
#progress_bar(value, max, label) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/components/ahoy_captain/tables/rows/row_component.rb', line 10 def (value, max, label) items = [] items << view_context.content_tag(:progress, "", class: "progress-primary bg-base-100 h-8 grow", value: value, max: max) items << view_context.content_tag(:span, class: "grow text-elipsis overflow-hidden absolute left-4 bottom-3 h-8 text-primary-content") do label end items.join.html_safe end |
#tooltip(value) ⇒ Object
34 35 36 |
# File 'app/components/ahoy_captain/tables/rows/row_component.rb', line 34 def tooltip(value) AhoyCaptain::TooltipComponent.new(amount: value).render_in(self) end |