Class: CCS::Components::GovUK::Tabs::Tab
- Defined in:
- lib/ccs/components/govuk/tabs/tab.rb
Overview
GOV.UK Tabs tab
The individual tab
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(index:, id_prefix:, label:, panel:, **options) ⇒ Tab
constructor
A new instance of Tab.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Tabs tab.
Constructor Details
#initialize(index:, id_prefix:, label:, panel:, **options) ⇒ Tab
Returns a new instance of Tab.
33 34 35 36 37 38 39 40 41 |
# File 'lib/ccs/components/govuk/tabs/tab.rb', line 33 def initialize(index:, id_prefix:, label:, panel:, **) super(**) @options[:attributes][:class] = 'govuk-tabs__tab' @index = index @label = label @href = "##{panel.dig(:attributes, :id) || "#{id_prefix}-#{index}"}" end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Tabs tab
47 48 49 50 51 |
# File 'lib/ccs/components/govuk/tabs/tab.rb', line 47 def render tag.li(class: "govuk-tabs__list-item #{'govuk-tabs__list-item--selected' if index == 1}".rstrip) do link_to(label, href, **[:attributes]) end end |