Sha256: 6477efc3241ed7d5b03abff5bb214830bc4ce8d624cd8f1646db272d43a9d3d8

Contents?: true

Size: 785 Bytes

Versions: 25

Compression:

Stored size: 785 Bytes

Contents

module Coco
  class MenuButton < Coco::Component
    include Concerns::AcceptsOptions
    include Concerns::WithIcon
    include Concerns::WrapsComponent

    wraps_component :button do |kwargs|
      @size = kwargs.fetch(:size, :default)&.to_sym
      if @size.in?(Coco::Button::SIZE_ALIASES.keys) && !kwargs.key?(:resize)
        @size, @resize = Coco::Button::SIZE_ALIASES.fetch(@size)
      end

      Coco::Button.new(toggle: :vertical, fit: get_option_value(:fit) || :auto, **kwargs)
    end

    accepts_option :fit, from: [:auto, :full]

    renders_one :text, Coco::Content

    renders_one :menu, ->(**kwargs) do
      Coco::Menu.new(size: @size, resize: @resize, **kwargs)
    end

    attr_reader :size, :resize

    def button_text
      text || content
    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_button/menu_button.rb
coveragebook_components-0.19.7 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.6 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.5 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.4 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.3 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.2 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.1 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.19.0 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.18.8 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.18.7 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.18.0 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.7 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.6 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.5 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.4 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.3 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.2 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.1 app/components/coco/buttons/menu_button/menu_button.rb
coveragebook_components-0.17.0 app/components/coco/buttons/menu_button/menu_button.rb