Class: FoxTail::ProgressBarComponent

Inherits:
BaseComponent show all
Includes:
Concerns::HasStimulusController
Defined in:
app/components/fox_tail/progress_bar_component.rb

Defined Under Namespace

Classes: StimulusController

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from BaseComponent

classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

#initialize(value, html_attributes = {}) ⇒ ProgressBarComponent

Returns a new instance of ProgressBarComponent.



13
14
15
16
# File 'app/components/fox_tail/progress_bar_component.rb', line 13

def initialize(value, html_attributes = {})
  super(html_attributes)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'app/components/fox_tail/progress_bar_component.rb', line 6

def value
  @value
end

Instance Method Details

#before_renderObject



18
19
20
21
22
23
24
25
26
# File 'app/components/fox_tail/progress_bar_component.rb', line 18

def before_render
  super

  html_attributes[:class] = classnames theme.apply(:root, self), html_class
  html_attributes[:aria] ||= {}
  html_attributes[:aria][:valuenow] = value
  html_attributes[:aria][:valuemin] = 0
  html_attributes[:aria][:valuemax] = 100
end

#callObject



28
29
30
31
32
# File 'app/components/fox_tail/progress_bar_component.rb', line 28

def call
   :div, html_attributes do
     :div, label, bar_attributes
  end
end

#stimulus_controller_optionsObject



38
39
40
# File 'app/components/fox_tail/progress_bar_component.rb', line 38

def stimulus_controller_options
  {value: value, update_label: show_label? && !content?}
end

#use_stimulus?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/components/fox_tail/progress_bar_component.rb', line 34

def use_stimulus?
  controlled? && super
end