Class: DsfrComponent::BadgeComponent

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

Constant Summary collapse

STATUSES =
i[success error info warning new].freeze

Constants inherited from Base

DsfrComponent::Base::HEADING_LEVELS, DsfrComponent::Base::SIZES

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(status:, html_attributes: {}) ⇒ BadgeComponent

Returns a new instance of BadgeComponent.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
# File 'app/components/dsfr_component/badge_component.rb', line 6

def initialize(status:, html_attributes: {})
  raise(ArgumentError, "`status` should be one of #{STATUSES}") unless STATUSES.include?(status)

  @status = status

  super(html_attributes: html_attributes)
end

Instance Method Details

#callObject



14
15
16
17
18
# File 'app/components/dsfr_component/badge_component.rb', line 14

def call
  tag.div(**html_attributes) do
    content
  end
end