Class: RubyCms::Admin::AdminPageHeader
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- RubyCms::Admin::AdminPageHeader
- Defined in:
- app/components/ruby_cms/admin/admin_page_header.rb
Overview
Reusable page header for admin pages. Renders breadcrumbs, title, optional subtitle, and action slot.
Usage from ERB:
<%= render RubyCms::Admin::AdminPageHeader.new(
title: "Sports",
breadcrumbs: [
{ label: "Admin", url: admin_root_path },
{ label: "Sports" }
]
) do %>
<%= link_to new_admin_sport_path, class: "..." do %>
+ Add
<% end %>
<% end %>
Instance Method Summary collapse
-
#initialize(title:, breadcrumbs: [], subtitle: nil, **options) ⇒ AdminPageHeader
constructor
A new instance of AdminPageHeader.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
#build_classes, #conditional_attributes, #controller, #form_authenticity_token, #helpers, #merge_data_attributes, #token_from_controller, #token_from_controller?, #token_from_helpers?
Constructor Details
#initialize(title:, breadcrumbs: [], subtitle: nil, **options) ⇒ AdminPageHeader
Returns a new instance of AdminPageHeader.
23 24 25 26 27 28 29 |
# File 'app/components/ruby_cms/admin/admin_page_header.rb', line 23 def initialize(title:, breadcrumbs: [], subtitle: nil, **) super() @title = title = Array() @subtitle = subtitle @header_class = [:class] end |
Instance Method Details
#view_template(&block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/ruby_cms/admin/admin_page_header.rb', line 31 def view_template(&block) header(class: build_classes("flex-shrink-0 mb-4", @header_class)) do if .any? div(class: "flex flex-wrap items-center justify-between gap-4") do render_title_section render_actions(&block) if block end end end |