Sha256: 34845690995ef94c3a3c54053ded25229855f8384ed1acd99be177bd365b8f2f

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

module Coco
  module App
    module Blocks
      module SidebarNav
        class Navbar < Coco::Component
          tag_name :nav
          component_name :app_sidebar_nav

          renders_many :actions, ->(label, href, icon:, **kwargs) do
            actions_data << {label: label, href: href, icon: icon, **kwargs}
          end

          renders_many :items, types: {
            link: ->(label, href, show_on_mobile: true, **kwargs, &block) do
              nav_item(mobile: show_on_mobile) do
                render Coco::App::Blocks::SidebarNav::Item.new(label: label, href: href, **kwargs), &block
              end
            end,
            menu: ->(label, show_on_mobile: true, **kwargs, &block) do
              nav_item(mobile: show_on_mobile) do
                render Coco::App::Blocks::SidebarNav::Item.new(label: label, **kwargs) do |item|
                  item.with_menu(&block)
                end
              end
            end
          }

          attr_reader :actions_data

          def initialize(**)
            @actions_data = []
            @menus_data = {}
          end

          def nav_item(mobile: true, &block)
            tag.div(class: "nav-item", data: {show_on_mobile: mobile.to_s}, &block)
          end

          def with_link(...)
            with_item_link(...)
          end

          def with_menu(...)
            with_item_menu(...)
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.12.1 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.12.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.11.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.10.1.beta.2 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.10.1.beta.1 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.10.1.beta.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.10.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.9.1 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.9.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.9 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.8 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.7 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.6 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.5 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.4 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb
coveragebook_components-0.8.3 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.rb