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