Class: Panda::Core::Admin::SidebarComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/sidebar_component.rb

Overview

Sidebar navigation component for admin pages Displays hierarchical navigation with toggle for nested items. Supports optional section grouping via the :section key on nav items.

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user:, **attrs) ⇒ SidebarComponent

Returns a new instance of SidebarComponent.



10
11
12
13
# File 'app/components/panda/core/admin/sidebar_component.rb', line 10

def initialize(user:, **attrs)
  @user = user
  super(**attrs)
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



15
16
17
# File 'app/components/panda/core/admin/sidebar_component.rb', line 15

def user
  @user
end

Instance Method Details

#admin_logoObject



17
18
19
# File 'app/components/panda/core/admin/sidebar_component.rb', line 17

def 
  Panda::Core.config.
end

#admin_logo_actionsObject



29
30
31
# File 'app/components/panda/core/admin/sidebar_component.rb', line 29

def admin_logo_actions
  Panda::Core.config.admin_logo_actions || []
end

#admin_settings_pathObject



21
22
23
# File 'app/components/panda/core/admin/sidebar_component.rb', line 21

def admin_settings_path
  Panda::Core.config.admin_settings_path
end

#compact_navigation?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/components/panda/core/admin/sidebar_component.rb', line 25

def compact_navigation?
  Panda::Core.config.compact_navigation
end

#safe_html(value) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'app/components/panda/core/admin/sidebar_component.rb', line 37

def safe_html(value)
  raw = value.respond_to?(:call) ? value.call : value
  helpers.sanitize(raw, tags: %w[svg path ellipse circle rect line polyline polygon g defs use
    span a i div img br strong em b], attributes: %w[
      viewBox fill stroke stroke-width stroke-linecap stroke-linejoin opacity cx cy rx ry r
      x y x1 y1 x2 y2 width height d points transform xmlns class href style id
      data-turbo-track rel
    ])
end

#sectioned?(items) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/components/panda/core/admin/sidebar_component.rb', line 33

def sectioned?(items)
  items.any? { |item| item[:section].present? }
end