Sha256: 29ac2b4e0b9100ffbb47d804c5d66bb2e3a5ab16cc9e54f60abe16a898df2443

Contents?: true

Size: 1 KB

Versions: 24

Compression:

Stored size: 1 KB

Contents

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

        wraps_component :button do |args|
          Coco::App::Elements::Button.new(toggle: :vertical, fit: get_option_value(:fit) || :auto, **args)
        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 initialize(button: {}, **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
        end

        def button_text
          text || content
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

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