Class: DsfrComponent::TagComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/dsfr_component/tag_component.rb

Constant Summary collapse

SIZES =
%i[sm md].freeze

Constants inherited from Base

Base::HEADING_LEVELS

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(title:, icon: nil, size: nil, url: nil, selected: nil, dismissable: nil, classes: [], html_attributes: {}) ⇒ 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

#callObject



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