Sha256: cceb329cd46b14b4a9e081e7d348af979500341362436ea2d2ced141c3226175

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 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}") do
                section[:content] || tag.p(section[:text], class: 'govuk-body')
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ccs-frontend_helpers-2.1.0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-2.0.0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-1.2.0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-1.1.2 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-1.1.1 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-1.1.0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-1.1.0.beta0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-1.0.0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.5.0.beta1 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.5.0.beta0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.3.0 lib/ccs/components/govuk/accordion/section/content.rb
ccs-frontend_helpers-0.2.0 lib/ccs/components/govuk/accordion/section/content.rb