Class: Components::PageTitle

Inherits:
Base
  • Object
show all
Defined in:
app/components/page_title.rb

Instance Method Summary collapse

Constructor Details

#initialize(title:, breadcrumbs: {}, heading: true) ⇒ PageTitle

Returns a new instance of PageTitle.



4
5
6
7
8
# File 'app/components/page_title.rb', line 4

def initialize(title:, breadcrumbs: {}, heading: true)
  @title = title
  @breadcrumbs = breadcrumbs
  @heading = heading
end

Instance Method Details

#view_template ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/page_title.rb', line 10

def view_template
  nav aria: {label: "breadcrumb"}, class: "border-bottom pt-1 pb-1" do
    ol class: "breadcrumb" do
      li class: "breadcrumb-item" do
        a(href: dashboard_path) { Icon icon: "house", label: t("application.navbar.home") }
      end
      @breadcrumbs.map do |text, path|
        li class: "breadcrumb-item" do
          a(href: path) { text }
        end
      end
      li(class: "breadcrumb-item active", aria: {current: "page"}) { @title }
    end
  end
  if @heading
    h1 do
      span { @title }
    end
  end
end