Sha256: 09bbc82010a5c4999b38a7b3713e75423d8a5459285bce3a00867ea57ae182e5

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

class SolidusAdmin::Layout::Navigation::Component < SolidusAdmin::BaseComponent
  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: children, top_level: true)
    end
    @store = store
  end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_admin-0.3.1 app/components/solidus_admin/layout/navigation/component.rb
solidus_admin-0.3.0 app/components/solidus_admin/layout/navigation/component.rb
solidus_admin-0.2.0 app/components/solidus_admin/layout/navigation/component.rb
solidus_admin-0.1.0 app/components/solidus_admin/layout/navigation/component.rb