Class: Brainzlab::Components::StatCard

Inherits:
Base
  • Object
show all
Defined in:
lib/brainzlab/components/stat_card.rb

Instance Method Summary collapse

Methods inherited from Base

#classes

Constructor Details

#initialize(label:, value:, change: nil, change_type: nil, **attrs) ⇒ StatCard

Returns a new instance of StatCard.



6
7
8
9
10
11
12
# File 'lib/brainzlab/components/stat_card.rb', line 6

def initialize(label:, value:, change: nil, change_type: nil, **attrs)
  @label = label
  @value = value
  @change = change
  @change_type = change_type
  @attrs = attrs
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
# File 'lib/brainzlab/components/stat_card.rb', line 14

def view_template
  div(class: classes('stat-card', @attrs[:class]), **@attrs.except(:class)) do
    div(class: 'stat-label') { @label }
    div(class: 'stat-value') { @value }
    span(class: change_classes) { @change } if @change
  end
end