Sha256: 086aa73f5396534fcb94a01a9f8f62f5e7e6370e550b8078c65d00ca8ff25db9

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'action_view'

module CCS::Components
  module GovUK
    class Field < Base
      class Inputs < Field
        class Item < Base
          # = GOV.UK Field Inputs item divider
          #
          # The divider for input items e.g. {CCS::Components::GovUK::Field::Inputs::Checkboxes Checkboxes} or {CCS::Components::GovUK::Field::Inputs::Radios Radios}
          #
          # @!attribute [r] text
          #   @return [String] Text for the divider
          # @!attribute [r] type
          #   @return [String] The type of the item

          class Divider
            include ActionView::Context
            include ActionView::Helpers

            private

            attr_reader :text, :type

            public

            # @param divider [String] the text for the divider
            # @param type [String] the type of the item divider.
            #                      One of +'checkboxes'+ or +'radios'+

            def initialize(divider:, type:)
              @text = divider
              @type = type
            end

            # Generates the HTML for an item divider
            #
            # @return [ActiveSupport::SafeBuffer]

            def render
              tag.div(text, class: "govuk-#{type}__divider")
            end
          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/divider.rb