Class: Oversee::Dashboard::Sidebar

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

Instance Method Summary collapse

Instance Method Details

#view_templateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/components/oversee/dashboard/sidebar.rb', line 4

def view_template
  div(class: "bg-white p-4 rounded-lg") do
    button(class: "mb-4 ") { collapse_icon } unless true

    p(class: "text-[0.7rem] uppercase text-gray-400 font-medium mb-2") { "Menu" }
    ul(class: "text-sm text-gray-700") do
      li do
        a(href: root_path, class:"flex items-center gap-2 hover:bg-gray-50 p-2") do
          render Phlex::Icons::Iconoir::LayoutLeft.new(class: "size-4 text-gray-400")
          span { "Dashboard" }
        end
      end
      li do
        a(href: helpers.main_app.root_path, class: "flex items-center gap-2 hover:bg-gray-50 p-2 rounded-lg") do
          render Phlex::Icons::Iconoir::HomeAltSlimHoriz.new(class: "size-4 text-gray-400")
          span { "Return to app" }
        end
      end
    end

    if Rails.env.development?
      hr(class: "my-4 -mx-4")
      details(
        id: "links-menu",
        class: "group",
        # open: true,
        data: {
          controller: "sidebar--state",
          action: "sidebar--state#persist",
          sidebar__state_target: "expandable"
        }
      ) do
        summary(class: "flex items-center justify-between cursor-pointer") do
          p(class: "text-[0.7rem] uppercase text-gray-400 font-medium") { "Links" }
          render Phlex::Icons::Iconoir::NavArrowDown.new(class: "size-4 text-gray-400 transform transition-transform group-open:rotate-180 group-hover:text-blue-500")
        end
        ul(class: "mt-2 text-sm text-gray-700 overflow-x-hidden") do
          li do
            a(href: "https://github.com/primevise/oversee", target: "_blank", class: "flex items-center gap-2 hover:bg-gray-50 p-2 truncate") do
              render Phlex::Icons::Iconoir::ArrowUpRightSquare.new(class: "size-4 text-gray-400")
              span { "Repository" }
            end
          end
        end
      end
    end

    hr(class: "my-4 -mx-4")

    details(
      id: "resources-menu",
      class: "group",
      # open: true,
      data: {
        controller: "sidebar--state",
        action: "sidebar--state#persist",
        sidebar__state_target: "expandable"
      }
    ) do
      summary(class: "flex items-center justify-between cursor-pointer") do
        p(class: "text-[0.7rem] uppercase text-gray-400 font-medium") { "Resources" }
        render Phlex::Icons::Iconoir::NavArrowDown.new(class: "size-4 text-gray-400 transform transition-transform group-open:rotate-180 group-hover:text-blue-500")
      end
      ul(class: "mt-2 text-sm text-gray-700 overflow-x-hidden") do
        Oversee.application_resource_names.sort.each do |resource_class_name|
          li do
            a(href: helpers.resources_path(resource_class_name:), class: "flex items-center gap-2 hover:bg-gray-50 p-2 truncate") do
              render Phlex::Icons::Iconoir::Folder.new(class: "size-4 text-gray-400")
              span { resource_class_name }
            end
          end
        end
      end
    end

    hr(class: "my-4 -mx-4")
    p(class: "text-xs text-gray-500") do
      plain("Powered by ")
      a(
          href: "https://github.com/primevise/oversee",
          class: "text-blue-500 hover:underline",
          target: "_blank"
        ) { "Oversee" }
    end
  end
end