Sha256: bfe7e3ec762b4b6e177bd74776d9cd12f6a56d16fdf41c2769bb38c0833dbd63

Contents?: true

Size: 949 Bytes

Versions: 25

Compression:

Stored size: 949 Bytes

Contents

module Coco
  module App
    module Elements
      class Menu < Coco::Component
        include Concerns::ActsAsButtonGroup
        include Concerns::AcceptsOptions

        accepts_option :size, from: [:sm, :md, nil], default: :sm

        renders_many :htmls, ->(*args, **kwargs, &block) do
          items << block.call
        end

        before_render do
          args[:resize]&.each { set_tag_data_attr("size-#{_1}", _2) }
        end

        def button_kwargs(kwargs, type = nil)
          btn_kwargs = {
            theme: nil,
            size: get_option_value(:size),
            resize: args[:resize],
            **kwargs,
            fit: :full,
            collapsible: false
          }

          if type == :menu
            btn_kwargs[:toggle] = :horizontal
            btn_kwargs[:dropdown] ||= {
              placement: "right-start"
            }
          end

          btn_kwargs
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.7.10 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.9 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.8 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.7 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.6 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.5 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.4 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.3 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.2 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.1 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.7.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.6.5 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.6.4 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.6.3 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.6.2 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.6.1 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.6.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.5.7 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.5.6 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.5.5 app/components/coco/app/elements/menu/menu.rb