Class: NfgUi::Bootstrap::Components::CarouselControl

Inherits:
Base
  • Object
show all
Defined in:
lib/nfg_ui/bootstrap/components/carousel_control.rb

Overview

Direct Known Subclasses

Components::Elements::CarouselControl

Instance Attribute Summary

Attributes inherited from Base

#options, #view_context

Instance Method Summary collapse

Methods inherited from Base

#html_options, #id, #initialize, #style

Constructor Details

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

Instance Method Details

#bodyObject

CarouselControl does not get adjustable body content



10
11
12
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 10

def body
  nil
end


18
19
20
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 18

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

#component_familyObject



14
15
16
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 14

def component_family
  :carousel
end

#controlObject

Options for control are :prev and :next control’s value sets up the rest of the carousel control attributes in HTML



24
25
26
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 24

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

#dataObject



28
29
30
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 28

def data
  control ? super.merge!(slide: control) : super
end

#hrefObject



32
33
34
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 32

def href
  carousel ? carousel : '#'
end

#icon_html_optionsObject



36
37
38
39
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 36

def icon_html_options
  return {} unless control
  { class: "carousel-control-#{control}-icon", aria: { hidden: true } }
end

#renderObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/nfg_ui/bootstrap/components/carousel_control.rb', line 41

def render
  super do
    capture do
      if control
        concat((:span, nil, icon_html_options))
        concat((:span, control.to_s, class: 'sr-only'))
      end
    end
  end
end