Sha256: 6e7b2ed2787c0362b419cdf9c67c25f8f942ad65e8ab5a07d9a9e3c60b1bc047

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

module Coco
  module App
    module Elements
      class ImagePicker < Coco::Component
        include Concerns::AcceptsOptions
        include Coco::AppHelper

        accepts_option :size, from: [:sm, :md, nil], default: :sm

        renders_one :blank_state_text

        before_render do
          args[:resize]&.each { set_tag_data_attr("size-#{_1}", _2) }
        end

        attr_reader :uploader_args, :src

        def initialize(input_name: nil, src: nil, accept: "image/*", form_builder: nil, **kwargs)
          @src = src
          @uploader_args = {name: input_name, accept: accept, form_builder: form_builder}
        end

        def alpine_props
          {
            image: {
              name: (src.present? && File.basename(src)),
              data: src
            }
          }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coveragebook_components-0.5.0 app/components/coco/app/elements/image_picker/image_picker.rb