Sha256: 18dbe3314185fe58d062950a96c5c7d714f876cc4104b512d62089a85b5a47f1

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require_relative '../item'

module CCS::Components
  module GovUK
    class Field < Base
      class Inputs < Field
        class Item < Base
          # = GOV.UK Field Inputs Radio
          #
          # This is used to generate an individual radio item

          class Radio < Item
            # @param (see CCS::Components::GovUK::Field::Items::Item#initialize)
            # label [Hash] attributes for the radio label, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
            #
            # @option (see CCS::Components::GovUK::Field::Items::Item#initialize))

            def initialize(attribute:, label:, **options)
              super(attribute: attribute, **options)

              label[:classes] = "govuk-radios__label #{label[:classes]}".rstrip
            end

            # Generates the HTML to wrap arround a radio input
            #
            # @yield the radio item input HTML
            #
            # @return [ActiveSupport::SafeBuffer]

            def render(&block)
              tag.div(class: 'govuk-radios__item') do
                super(&block)
              end
            end

            # The default attributes for the radio

            DEFAULT_ATTRIBUTES = { class: 'govuk-radios__input' }.freeze

            # The type of the input item

            ITEM_TYPE = 'radios'.freeze
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.1.0.rc.2 lib/ccs/components/govuk/field/inputs/item/radio.rb