Sha256: 871249ebe5496a7fb7e170853097fcec90a0ed5d34ea357dcdea1a2b8eb0023a

Contents?: true

Size: 819 Bytes

Versions: 25

Compression:

Stored size: 819 Bytes

Contents

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

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

    renders_many :htmls, ->(*args, **kwargs, &block) do
      init_button_group
      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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.19.8 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.7 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.6 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.5 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.4 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.3 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.2 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.1 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.19.0 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.18.8 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.18.7 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.18.0 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.7 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.6 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.5 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.4 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.3 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.2 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.1 app/components/coco/buttons/menu/menu.rb
coveragebook_components-0.17.0 app/components/coco/buttons/menu/menu.rb