Sha256: 24d39b28f1398a2c0eca80a6f9b71c76bd728c607605945a6ca9562626d5fae6

Contents?: true

Size: 1.65 KB

Versions: 8

Compression:

Stored size: 1.65 KB

Contents

module CCS
  module Components
    module GovUK
      class Accordion < Base
        class Section
          # = GOV.UK Accordion Section Content
          #
          # The individual accordion section content
          #
          # @!attribute [r] section
          #   @return [Hash] Attributes for the accordion section
          # @!attribute [r] accordion_id
          #   @return [String] ID of the accordion
          # @!attribute [r] index
          #   @return [Integer] Index of the accordion section

          class Content
            include ActionView::Context
            include ActionView::Helpers

            private

            attr_reader :section, :accordion_id, :index

            public

            # @param section [Hash] attributes for the accordion section
            # @param accordion_id [String] ID of the accordion
            # @param index [Integer] the index of the accordion section
            #
            # @option (see CCS::Components::GovUK::Accordion::Section)

            def initialize(section:, accordion_id:, index:)
              @section = section
              @accordion_id = accordion_id
              @index = index
            end

            # Generates the HTML for the GOV.UK Accordion Section Content
            #
            # @return [ActiveSupport::SafeBuffer]

            def render
              tag.div(class: 'govuk-accordion__section-content', id: "#{accordion_id}-content-#{index}", aria: { labelledby: "#{accordion_id}-heading-#{index}" }) do
                section[:content] || tag.p(section[:text], class: 'govuk-body')
              end
            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/accordion/section/content.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/accordion/section/content.rb