Class: SolidusAdmin::Layout::Navigation::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/solidus_admin/layout/navigation/component.rb

Instance Method Summary collapse

Constructor Details

#initialize(store:, logo_path: SolidusAdmin::Config.logo_path, items: SolidusAdmin::Config.menu_items) ⇒ Component

Returns a new instance of Component.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/components/solidus_admin/layout/navigation/component.rb', line 4

def initialize(
  store:,
  logo_path: SolidusAdmin::Config.logo_path,
  items: SolidusAdmin::Config.menu_items
)
  @logo_path = logo_path
  @items = items.map do |attrs|
    children = attrs[:children].to_a.map { SolidusAdmin::MenuItem.new(**_1, top_level: false) }
    SolidusAdmin::MenuItem.new(**attrs, children:, top_level: true)
  end
  @store = store
end

Instance Method Details

#before_renderObject



17
18
19
20
21
# File 'app/components/solidus_admin/layout/navigation/component.rb', line 17

def before_render
  url = @store.url
  url = "https://#{url}" unless url.start_with?("http")
  @store_url = url
end

#itemsObject



23
24
25
# File 'app/components/solidus_admin/layout/navigation/component.rb', line 23

def items
  @items.sort_by(&:position)
end