class NfgUi::Bootstrap::Components::DropdownToggle
Bootstrap
Dropdown
Component getbootstrap.com/docs/4.1/components/dropdowns/
Public Instance Methods
component_family()
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 12 def component_family :dropdown end
data()
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 16 def data data_toggle = (options[:data] || {}).merge!(toggle: 'dropdown') offset.present? ? { **data_toggle, offset: offset } : data_toggle end
href()
click to toggle source
Calls superclass method
NfgUi::Bootstrap::Components::Base#href
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 21 def href as == :a ? '#' : super end
offset()
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 29 def offset options.fetch(:offset, '') end
render() { |: body)| ... }
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 46 def render NfgUi::Bootstrap::Components::Button.new({ as: as, theme: theme, **html_options, remove_component_css_classes: nav_link }, view_context).render do (block_given? ? yield : body) end end
split()
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 33 def split options.fetch(:split, false) end
theme()
click to toggle source
Bypass & Skip Bootstrap::Utilities::Themeable
module this method just passes the options to the button component Otherwise, if utilizing :button AND Themeable, we end up with duplicate theme css classes being sent to the button… ex: <button class='btn-danger btn-danger'…>
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 42 def theme options.fetch(:theme, NfgUi::DEFAULT_BOOTSTRAP_THEME) end
Private Instance Methods
assistive_html_attributes()
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 61 def assistive_html_attributes { aria: { haspopup: 'true', expanded: 'false' } } end
css_classes()
click to toggle source
Calls superclass method
NfgUi::Bootstrap::Utilities::Sizable#css_classes
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 54 def css_classes [ super, ("#{component_css_class}-split" if split) ].join(' ').squish end
default_html_wrapper_element()
click to toggle source
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 65 def default_html_wrapper_element :button end
non_html_attribute_options()
click to toggle source
Calls superclass method
NfgUi::Bootstrap::Utilities::Sizable#non_html_attribute_options
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 69 def non_html_attribute_options super.push(:offset, :nav_link) end
size_css_class_prefix()
click to toggle source
Toggle, in html, is a customized button, so sizing a toggle requires using the button prefix – otherwise it'll end up as 'dropdown-toggle-lg' or 'dropdown-toggle-sm', etc
# File lib/nfg_ui/bootstrap/components/dropdown_toggle.rb, line 76 def size_css_class_prefix 'btn' end