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
SIZES =
%i[md sm].freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BadgeComponent.

Parameters:



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

def initialize(status: nil, size: :md, html_attributes: {})
  validate_status!(status)
  validate_size!(size)

  @status = status
  @size = size

  super(html_attributes: html_attributes)
end

Instance Method Details

#callObject



17
18
19
20
21
# File 'app/components/dsfr_component/badge_component.rb', line 17

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