Class: DesignSystem::Generic::Builders::Details

Inherits:
Base
  • Object
show all
Defined in:
lib/design_system/generic/builders/details.rb

Overview

This builds a generic details component with brand-specific classes

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Helpers::CssHelper

#css_class_options_merge

Methods included from Concerns::BrandDerivable

#brand

Constructor Details

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

Instance Method Details

#render_details(summary_text) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/design_system/generic/builders/details.rb', line 8

def render_details(summary_text)
  content = capture { yield if block_given? }

  (:details, class: "#{brand}-details") do
    safe_buffer = ActiveSupport::SafeBuffer.new

    safe_buffer.concat(
      (:summary, class: "#{brand}-details__summary") do
        (:span, summary_text, class: "#{brand}-details__summary-text")
      end
    )

    safe_buffer.concat(
      (:div, content, class: "#{brand}-details__text")
    )

    safe_buffer
  end
end