Class: DsfrComponent::TagComponent
- Defined in:
- app/components/dsfr_component/tag_component.rb
Constant Summary collapse
- SIZES =
%i[sm md].freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(title:, icon: nil, size: nil, url: nil, selected: nil, dismissable: nil, classes: [], html_attributes: {}) ⇒ TagComponent
constructor
A new instance of TagComponent.
Constructor Details
#initialize(title:, icon: nil, size: nil, url: nil, selected: nil, dismissable: nil, classes: [], html_attributes: {}) ⇒ TagComponent
Returns a new instance of TagComponent.
11 12 13 14 15 16 17 18 19 20 |
# File 'app/components/dsfr_component/tag_component.rb', line 11 def initialize(title:, icon: nil, size: nil, url: nil, selected: nil, dismissable: nil, classes: [], html_attributes: {}) @title = title @icon = icon @size = size @url = url @selected = selected @dismissable = dismissable super(classes: classes, html_attributes: html_attributes) end |
Instance Method Details
#call ⇒ Object
22 23 24 25 |
# File 'app/components/dsfr_component/tag_component.rb', line 22 def call validate_size && validate_selected && validate_dismissable tag.send(tag_name, **html_attributes) { title } end |