Module: NavbarHelper
- Includes:
- ActionView::Helpers
- Defined in:
- app/helpers/navbar_helper.rb
Instance Method Summary collapse
- #horizontal(options = {}, &block) ⇒ Object
-
#navbar(options = {}, &block) ⇒ Object
TODO: add navbar form support.
- #navbar_menu(options = {}, &block) ⇒ Object
- #vertical(options = {}, &block) ⇒ Object
Instance Method Details
#horizontal(options = {}, &block) ⇒ Object
34 35 36 37 38 |
# File 'app/helpers/navbar_helper.rb', line 34 def horizontal(={}, &block) prepend_class(, 'collapse navbar-collapse') content_tag :div, , &block end |
#navbar(options = {}, &block) ⇒ Object
TODO: add navbar form support
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/navbar_helper.rb', line 5 def (={}, &block) style = .delete(:inverse).presence ? 'navbar navbar-inverse' : 'navbar navbar-default' container = .delete(:fluid).presence ? 'container-fluid' : 'container' padding = .delete(:padding).presence || '70px' position, position_style = parse_position(.delete(:position), padding) prepend_class(, style, position) [:data] = ([:data] || {}).merge(bui: 'navbar') (position_style + (content_tag :nav, do content_tag :div, class: container, &block end)).html_safe end |
#navbar_menu(options = {}, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/navbar_helper.rb', line 40 def (={}, &block) style = case .delete(:position).try(:to_sym) when :right 'nav navbar-nav navbar-right' when :left 'nav navbar-nav navbar-left' else 'nav navbar-nav' end prepend_class(, style) content_tag :ul, , &block end |
#vertical(options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/navbar_helper.rb', line 20 def vertical(={}, &block) prepend_class(, 'navbar-header') content_tag :div, do (content_tag :button, class: 'navbar-toggle collapsed', type: :button, data: {toggle: 'collapse'}, aria: {expanded: false} do ("<span class='icon-bar'></span>" * 3).html_safe end) + capture(&block) end end |