Sha256: 3330ec95f21cb7252f334df358f7d5a51b7c960f955a89c8940ac2898182ba60
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Forms module Input class InputComponent < ViewComponent::Base def initialize(**options) @method = options[:method] @object = options[:object] @scope = options[:scope] @type = options.dig(:html, :type) @classes = options.dig(:html, :class) @floating = options.dig(:html, :floating) @placeholder = options.dig(:html, :placeholder) @onchange = options.dig(:html, :onchange) @html = options[:html] classes_builder end private def text_input if scoped? @scope.text_field(@method, @html) else text_field(@object, @method, @html) end end def scoped? @scope.present? end def floating_label_id if scoped? @scope.options[:html][:id] else "#{@object}_#{@method}" end end def classes_builder if @html[:class] @html[:class] = "form-control #{@classes}".strip end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bsvc-0.1.2 | app/components/alpha/forms/input/input_component.rb |
bsvc-0.1.1 | app/components/alpha/forms/input/input_component.rb |