Class: Keystone::Ui::PageHeaderComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/keystone/ui/page_header_component.rb

Constant Summary collapse

WRAPPER_CLASSES =
"hidden sm:block mb-6 sm:flex sm:items-center sm:justify-between"
TITLE_CLASSES =
"text-2xl font-bold text-gray-900 dark:text-white"
SUBTITLE_CLASSES =
"mt-1 text-sm text-gray-500 dark:text-gray-400"
ACTIONS_CLASSES =
"page-header-actions hidden sm:block mt-4 sm:mt-0 sm:ml-4 flex-shrink-0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, subtitle: nil, action_url: nil, action_label: "Add new") ⇒ PageHeaderComponent

Returns a new instance of PageHeaderComponent.



13
14
15
16
17
18
19
# File 'app/components/keystone/ui/page_header_component.rb', line 13

def initialize(title:, subtitle: nil, action_url: nil, action_label: "Add new")
  @title = title
  @subtitle = subtitle
  @action_url = action_url
  @action_label = action_label
  @action_block = nil
end

Instance Attribute Details

#action_labelObject (readonly)

Returns the value of attribute action_label.



11
12
13
# File 'app/components/keystone/ui/page_header_component.rb', line 11

def action_label
  @action_label
end

#action_urlObject (readonly)

Returns the value of attribute action_url.



11
12
13
# File 'app/components/keystone/ui/page_header_component.rb', line 11

def action_url
  @action_url
end

#titleObject (readonly)

Returns the value of attribute title.



11
12
13
# File 'app/components/keystone/ui/page_header_component.rb', line 11

def title
  @title
end

Instance Method Details

#action(&block) ⇒ Object



25
26
27
# File 'app/components/keystone/ui/page_header_component.rb', line 25

def action(&block)
  @action_block = block
end

#action?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/components/keystone/ui/page_header_component.rb', line 29

def action?
  !!@action_block
end

#before_renderObject



21
22
23
# File 'app/components/keystone/ui/page_header_component.rb', line 21

def before_render
  content
end

#subtitle?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/components/keystone/ui/page_header_component.rb', line 33

def subtitle?
  !@subtitle.nil?
end

#subtitle_textObject



37
38
39
# File 'app/components/keystone/ui/page_header_component.rb', line 37

def subtitle_text
  @subtitle
end