Class: Arara::CardMediaComponent

Inherits:
ActionView::Component::Base
  • Object
show all
Includes:
BaseComponent
Defined in:
app/components/arara/card_media_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_options, #html_tag, included

Constructor Details

#initialize(variant:, image_url:, content_html_class: "", **kw) ⇒ CardMediaComponent

Returns a new instance of CardMediaComponent.



5
6
7
8
9
10
# File 'app/components/arara/card_media_component.rb', line 5

def initialize(variant:, image_url:, content_html_class: "", **kw)
  super(tag: "div", variant: variant, **kw)

  @image_url = image_url
  @content_html_class = content_html_class
end

Instance Attribute Details

#content_html_classObject (readonly)

Returns the value of attribute content_html_class.



12
13
14
# File 'app/components/arara/card_media_component.rb', line 12

def content_html_class
  @content_html_class
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



12
13
14
# File 'app/components/arara/card_media_component.rb', line 12

def image_url
  @image_url
end

Instance Method Details

#default_html_classObject



14
15
16
17
18
# File 'app/components/arara/card_media_component.rb', line 14

def default_html_class
  return "mdc-card__media mdc-card__media--16-9" if user_variant == "wide"
  return "mdc-card__media mdc-card__media--square" if user_variant == "square"
  "mdc-card__media"
end