Class: Oversee::Dashboard::Header

Inherits:
Base
  • Object
show all
Defined in:
app/components/oversee/dashboard/header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, subtitle: nil, return_path: nil, show_back_button: true) ⇒ Header

Returns a new instance of Header.



7
8
9
10
11
12
# File 'app/components/oversee/dashboard/header.rb', line 7

def initialize(title: nil, subtitle: nil, return_path: nil, show_back_button: true)
  @title = title || "Dashboard"
  @subtitle = subtitle || "Manage your account"
  @return_path = return_path
  @show_back_button = show_back_button
end

Instance Attribute Details

#return_pathObject (readonly)

Returns the value of attribute return_path.



4
5
6
# File 'app/components/oversee/dashboard/header.rb', line 4

def return_path
  @return_path
end

#show_back_buttonObject (readonly)

Returns the value of attribute show_back_button.



5
6
7
# File 'app/components/oversee/dashboard/header.rb', line 5

def show_back_button
  @show_back_button
end

#subtitleObject (readonly)

Returns the value of attribute subtitle.



3
4
5
# File 'app/components/oversee/dashboard/header.rb', line 3

def subtitle
  @subtitle
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'app/components/oversee/dashboard/header.rb', line 2

def title
  @title
end

Instance Method Details

#leftObject



26
27
28
29
30
31
32
# File 'app/components/oversee/dashboard/header.rb', line 26

def left(&)
  div(class: "flex items-center gap-2") do
    back_button if show_back_button
    h3(class: "text-lg font-medium text-gray-900") { title } if title.present?
    yield if block_given?
  end
end

#rightObject



34
35
36
# File 'app/components/oversee/dashboard/header.rb', line 34

def right(&)
  div(class: "flex items-center gap-4", &)
end

#separatorObject



38
39
40
# File 'app/components/oversee/dashboard/header.rb', line 38

def separator
  render Phlex::Icons::Iconoir::Slash.new(class: "size-4 text-gray-300", stroke_width: 1.75)
end

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/components/oversee/dashboard/header.rb', line 14

def view_template(&)

  div(class: "min-h-10 flex items-center justify-between") do
    if block_given?
      yield(self)
    else
      left
      right
    end
  end
end