Sha256: 37390d4c54d2b5a3f4762bd14ca8eea9122734a548a405b1de0fd6119e5437d4
Contents?: true
Size: 1.67 KB
Versions: 20
Compression:
Stored size: 1.67 KB
Contents
require_relative '../text_input' module CCS module Components module GovUK class Field < Base class Input < Field class TextInput < Input # = GOV.UK Text Input prefix/suffix # # This is used to generate the prefix/suffix HTML for a text input # # @!attribute [r] text # @return [String] Text for the prefix/suffix class Fix < Base private attr_reader :text public # @param text [String] the text for the prefix/suffix # @param fix [String] either +"pre"+ or +"suf"+ # # @param options [Hash] options that will be used in customising the HTML # # @option options [String] :classes additional CSS classes for the prefix/suffix HTML # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML def initialize(text:, fix:, **options) super(**options) @options[:attributes][:class] = "govuk-input__#{fix}fix #{@options[:attributes][:class]}".rstrip (@options[:attributes][:aria] ||= {})[:hidden] = true @text = text end # Generates the HTML for the GOV.UK Text Input prefix/suffix # # @yield (see CCS::Components::GovUK::Field#render) # # @return [ActiveSupport::SafeBuffer] def render tag.div(text, **options[:attributes]) end end end end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems