Class: DsfrComponent::HighlightComponent
- Defined in:
- app/components/dsfr_component/highlight_component.rb
Constant Summary
Constants inherited from Base
Base::HEADING_LEVELS, Base::SIZES
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text: nil, size: :md, html_attributes: {}) ⇒ HighlightComponent
constructor
A new instance of HighlightComponent.
Constructor Details
#initialize(text: nil, size: :md, html_attributes: {}) ⇒ HighlightComponent
Returns a new instance of HighlightComponent.
5 6 7 8 9 10 |
# File 'app/components/dsfr_component/highlight_component.rb', line 5 def initialize(text: nil, size: :md, html_attributes: {}) @text = text @size = size super(html_attributes: html_attributes) end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/dsfr_component/highlight_component.rb', line 12 def call raise(ArgumentError, "You must provide either a text param or some block content") if no_content? raise(ArgumentError, "Size '#{size}' is not allowed; possible values are #{SIZES}") if SIZES.exclude?(size) tag.div(**html_attributes) do tag.p(class: "fr-text--#{@size}") do @text || content end end end |