Class: DsfrComponent::TileComponent

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

Constant Summary

Constants inherited from Base

Base::HEADING_LEVELS

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(title:, url:, image_src: nil, image_alt: "", description: nil, orientation: :vertical, heading_level: 4, classes: [], html_attributes: {}) ⇒ TileComponent

Returns a new instance of TileComponent.

Parameters:

  • title (String)

    title (required)

  • url (String)

    url (required)

  • image_src (String) (defaults to: nil)

    chemin vers l’image (optional)

  • image_alt (String) (defaults to: "")

    L’alternative de l’image. Doit a priori être vide si l’image est illustrative et n’apporte pas de valeur sémantique.

  • description (String) (defaults to: nil)

    description (optional)

  • orientation (String) (defaults to: :vertical)

    :horizontal or :vertical

  • heading_level (Integer) (defaults to: 4)

    1, 2, 3, 4 (default), 5, 6

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/components/dsfr_component/tile_component.rb', line 10

def initialize(title:, url:, image_src: nil, image_alt: "", description: nil, orientation: :vertical, heading_level: 4, classes: [], 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(classes: classes, html_attributes: html_attributes)
end