Sha256: 77dd7b1750cfd89e932005fab1b394f3be6a8d4da045275797789fb1e9fc8ee5

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

require_relative '../item'

module CCS
  module 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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/field/inputs/item/radio.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/field/inputs/item/radio.rb