Sha256: 77e43ade58fa0d102b422a06a44eee126bd40ea5eb9541ffa7c2bf3b43c6babc

Contents?: true

Size: 951 Bytes

Versions: 45

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

module Satis
  module Input
    class Element < ViewComponent::Base
      attr_reader :classes

      def initialize(classes: nil, colored: true)
        @classes = classes || ""
        @classes += " colored" if colored
      end
    end

    class Component < Satis::ApplicationComponent
      attr_reader :form, :attribute, :options

      renders_one :label
      renders_one :input
      renders_one :hint
      renders_many :prefixes, Element
      renders_many :postfixes, Element

      def initialize(form: nil, attribute: nil, **options)
        @form = form
        @attribute = attribute
        @options = options
      end

      def input_class
        [@options.fetch(:input_html, {}).fetch(:class, ""), "sts-input__input", form.has_error?(attribute) ? "is-invalid" : ""].join(" ")
      end

      def input_container_class
        form.has_error?(attribute) && "is-invalid"
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
satis-2.1.47 app/components/satis/input/component.rb
satis-2.1.46 app/components/satis/input/component.rb
satis-2.1.45 app/components/satis/input/component.rb
satis-2.1.44 app/components/satis/input/component.rb
satis-2.1.43 app/components/satis/input/component.rb
satis-2.1.42 app/components/satis/input/component.rb
satis-2.1.41 app/components/satis/input/component.rb
satis-2.1.40 app/components/satis/input/component.rb
satis-2.1.39 app/components/satis/input/component.rb
satis-2.1.38 app/components/satis/input/component.rb
satis-2.1.37 app/components/satis/input/component.rb
satis-2.1.36 app/components/satis/input/component.rb
satis-2.1.35 app/components/satis/input/component.rb
satis-2.1.33 app/components/satis/input/component.rb
satis-2.1.31 app/components/satis/input/component.rb
satis-2.1.30 app/components/satis/input/component.rb
satis-2.1.29 app/components/satis/input/component.rb
satis-2.1.28 app/components/satis/input/component.rb
satis-2.1.27 app/components/satis/input/component.rb
satis-2.1.26 app/components/satis/input/component.rb