Class: JetUi::Icon::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- JetUi::Icon::Component
- Defined in:
- app/components/jet_ui/icon/component.rb
Constant Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name = nil, size: nil, **options) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name = nil, size: nil, **options) ⇒ Component
Returns a new instance of Component.
10 11 12 13 14 |
# File 'app/components/jet_ui/icon/component.rb', line 10 def initialize(name = nil, size: nil, **) @name = name.to_s @size = size @options = end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/components/jet_ui/icon/component.rb', line 16 def call icon_name = @name.presence || content.to_s.strip svg = File.read(ICONS_PATH.join("#{icon_name}.svg")) # rubocop:disable Rails/OutputSafety svg.sub('<svg', "<svg #{html_attributes(icon_name)}").html_safe # rubocop:enable Rails/OutputSafety end |