Class: TinyAdmin::Views::Components::Navbar
- Inherits:
-
BasicComponent
- Object
- Phlex::HTML
- BasicComponent
- TinyAdmin::Views::Components::Navbar
- Defined in:
- lib/tiny_admin/views/components/navbar.rb
Instance Attribute Summary collapse
-
#current_slug ⇒ Object
Returns the value of attribute current_slug.
-
#items ⇒ Object
Returns the value of attribute items.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
-
#root_title ⇒ Object
Returns the value of attribute root_title.
Instance Method Summary collapse
Methods included from Attributes
Instance Attribute Details
#current_slug ⇒ Object
Returns the value of attribute current_slug.
7 8 9 |
# File 'lib/tiny_admin/views/components/navbar.rb', line 7 def current_slug @current_slug end |
#items ⇒ Object
Returns the value of attribute items.
7 8 9 |
# File 'lib/tiny_admin/views/components/navbar.rb', line 7 def items @items end |
#root_path ⇒ Object
Returns the value of attribute root_path.
7 8 9 |
# File 'lib/tiny_admin/views/components/navbar.rb', line 7 def root_path @root_path end |
#root_title ⇒ Object
Returns the value of attribute root_title.
7 8 9 |
# File 'lib/tiny_admin/views/components/navbar.rb', line 7 def root_title @root_title end |
Instance Method Details
#view_template ⇒ Object
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 |
# File 'lib/tiny_admin/views/components/navbar.rb', line 9 def view_template nav(class: "navbar navbar-expand-lg") { div(class: "container") { a(class: "navbar-brand", href: root_path) { root_title } ( class: "navbar-toggler", type: "button", "data-bs-toggle" => "collapse", "data-bs-target" => "#navbarNav", "aria-controls" => "navbarNav", "aria-expanded" => "false", "aria-label" => "Toggle navigation" ) { span(class: "navbar-toggler-icon") } div(class: "collapse navbar-collapse", id: "navbarNav") { ul(class: "navbar-nav") { items.each do |item| classes = %w[nav-link] classes << "active" if item.slug == current_slug link_attributes = { class: classes.join(" "), href: item.path, "aria-current" => "page" } link_attributes.merge!(item.) if item. li(class: "nav-item") { a(**link_attributes) { item.name } } end } } } } end |