Class: NfgUi::Bootstrap::Components::Dropdown

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

Overview

Bootstrap Dropdown Component getbootstrap.com/docs/4.1/components/dropdowns/

Direct Known Subclasses

Components::Patterns::Dropdown

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::DropdownDirectionable

#dropleft, #dropright, #dropup

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

#buttonObject



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

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

#component_familyObject



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

def component_family
  :dropdown
end

#offsetObject



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

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

#renderObject



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

def render
  super do
    capture do
      if button.present?
        concat(NfgUi::Bootstrap::Components::DropdownToggle.new({ body: button, theme: theme, as: :button, offset: offset }, view_context).render)
      end
      concat(block_given? ? yield : body)
    end
  end
end

#themeObject



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

def theme
  options.fetch(:theme, NfgUi::DEFAULT_BOOTSTRAP_THEME)
end