Sha256: 4c7e91d52f2fec4e7a012b848ebcff7c9e43cced0a105eb057e8a5025a5701cc

Contents?: true

Size: 1008 Bytes

Versions: 17

Compression:

Stored size: 1008 Bytes

Contents

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

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

          Coco::App::Elements::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::App::Elements::Menu.new(size: @size, resize: @resize, **kwargs)
        end

        attr_reader :size, :resize

        def button_text
          text || content
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
coveragebook_components-0.10.0 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.9.1 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.9.0 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.9 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.8 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.7 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.6 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.5 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.4 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.3 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.2 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.1 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.0 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.0.beta.3 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.0.beta.2 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.8.0.beta.1 app/components/coco/app/elements/menu_button/menu_button.rb
coveragebook_components-0.7.10 app/components/coco/app/elements/menu_button/menu_button.rb