Sha256: 6dea90e8ca67fab5056b8e66bd497fd1da5ab0deef0c29a6c370cfd8f55727f3

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require 'active_support/concern'

module Satis
  module Forms
    module Concerns
      module File
        extend ActiveSupport::Concern

        included do
          def file_input(method, options = {})
            form_group(method, options.merge(data: {
                                               controller: 'satis-file'
                                             })) do
              safe_join [
                (custom_label(method, options[:label], options) unless options[:label] == false),
                tag.div(class: 'overflow-hidden relative inline-block -mb-2') do
                  safe_join [
                    tag.button((options[:multiple] ? t('choose_files') : t('choose_file')), type: 'button',
                                                                                            class: 'bg-white py-3 px-4 border border-gray-300 rounded-md shadow-sm text-sm leading-4 font-medium text-gray-700 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500'),
                    file_field(method,
                               options.merge(class: 'w-full cursor-pointer absolute block opacity-0 inset-0',
                                             data: { 'satis-file-target': 'input' }))
                  ]
                end,
                tag.div(class: 'mt-2 text-gray-300 text-xs', data: { 'satis-file-target': 'selection' })
              ]
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
satis-1.0.75 lib/satis/forms/concerns/file.rb
satis-1.0.74 lib/satis/forms/concerns/file.rb
satis-1.0.70 lib/satis/forms/concerns/file.rb
satis-1.0.69 lib/satis/forms/concerns/file.rb
satis-1.0.68 lib/satis/forms/concerns/file.rb
satis-1.0.67 lib/satis/forms/concerns/file.rb
satis-1.0.66 lib/satis/forms/concerns/file.rb