Sha256: 8b74dfcfaca457590ed57368ee0dc9ba4285f034d45a8e0b5b3fbacc7d71e2a9

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require_relative '../item'

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

          class Checkbox < Item
            # @param (see CCS::Components::GovUK::Field::Items::Item#initialize)
            # label [Hash] attributes for the checkbox 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-checkboxes__label #{label[:classes]}".rstrip
            end

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

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

            # The default attributes for the checkbox

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

            # The type of the input item

            ITEM_TYPE = 'checkboxes'.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/checkbox.rb