Class: NfgUi::Bootstrap::Components::Carousel
- Defined in:
- lib/nfg_ui/bootstrap/components/carousel.rb
Overview
Bootstrap Carousel Component getbootstrap.com/docs/4.1/components/carousel/
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#body, #options, #view_context
Instance Method Summary collapse
-
#auto ⇒ Object
Turn on or off auto scrolling carousel.
- #component_family ⇒ Object
- #controls ⇒ Object
- #data ⇒ Object
- #indicators ⇒ Object
- #render ⇒ Object
Methods inherited from Base
#href, #html_options, #id, #initialize, #style
Constructor Details
This class inherits a constructor from NfgUi::Bootstrap::Components::Base
Instance Method Details
#auto ⇒ Object
Turn on or off auto scrolling carousel
10 11 12 |
# File 'lib/nfg_ui/bootstrap/components/carousel.rb', line 10 def auto .fetch(:auto, true) end |
#component_family ⇒ Object
14 15 16 |
# File 'lib/nfg_ui/bootstrap/components/carousel.rb', line 14 def component_family :carousel end |
#controls ⇒ Object
18 19 20 |
# File 'lib/nfg_ui/bootstrap/components/carousel.rb', line 18 def controls .fetch(:controls, false) end |
#data ⇒ Object
22 23 24 25 26 27 |
# File 'lib/nfg_ui/bootstrap/components/carousel.rb', line 22 def data # false on auto means that the carousel should not automatically rotate. data_val = auto == false ? { interval: 'false' } : { ride: 'carousel' } super.merge!(**data_val) end |
#indicators ⇒ Object
29 30 31 |
# File 'lib/nfg_ui/bootstrap/components/carousel.rb', line 29 def indicators [:indicators] || 0 # return 0 on nil end |
#render ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nfg_ui/bootstrap/components/carousel.rb', line 33 def render super do capture do content_tag(:div, class: 'carousel-inner') do if indicators > 0 concat(NfgUi::Bootstrap::Components::CarouselIndicators.new({ count: indicators, carousel: "##{id}" }, view_context).render) end concat(block_given? ? yield : body) if controls concat(NfgUi::Bootstrap::Components::CarouselControl.new({ control: :next, carousel: "##{id}" }, view_context).render) concat(NfgUi::Bootstrap::Components::CarouselControl.new({ control: :prev, carousel: "##{id}" }, view_context).render) end end end end end |