Sha256: bd8f0c9e91a06cb2919e72f927cac67b18c2627832a196d603369d52bd4fc4e8
Contents?: true
Size: 1.13 KB
Versions: 33
Compression:
Stored size: 1.13 KB
Contents
module Coco module App module Elements class LayoutPickerButton < Coco::Component include Concerns::AcceptsOptions include Concerns::WithDropdownOptions include Concerns::WrapsComponent include Coco::AppHelper wraps_component :button do |args| args[:class] = [args[:class], "layout-picker-trigger"] Coco::App::Elements::Button.new(**args) end renders_many :layouts, ->(name:, thumbnail:, **layout_options) do @layout_options << {name: name, thumbnail: thumbnail, **layout_options} 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::App::Elements::Button::SIZE_ALIASES.keys) && !kwargs.key?(:resize) @size, @resize = Coco::App::Elements::Button::SIZE_ALIASES.fetch(@size) end end def selected @selected || @layout_options.first[:name] end end end end end
Version data entries
33 entries across 33 versions & 1 rubygems