Class: FoxTail::IconBaseComponent
- Inherits:
-
InlineSvgComponent
- Object
- ViewComponent::Base
- Base
- BaseComponent
- InlineSvgComponent
- FoxTail::IconBaseComponent
- Defined in:
- app/components/fox_tail/icon_base_component.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #icon_set ⇒ Object
-
#initialize(name, html_attributes = {}) ⇒ IconBaseComponent
constructor
A new instance of IconBaseComponent.
- #path ⇒ Object
- #variant ⇒ Object
Methods inherited from InlineSvgComponent
Methods inherited from BaseComponent
classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
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
#name ⇒ Object (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_set ⇒ Object
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 = .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 |
#path ⇒ Object
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 |
#variant ⇒ Object
9 10 11 |
# File 'app/components/fox_tail/icon_base_component.rb', line 9 def variant [:variant] ||= default_icon_variant end |