Sha256: 2d0e40db94bdd22b9b4f0c868ce3377ecf80d353d07fdfd7dc88c332a640e4b7
Contents?: true
Size: 964 Bytes
Versions: 20
Compression:
Stored size: 964 Bytes
Contents
module Coco class LayoutPickerButton < Coco::Component include Concerns::AcceptsOptions include Concerns::WithDropdownOptions include Concerns::WrapsComponent wraps_component :button do |args| args[:class] = [args[:class], "layout-picker-trigger"] Coco::Button.new(**args) end renders_many :layouts, ->(name:, thumbnail: nil, **layout_options, &block) do @layout_options << {name: name, thumbnail: thumbnail, **layout_options, icon: block&.call} end attr_reader :layout_options, :size, :resize def initialize(selected: nil, **kwargs) @selected = selected @layout_options = [] @resize = {} @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 end def selected @selected || @layout_options.first[:name] end end end
Version data entries
20 entries across 20 versions & 1 rubygems