Sha256: de285cd26046758bea1d72ac2ab28f371462071e40e38f0d08779d50072f7833
Contents?: true
Size: 1.26 KB
Versions: 34
Compression:
Stored size: 1.26 KB
Contents
module Coco module App module Elements class ImagePickerButton < Coco::Component include Concerns::WithDropdownOptions include Concerns::WrapsComponent include Coco::AppHelper wraps_component :button do |args| Coco::App::Elements::Button.new(icon: :image_plus, **args) end renders_one :text, Coco::Content renders_one :picker, ->(picker = nil, **kwargs, &block) do if picker.is_a?(Coco::App::Elements::ImagePicker) picker else picker&.to_s.presence || Coco::App::Elements::ImagePicker.new( size: @size, resize: @resize, src: @src, **kwargs ) end end before_render do with_picker(src: @src) unless picker? end attr_reader :src def initialize(src: nil, **kwargs) @src = src @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
34 entries across 34 versions & 1 rubygems