Class: OkonomiUiKit::Components::PageHeaderRowBuilder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper
Defined in:
app/helpers/okonomi_ui_kit/components/page_header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, component) ⇒ PageHeaderRowBuilder

Returns a new instance of PageHeaderRowBuilder.



74
75
76
77
78
79
# File 'app/helpers/okonomi_ui_kit/components/page_header.rb', line 74

def initialize(template, component)
  @template = template
  @component = component
  @title_content = nil
  @actions_content = nil
end

Instance Attribute Details

#template ⇒ Object (readonly)

Returns the value of attribute template.



70
71
72
# File 'app/helpers/okonomi_ui_kit/components/page_header.rb', line 70

def template
  @template
end

Instance Method Details

#actions(&block) ⇒ Object



85
86
87
88
89
# File 'app/helpers/okonomi_ui_kit/components/page_header.rb', line 85

def actions(&block)
  @actions_content = tag.div(class: @component.style(:actions)) do
    capture(&block) if block_given?
  end
end

#render ⇒ Object



91
92
93
94
95
96
97
98
# File 'app/helpers/okonomi_ui_kit/components/page_header.rb', line 91

def render
  tag.div(class: @component.style(:row)) do
    content = []
    content << @title_content if @title_content
    content << @actions_content if @actions_content
    @template.safe_join(content.compact)
  end
end

#title(text, **options) ⇒ Object



81
82
83
# File 'app/helpers/okonomi_ui_kit/components/page_header.rb', line 81

def title(text, **options)
  @title_content = ui.typography(text, variant: "h1", **options)
end