Sha256: 24a686f1f87df6329deaeaa7d1de008c519467637e38aea4adedc0cdae78ae39

Contents?: true

Size: 1.52 KB

Versions: 95

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module NfgUi
  module Bootstrap
    module Components
      # Bootstrap Carousel Component
      # https://getbootstrap.com/docs/4.1/components/carousel/
      class Carousel < NfgUi::Bootstrap::Components::Base
        def component_family
          :carousel
        end

        def controls
          options.fetch(:controls, false)
        end

        def data
          super.merge!(ride: 'carousel')
        end

        def indicators
          options[:indicators] || 0 # return 0 on nil
        end

        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

        private

        def css_classes
          [
            super,
            'slide'
          ].join(' ').squish
        end

        def non_html_attribute_options
          super.push(:indicators, :controls)
        end
      end
    end
  end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
nfg_ui-0.9.18.1 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.18 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.17 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.16 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.15 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.14 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.13 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.12 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.11 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.10 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.9 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.8.18 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.8.17 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.8.16 lib/nfg_ui/bootstrap/components/carousel.rb
nfg_ui-0.9.8.15 lib/nfg_ui/bootstrap/components/carousel.rb