Class: NfgUi::Bootstrap::Components::CarouselItem

Inherits:
Base
  • Object
show all
Includes:
Utilities::Activatable
Defined in:
lib/nfg_ui/bootstrap/components/carousel_item.rb

Overview

Bootstrap Carousel Slide / Carousel Item Component getbootstrap.com/docs/4.1/components/carousel/#slides-only

Direct Known Subclasses

Components::Elements::CarouselItem

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Activatable

#active

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

#captionObject



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

def caption
  options.fetch(:caption, nil)
end

#component_familyObject



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

def component_family
  :carousel
end

#imageObject



19
20
21
# File 'lib/nfg_ui/bootstrap/components/carousel_item.rb', line 19

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

#labelObject



23
24
25
# File 'lib/nfg_ui/bootstrap/components/carousel_item.rb', line 23

def label
  options.fetch(:label, nil)
end

#renderObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/nfg_ui/bootstrap/components/carousel_item.rb', line 27

def render
  super do
    capture do
      concat(image_tag(image, class: 'd-block w-100')) if image
      if caption || label
        concat(NfgUi::Bootstrap::Components::CarouselCaption.new({ body: caption, label: label }, view_context).render)
      end
      concat(block_given? ? yield : body)
    end
  end
end