Sha256: 0814f321afe5b2fda2b92ef28e63adf0fda98afca0dd795905593e6763adcf05

Contents?: true

Size: 1.84 KB

Versions: 10

Compression:

Stored size: 1.84 KB

Contents

require_relative '../../base'

module CCS
  module Components
    module CCS
      class DashboardSection < Base
        # = CCS Dashboard Section Panel
        #
        # The individual panel within a dashboard section
        #
        # @!attribute [r] title
        #   @return [String] Text for the panel title
        # @!attribute [r] href
        #   @return [String] The href for the panel
        # @!attribute [r] description
        #   @return [String] Description text for the panel

        class Panel < Base
          private

          attr_reader :title, :href, :description

          public

          # @param title [String] the text for the panel title
          # @param href [String] the href for the panel
          # @param description [String] the description text for the panel
          # @param options [Hash] options that will be used in customising the HTML
          #
          # @option options [String] :width (default: 'one-third') the width of the panel
          # @option options [Hash] :attributes any additional attributes that will added as part of the HTML.

          def initialize(title:, href:, description:, **options)
            super(**options)

            @options[:attributes][:class] = "ccs-dashboard-section__panel govuk-grid-column-#{@options[:width] || 'one-third'}"

            @title = title
            @href = href
            @description = description
          end

          # Generates the HTML for the CCS Dashboard Section Panel
          #
          # @return [ActiveSupport::SafeBuffer]

          def render
            tag.div(**options[:attributes]) do
              concat(link_to(title, href, class: 'ccs-dashboard-section__panel-title'))
              concat(tag.p(description, class: 'ccs-dashboard-section__panel-description'))
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.3.0 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.2.0 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.2 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/ccs/dashboard_section/panel.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/ccs/dashboard_section/panel.rb