Sha256: 3e2068ccc6d1b501677df7c59dd58dab612dbbe925d28faf97ccc7731effb4d6
Contents?: true
Size: 1.44 KB
Versions: 17
Compression:
Stored size: 1.44 KB
Contents
module Coco module App module Blocks module SidebarNav class Menu < Coco::Component component_name :app_sidebar_nav_menu renders_many :items, types: { link: ->(label, href, qualifier: nil, **kwargs, &block) do if items.size < max_links coco_link(href, **kwargs, theme: nil, underline: false) do tag.span(label, class: "menu-item-label") + tag.span(qualifier, class: "menu-item-qualifier") end else overflow_items << ["#{label}#{qualifier.present? ? " (#{qualifier})" : ""}", href] nil end end, block_link: ->(href, **kwargs, &block) do coco_link(href, **kwargs, theme: nil, underline: false, &block) end } renders_one :action, ->(*args, **kwargs, &block) do coco_button(*args, theme: :primary, **kwargs, size: :sm, fit: :full, &block) end attr_reader :max_links, :overflow_items, :prompt def initialize(max_links: 6, prompt: "More links...", **kwargs) @max_links = max_links @prompt = prompt @overflow_items = [] end def with_link(...) with_item_link(...) end def with_block_link(...) with_item_block_link(...) end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems