Sha256: 4e0ff6419375589fd67c0279638af321402493dc3c0bc9e4009aeb4e2879c2af

Contents?: true

Size: 982 Bytes

Versions: 23

Compression:

Stored size: 982 Bytes

Contents

module Coco
  module App
    module Elements
      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
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.12.1 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.12.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.11.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.10.1.beta.2 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.10.1.beta.1 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.10.1.beta.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.10.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.9.1 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.9.0 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.9 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.8 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.7 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.6 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.5 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.4 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.3 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.2 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.1 app/components/coco/app/elements/menu/menu.rb
coveragebook_components-0.8.0 app/components/coco/app/elements/menu/menu.rb