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