Class: Bulmacomp::NavbarComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bulmacomp::NavbarComponent
- Defined in:
- app/components/bulmacomp/navbar_component.rb
Overview
Make an html structure for a bulma navbar
Instance Method Summary collapse
-
#call ⇒ String
Html_safe navbar.
-
#initialize(brand: nil, navbar_start: nil, navbar_end: nil, **opts) {|optional| ... } ⇒ NavbarComponent
constructor
A new instance of NavbarComponent.
-
#navbar_brand ⇒ String
Html_safe navbar-brand tag.
-
#navbar_burger ⇒ String
Html_safe navbar-burger link.
-
#navbar_menu ⇒ String
Html_safe navbar-menu tag.
Constructor Details
#initialize(brand: nil, navbar_start: nil, navbar_end: nil, **opts) {|optional| ... } ⇒ NavbarComponent
Returns a new instance of NavbarComponent.
51 52 53 54 55 56 |
# File 'app/components/bulmacomp/navbar_component.rb', line 51 def initialize(brand: nil, navbar_start: nil, navbar_end: nil, **opts) @brand = brand = tag.div , class: "navbar-start" if .present? = tag.div , class: "navbar-end" if .present? @opts = { class: "navbar", aria: { role: "navigation", label: "main navigation" } }.merge(opts) end |
Instance Method Details
#call ⇒ String
Returns html_safe navbar.
59 60 61 |
# File 'app/components/bulmacomp/navbar_component.rb', line 59 def call tag.nav safe_join([ , ]), **@opts end |
#navbar_brand ⇒ String
Returns html_safe navbar-brand tag.
64 65 66 67 68 69 |
# File 'app/components/bulmacomp/navbar_component.rb', line 64 def return if @brand.blank? tag.div safe_join([ link_to(@brand, root_path, data_turbo_frame: "yield", class: "navbar-item"), ]), class: "navbar-brand" end |
#navbar_burger ⇒ String
Returns html_safe navbar-burger link.
77 78 79 80 81 82 |
# File 'app/components/bulmacomp/navbar_component.rb', line 77 def aria = { expanded: "false", label: "menu" } data = { action: "click->page#toggleMenu" } role = "button" tag.a tag.span(aria_hidden: true) * 3, class: "navbar-burger", aria: aria, data: data, role: role end |
#navbar_menu ⇒ String
Returns html_safe navbar-menu tag.
72 73 74 |
# File 'app/components/bulmacomp/navbar_component.rb', line 72 def tag.div(safe_join([ , content, ]), class: "navbar-menu", data: { page_target: "menu" }) end |