Class: Panda::Core::Admin::PageHeaderComponent
- Defined in:
- app/components/panda/core/admin/page_header_component.rb
Overview
Page header component with title, optional breadcrumbs, and action buttons.
Follows Tailwind UI Plus pattern for page headers with responsive layout and support for multiple action buttons.
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#breadcrumbs ⇒ Object
readonly
Returns the value of attribute breadcrumbs.
-
#show_back ⇒ Object
readonly
Returns the value of attribute show_back.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#button(text:, variant: :secondary, href: "#", **props) ⇒ Object
Define a button to be rendered in the header actions area.
-
#buttons ⇒ Object
Lazy accessor that ensures buttons are registered before returning them.
-
#initialize(title: "", breadcrumbs: nil, show_back: true, **attrs, &block) ⇒ PageHeaderComponent
constructor
A new instance of PageHeaderComponent.
Constructor Details
#initialize(title: "", breadcrumbs: nil, show_back: true, **attrs, &block) ⇒ PageHeaderComponent
Returns a new instance of PageHeaderComponent.
36 37 38 39 40 41 42 43 |
# File 'app/components/panda/core/admin/page_header_component.rb', line 36 def initialize(title: "", breadcrumbs: nil, show_back: true, **attrs, &block) @title = title @breadcrumbs = @show_back = show_back @buttons = [] @setup_block = block super(**attrs) end |
Instance Attribute Details
#breadcrumbs ⇒ Object (readonly)
Returns the value of attribute breadcrumbs.
45 46 47 |
# File 'app/components/panda/core/admin/page_header_component.rb', line 45 def @breadcrumbs end |
#show_back ⇒ Object (readonly)
Returns the value of attribute show_back.
45 46 47 |
# File 'app/components/panda/core/admin/page_header_component.rb', line 45 def show_back @show_back end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
45 46 47 |
# File 'app/components/panda/core/admin/page_header_component.rb', line 45 def title @title end |
Instance Method Details
#button(text:, variant: :secondary, href: "#", **props) ⇒ Object
Define a button to be rendered in the header actions area
69 70 71 |
# File 'app/components/panda/core/admin/page_header_component.rb', line 69 def (text:, variant: :secondary, href: "#", **props) @buttons << {text: text, variant: variant, href: href, **props} end |
#buttons ⇒ Object
Lazy accessor that ensures buttons are registered before returning them. Supports two patterns:
- Block passed to new() - executed here (for tests)
- Block passed to render() - executed via content (for ERB templates)
51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/components/panda/core/admin/page_header_component.rb', line 51 def unless @buttons_registered if @setup_block @setup_block.call(self) else content end @buttons_registered = true end @buttons end |