Class: StatisticComponent

Inherits:
Component show all
Defined in:
app/components/statistic_component.rb

Overview

Statistic — numeric statistics display.

Usage:

Statistic(color: :blue) { |c|
  c.value { text "5,550" }
  c.label { text "Downloads" }
}
Statistic(horizontal: true) { |c|
  c.value { text "22" }
  c.label { text "Members" }
}

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/statistic_component.rb', line 25

def to_s
  classes = class_names(
    "ui",
    color,
    size,
    floated && "#{floated} floated",
    { "horizontal" => horizontal,
      "inverted" => inverted },
    "statistic"
  )

  value_el = @slots[:value] ? tag.div(class: "value") { @slots[:value] } : nil
  label_el = @slots[:label] ? tag.div(class: "label") { @slots[:label] } : nil

  tag.div(class: classes) {
    safe_join([ value_el, label_el, @content.presence ])
  }
end