Class: DesignSystem::Nhsuk::Builders::InsetText

Inherits:
Generic::Builders::InsetText show all
Defined in:
lib/design_system/nhsuk/builders/inset_text.rb

Overview

This generates html for rendering inset text for Nhsuk

Instance Method Summary collapse

Methods inherited from Generic::Builders::Base

#initialize

Methods included from Helpers::CssHelper

#css_class_options_merge

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

#brand

Constructor Details

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

Instance Method Details

#render_inset_text(text = nil, **options) ⇒ Object



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

def render_inset_text(text = nil, **options, &)
  content = block_given? ? capture(&) : text
  return if content.blank?

  wrapped_content = block_given? ? content : (:p, content)

  div_options = css_class_options_merge(options, ["#{brand}-inset-text"])

  (:div, **div_options) do
    (:span, 'Information: ', class: "#{brand}-u-visually-hidden") + wrapped_content
  end
end