Class: NfgUi::Bootstrap::Components::DropdownToggle
Overview
Instance Attribute Summary
#as
Attributes inherited from Base
#body, #options, #view_context
Instance Method Summary
collapse
#size
#utility_initialize
Methods inherited from Base
#html_options, #id, #initialize, #style
Instance Method Details
#component_family ⇒ Object
12
13
14
|
# File 'lib/nfg_ui/bootstrap/components/dropdown_toggle.rb', line 12
def component_family
:dropdown
end
|
#data ⇒ Object
16
17
18
19
|
# 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 ⇒ Object
21
22
23
|
# File 'lib/nfg_ui/bootstrap/components/dropdown_toggle.rb', line 21
def href
as == :a ? '#' : super
end
|
#nav_link ⇒ Object
25
26
27
|
# File 'lib/nfg_ui/bootstrap/components/dropdown_toggle.rb', line 25
def nav_link
options.fetch(:nav_link, false)
end
|
#offset ⇒ Object
29
30
31
|
# File 'lib/nfg_ui/bootstrap/components/dropdown_toggle.rb', line 29
def offset
options.fetch(:offset, '')
end
|
#render ⇒ Object
46
47
48
49
50
|
# 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 ⇒ Object
33
34
35
|
# File 'lib/nfg_ui/bootstrap/components/dropdown_toggle.rb', line 33
def split
options.fetch(:split, false)
end
|
#theme ⇒ Object
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’…>
42
43
44
|
# File 'lib/nfg_ui/bootstrap/components/dropdown_toggle.rb', line 42
def theme
options.fetch(:theme, NfgUi::DEFAULT_BOOTSTRAP_THEME)
end
|