Class: CCS::Components::CCS::DashboardSection::Panel

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/ccs/dashboard_section/panel.rb

Overview

CCS Dashboard Section Panel

The individual panel within a dashboard section

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the dashboard panel

{ class: 'ccs-dashboard-section__panel' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(title:, href:, description:, **options) ⇒ Panel

Returns a new instance of Panel.

Parameters:

  • title (String)

    the text for the panel title

  • href (String)

    the href for the panel

  • description (String)

    the description text for the panel

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :width (String) — default: default: 'one-third'

    the width of the panel

  • :attributes (Hash)

    any additional attributes that will added as part of the HTML.



33
34
35
36
37
38
39
40
41
# File 'lib/ccs/components/ccs/dashboard_section/panel.rb', line 33

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

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

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

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the CCS Dashboard Section Panel

Returns:

  • (ActiveSupport::SafeBuffer)


47
48
49
50
51
52
# File 'lib/ccs/components/ccs/dashboard_section/panel.rb', line 47

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