Class: DsfrComponent::BadgeComponent
- 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
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(status:, classes: [], html_attributes: {}) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(status:, classes: [], html_attributes: {}) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
6 7 8 9 10 11 12 13 14 |
# File 'app/components/dsfr_component/badge_component.rb', line 6 def initialize(status:, classes: [], html_attributes: {}) raise(ArgumentError, "`status` should be one of #{STATUSES}") unless STATUSES.include?(status) @status = status classes.push("fr-badge--#{@status}") super(classes: classes, html_attributes: html_attributes) end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 |
# File 'app/components/dsfr_component/badge_component.rb', line 16 def call tag.div(**html_attributes) do content end end |