Class: NfgUi::Bootstrap::Components::CardImageOverlay

Inherits:
Base
  • Object
show all
Includes:
Components::Utilities::Titleable
Defined in:
lib/nfg_ui/bootstrap/components/card_image_overlay.rb

Overview

Direct Known Subclasses

Components::Elements::CardImageOverlay

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Components::Utilities::Titleable

#title

Methods inherited from Base

#data, #href, #html_options, #id, #initialize, #style

Constructor Details

This class inherits a constructor from NfgUi::Bootstrap::Components::Base

Instance Method Details

#component_familyObject



11
12
13
# File 'lib/nfg_ui/bootstrap/components/card_image_overlay.rb', line 11

def component_family
  :card
end

#imageObject



15
16
17
# File 'lib/nfg_ui/bootstrap/components/card_image_overlay.rb', line 15

def image
  options.fetch(:image, '')
end

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nfg_ui/bootstrap/components/card_image_overlay.rb', line 19

def render
  capture do
    if image
      concat(NfgUi::Bootstrap::Components::CardImage.new({ image: image }, view_context).render)
    end

    concat((:div, html_options) {
      capture do
        concat((:h5, title, class: 'card-title')) if title
        concat(block_given? ? yield : body)
      end
    })
  end
end