Module: Analytic::ApplicationHelper
- Defined in:
- app/helpers/analytic/application_helper.rb
Instance Method Summary collapse
- #delta_icon_tag(delta) ⇒ String
- #delta_percentage_tag(delta) ⇒ String
- #delta_tag(delta) ⇒ Object
- #fa_icon_tag(icon) ⇒ Object
- #react(component:) ⇒ Object
Instance Method Details
#delta_icon_tag(delta) ⇒ String
16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/analytic/application_helper.rb', line 16 def delta_icon_tag(delta) if delta.zero? fa_icon_tag('fa-solid fa-xmark') elsif delta.positive? fa_icon_tag('fa-solid fa-arrow-up') elsif delta.negative? fa_icon_tag('fa-solid fa-arrow-down') end end |
#delta_percentage_tag(delta) ⇒ String
28 29 30 |
# File 'app/helpers/analytic/application_helper.rb', line 28 def delta_percentage_tag(delta) tag.span(number_to_percentage(delta.abs * 100.0, precision: 2), class: 'delta__value') end |
#delta_tag(delta) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/analytic/application_helper.rb', line 33 def delta_tag(delta) return if delta.nil? modifier = if delta.zero? then 'delta--neutral' elsif delta.positive? then 'delta--positive' elsif delta.negative? then 'delta--negative' end tag.div(class: "delta #{modifier}") do concat(delta_icon_tag(delta)) concat(delta_percentage_tag(delta)) end end |
#fa_icon_tag(icon) ⇒ Object
10 11 12 |
# File 'app/helpers/analytic/application_helper.rb', line 10 def fa_icon_tag(icon) tag.i(class: icon) end |
#react(component:) ⇒ Object
5 6 7 |
# File 'app/helpers/analytic/application_helper.rb', line 5 def react(component:) tag.div(data: { react: component }) end |