Module: SimpleNavbar
- Defined in:
- lib/simple_navbar.rb,
lib/simple_navbar/railtie.rb,
lib/simple_navbar/version.rb,
lib/generators/simple_navbar/install_generator.rb
Defined Under Namespace
Classes: InstallGenerator, Railtie
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
Instance Method Details
#simple_navbar(brand: {}, links: []) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/simple_navbar.rb', line 5 def (brand: {}, links: []) content_tag :nav, class: "simple-nav-bar" do content_tag(:div, class: "simple-nav-bar-container") do concat( content_tag(:a, href: brand[:url], class: "simple-nav-bar-brand-link") do concat content_tag(:h1, brand[:title], class: "simple-nav-bar-brand-title") if brand[:title].present? concat image_tag(brand[:logo], class: "simple-nav-bar-brand-logo") if brand[:logo].present? end ) concat( content_tag(:button, class: "simple-nav-bar-burger-button") do concat content_tag(:span, "", class: "simple-nav-bar-burger-line") concat content_tag(:span, "", class: "simple-nav-bar-burger-line") concat content_tag(:span, "", class: "simple-nav-bar-burger-line") end ) concat( content_tag(:button, class: "simple-nav-bar-close-button") do concat content_tag(:span, "", class: "simple-nav-bar-close-line") concat content_tag(:span, "", class: "simple-nav-bar-close-line") end ) concat( content_tag(:div, class: "simple-nav-bar-nav-list-container") do content_tag(:nav) do content_tag(:ul, class: "simple-nav-bar-nav-list") do links.map do |link| if link[:dropdown] concat( content_tag(:li, class: "simple-nav-bar-nav-item simple-nav-bar-nav-item-dropdown") do concat( content_tag(:button, class: "simple-nav-bar-nav-link simple-nav-bar-dropdown-toggle") do concat link[:dropdown][:label] concat content_tag(:span, "▼", class: "simple-nav-bar-dropdown-arrow-down") concat content_tag(:span, "▲", class: "simple-nav-bar-dropdown-arrow-up simple-nav-bar-hidden") end ) concat( content_tag(:ul, class: "simple-nav-bar-dropdown-menu simple-nav-bar-hidden", data: { simple_navbar_target: "dropdownMenu" }) do link[:dropdown][:links].map do |sublink| concat content_tag(:li, link_to(sublink[:label], sublink[:url], class: "simple-nav-bar-dropdown-item")) end.join.html_safe end ) end ) else concat content_tag(:li, link_to(link[:label], link[:url], class: "simple-nav-bar-nav-link"), class: "simple-nav-bar-nav-item") end end.join.html_safe end end end ) end end end |
#simple_navbar_s(brand: {}, links: []) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/simple_navbar.rb', line 66 def (brand: {}, links: []) content_tag :nav, class: "simple-nav-bar", data: { controller: "simple-navbar" } do content_tag(:div, class: "simple-nav-bar-container") do concat( content_tag(:a, href: brand[:url], class: "simple-nav-bar-brand-link") do concat content_tag(:h1, brand[:title], class: "simple-nav-bar-brand-title") if brand[:title].present? concat image_tag(brand[:logo], class: "simple-nav-bar-brand-logo") if brand[:logo].present? end ) concat( content_tag(:button, class: "simple-nav-bar-burger-button", data: { action: "click->simple-navbar#menuToggle", simple_navbar_target: "burgerButton" }) do concat content_tag(:span, "", class: "simple-nav-bar-burger-line") concat content_tag(:span, "", class: "simple-nav-bar-burger-line") concat content_tag(:span, "", class: "simple-nav-bar-burger-line") end ) concat( content_tag(:button, class: "simple-nav-bar-close-button", data: { action: "click->simple-navbar#menuToggle", simple_navbar_target: "closeButton" }) do concat content_tag(:span, "", class: "simple-nav-bar-close-line") concat content_tag(:span, "", class: "simple-nav-bar-close-line") end ) concat( content_tag(:div, class: "simple-nav-bar-nav-list-container", data: { simple_navbar_target: "menu" }) do content_tag(:nav) do content_tag(:ul, class: "simple-nav-bar-nav-list") do links.map do |link| if link[:dropdown] concat( content_tag(:li, class: "simple-nav-bar-nav-item simple-nav-bar-nav-item-dropdown") do concat( content_tag(:button, class: "simple-nav-bar-nav-link", data: { simple_navbar_target: "dropdownToggle" }) do concat link[:dropdown][:label] concat content_tag(:span, "▼", class: "simple-nav-bar-dropdown-arrow-down") concat content_tag(:span, "▲", class: "simple-nav-bar-dropdown-arrow-up simple-nav-bar-hidden") end ) concat( content_tag(:ul, class: "simple-nav-bar-dropdown-menu simple-nav-bar-hidden", data: { simple_navbar_target: "dropdownMenu" }) do link[:dropdown][:links].map do |sublink| concat content_tag(:li, link_to(sublink[:label], sublink[:url], class: "simple-nav-bar-dropdown-item")) end.join.html_safe end ) end ) else concat content_tag(:li, link_to(link[:label], link[:url], class: "simple-nav-bar-nav-link"), class: "simple-nav-bar-nav-item") end end.join.html_safe end end end ) end end end |