Class: DesignSystem::Govuk::Builders::Tab

Inherits:
DesignSystem::Generic::Builders::Tab show all
Defined in:
lib/design_system/govuk/builders/tab.rb

Overview

This class provides GOVUK Tab.

Direct Known Subclasses

Nhsuk::Builders::Tab

Instance Method Summary collapse

Methods inherited from DesignSystem::Generic::Builders::Base

#initialize

Methods included from Helpers::CssHelper

#css_class_options_merge

Methods included from DesignSystem::Generic::Builders::Concerns::BrandDerivable

#brand

Constructor Details

This class inherits a constructor from DesignSystem::Generic::Builders::Base

Instance Method Details

#render_tabs {|@tab| ... } ⇒ Object

Yields:

  • (@tab)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/design_system/govuk/builders/tab.rb', line 8

def render_tabs
  @tab = ::DesignSystem::Components::Tab.new(self)

  yield @tab
  (:div, class: "#{brand}-tabs", 'data-module': "#{brand}-tabs") do
    safe_buffer = ActiveSupport::SafeBuffer.new

    safe_buffer.concat((:h2, @tab.title, class: "#{brand}-tabs__title")) if @tab.title
    safe_buffer.concat(tabs_list_content) if @tab.tabs.present?
    safe_buffer.concat(tabs_body_content) if @tab.tabs.present?
    safe_buffer
  end
end