Class: FoxTail::BaseComponent

Inherits:
Base
  • Object
show all
Includes:
Concerns::HasOptions, Concerns::HasTheme
Defined in:
app/components/fox_tail/base_component.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

fox_tail_config

Constructor Details

#initialize(html_attributes = {}) ⇒ BaseComponent

Returns a new instance of BaseComponent.



13
14
15
16
17
18
19
20
21
# File 'app/components/fox_tail/base_component.rb', line 13

def initialize(html_attributes = {})
  super

  html_attributes = ActiveSupport::HashWithIndifferentAccess.new html_attributes
  theme = html_attributes.delete :theme
  self.theme.merge! theme if theme.present?
  extract_options! html_attributes
  @html_attributes = html_attributes
end

Instance Attribute Details

#html_attributesObject (readonly)

Returns the value of attribute html_attributes.



7
8
9
# File 'app/components/fox_tail/base_component.rb', line 7

def html_attributes
  @html_attributes
end

Class Method Details

.classname_mergerObject



48
49
50
# File 'app/components/fox_tail/base_component.rb', line 48

def classname_merger
  FoxTail::Base.fox_tail_config.classname_merger
end

.stimulus_mergerObject



56
57
58
# File 'app/components/fox_tail/base_component.rb', line 56

def stimulus_merger
  FoxTail::Base.fox_tail_config.stimulus_merger
end

.use_stimulus?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/components/fox_tail/base_component.rb', line 52

def use_stimulus?
  !!FoxTail::Base.fox_tail_config.use_stimulus
end

Instance Method Details

#with_html_attributes(attributes = {}) ⇒ Object



23
24
25
26
# File 'app/components/fox_tail/base_component.rb', line 23

def with_html_attributes(attributes = {})
  @html_attributes.merge! attributes if attributes.present?
  self
end

#with_html_class(classes) ⇒ Object



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

def with_html_class(classes)
  options[:class] = classnames html_class, classes
  self
end