Class: FoxTail::IconBaseComponent

Inherits:
InlineSvgComponent show all
Defined in:
app/components/fox_tail/icon_base_component.rb

Direct Known Subclasses

IconComponent

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from InlineSvgComponent

#call

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(name, html_attributes = {}) ⇒ IconBaseComponent

Returns a new instance of IconBaseComponent.



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

def initialize(name, html_attributes = {})
  @name = name.to_s.gsub("_", "-")
  super(nil, html_attributes)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'app/components/fox_tail/icon_base_component.rb', line 4

def name
  @name
end

Instance Method Details

#icon_setObject



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

def icon_set
  @icon_set ||= begin
    name = options.fetch(:icon_set, default_icon_set).to_sym
    icon_set = icon_sets.fetch name
    raise FoxTail::InvalidIconSet.new(name) unless icon_set

    icon_set.new name
  end
end

#pathObject



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

def path
  @path ||= icon_set.path(name, variant: variant).to_s
end

#variantObject



9
10
11
# File 'app/components/fox_tail/icon_base_component.rb', line 9

def variant
  options[:variant] ||= default_icon_variant
end