Class: Bootstrap5Helper::PageHeader

Inherits:
Component
  • Object
show all
Defined in:
lib/bootstrap5_helper/page_header.rb

Overview

Builds a simple CSS spinner component.

Instance Method Summary collapse

Methods inherited from Component

#capture, #concat, #config, #content_tag, #parse_arguments, #parse_context_or_options, #parse_tag_or_options, #parse_text_or_options, #uuid

Constructor Details

#initialize(template, tag_or_options = nil, opts = {}, &block) ⇒ PageHeader

Class constructor

Parameters:

  • template (ActionView)
  • tag_or_options (Symbol|Hash) (defaults to: nil)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :id (String)
  • :class (String)
  • :data (Hash)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bootstrap5_helper/page_header.rb', line 15

def initialize(template, tag_or_options = nil, opts = {}, &block)
  super(template)

  @tag, args = parse_tag_or_options(tag_or_options, opts)
  @tag ||= config(:page_header, :h1)

  @id      = args.fetch(:id,    uuid)
  @class   = args.fetch(:class, '')
  @data    = args.fetch(:data,  {})
  @content = block || proc { '' }
end

Instance Method Details

#to_sString

String representation of the object.

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
# File 'lib/bootstrap5_helper/page_header.rb', line 31

def to_s
  (
    @tag,
    id:    @id,
    class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
    data:  @data
  ) do
    @content.call(self)
  end
end