module Coco module App module Elements class Menu < Coco::Component include Concerns::ActsAsButtonGroup include Concerns::AcceptsOptions accepts_option :size, from: [:sm, :md, nil], default: :sm renders_many :htmls, ->(*args, **kwargs, &block) do 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