Class: DsfrComponent::HeaderComponent::OperatorImageComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/dsfr_component/header_component/operator_image_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:, src:, alt:, classes: [], html_attributes: {}) ⇒ OperatorImageComponent

Returns a new instance of OperatorImageComponent.

Parameters:

  • title (String)

    Le title du lien vers la page d’accueil du site

  • src (String)

    L’attribut src qui sera passé au tag img

  • alt (String)

    Le texte alternatif qui sera passé au tag img. Il doit impérativement contenir le texte présent dans l’image.



5
6
7
8
9
10
11
# File 'app/components/dsfr_component/header_component/operator_image_component.rb', line 5

def initialize(title:, src:, alt:, classes: [], html_attributes: {})
  @title = title
  @src = src
  @alt = alt

  super(classes: classes, html_attributes: html_attributes)
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'app/components/dsfr_component/header_component/operator_image_component.rb', line 13

def call
  tag.div(class: "fr-header__operator") do
    tag.a(href: "/", title: title) do
      tag.img(class: "fr-responsive-img", src: src, alt: alt, style: "max-width:9.0625rem;")
    end
  end
end

#default_attributesObject



21
22
23
# File 'app/components/dsfr_component/header_component/operator_image_component.rb', line 21

def default_attributes
  {}
end