Sha256: 75e62b8b63e593a02ac949995b881af470b1504ab7ad0289c1deb94996593436

Contents?: true

Size: 1.79 KB

Versions: 19

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

SimpleForm.setup do |config|
  def configure_label(b)
    b.wrapper :label_wrapper, tag: :div, class: "wrapper__label" do |ba|
      ba.use :label
    end
  end

  def configure_input(b)
    b.wrapper :right_input_wrapper, tag: :div, class: "wrapper__input" do |ba|
      ba.use :input
      ba.use :error, wrap_with: { tag: :small, class: ["error"] }
      ba.use :hint,  wrap_with: { tag: :span, class: ["hint"] }
    end
  end

  # Configure various sized wrappers. We use CSS to style the label and inputs within the top div
  # with classes of e.g. "row wrapper-medium"
  %i(xs sm md lg).each do |size|
    config.wrappers(
      :"hz_#{size}", # eg hz_md
      tag: "div",
      class: "row wrapper wrapper_style_horizontal wrapper_size_#{size}",
      hint_class: :field_with_hint,
      error_class: :error
    ) do |b|
      b.use :html5
      b.use :placeholder
      b.optional :maxlength
      b.optional :pattern
      b.optional :min_max
      b.optional :readonly
      configure_label(b)
      configure_input(b)
    end
  end

  config.wrappers(
    :hz_datepicker,
    tag: :div,
    class: "row wrapper wrapper_style_horizontal wrapper_size_datepicker",
    hint_class: :field_with_hint,
    error_class: :error
  ) do |b|
    b.use :html5
    b.use :placeholder
    b.optional :maxlength
    b.optional :pattern
    b.optional :min_max
    b.optional :readonly
    configure_label(b)

    b.wrapper :right_input_wrapper, tag: :div, class: "wrapper__input" do |ba|
      ba.wrapper :x, tag: :div, class: "row collapse datepicker-wrapper" do |bc|
        bc.use :prefix_column
        bc.use :input_column
        bc.use :error, wrap_with: { tag: :small, class: [:error, :datepicker_error] }
        bc.use :hint,  wrap_with: { tag: :span, class: :hint }
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
renalware-core-2.1.1 config/initializers/simple_form_wrappers.rb
renalware-core-2.1.0 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.167 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.166 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.165 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.164 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.163 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.162 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.161 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.160 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.159 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.158 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.157 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.156 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.155 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.153 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.152 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.151 config/initializers/simple_form_wrappers.rb
renalware-core-2.0.149 config/initializers/simple_form_wrappers.rb