Class: DsfrComponent::TileComponent
- Defined in:
- app/components/dsfr_component/tile_component.rb
Constant Summary
Constants inherited from Base
Base::HEADING_LEVELS, Base::SIZES
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #before_render ⇒ Object
-
#initialize(title:, url:, image_src: nil, image_alt: "", description: nil, orientation: :vertical, heading_level: 4, html_attributes: {}) ⇒ TileComponent
constructor
A new instance of TileComponent.
Constructor Details
#initialize(title:, url:, image_src: nil, image_alt: "", description: nil, orientation: :vertical, heading_level: 4, html_attributes: {}) ⇒ TileComponent
Returns a new instance of TileComponent.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/dsfr_component/tile_component.rb', line 12 def initialize(title:, url:, image_src: nil, image_alt: "", description: nil, orientation: :vertical, heading_level: 4, html_attributes: {}) @title = title @url = url @image_src = image_src @image_alt = image_alt @description = description @orientation = orientation @heading_level = heading_level raise ArgumentError if HEADING_LEVELS.exclude?(heading_level) super(html_attributes: html_attributes) end |
Instance Method Details
#before_render ⇒ Object
26 27 28 |
# File 'app/components/dsfr_component/tile_component.rb', line 26 def before_render raise ArgumentError, "TileComponent accepte au maximum 4 badges (#{badges.size} fournis)" if badges.size > 4 end |