Class: CCS::Components::GovUK::Tabs::Panel
- Defined in:
- lib/ccs/components/govuk/tabs/panel.rb
Overview
GOV.UK Tabs panel
The individual tab panels
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(index:, id_prefix:, content: nil, text: nil, **options) ⇒ Panel
constructor
A new instance of Panel.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Tabs panel.
Constructor Details
#initialize(index:, id_prefix:, content: nil, text: nil, **options) ⇒ Panel
Returns a new instance of Panel.
35 36 37 38 39 40 41 42 43 |
# File 'lib/ccs/components/govuk/tabs/panel.rb', line 35 def initialize(index:, id_prefix:, content: nil, text: nil, **) super(**) @options[:attributes][:class] = "govuk-tabs__panel #{'govuk-tabs__panel--hidden' if index > 1}".rstrip @options[:attributes][:id] ||= "#{id_prefix}-#{index}" @index = index @content = content @text = text end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Tabs panel
49 50 51 52 53 |
# File 'lib/ccs/components/govuk/tabs/panel.rb', line 49 def render tag.div(**[:attributes]) do content || tag.p(text, class: 'govuk-body') end end |