Sha256: 6685d8cfaafee317355b1850c6f26f5de4428f557f7f7823ba556f4dd7b09002
Contents?: true
Size: 823 Bytes
Versions: 3
Compression:
Stored size: 823 Bytes
Contents
# frozen_string_literal: true module PandaCms class PageMenuComponent < ViewComponent::Base attr_accessor :page attr_accessor :menu_item attr_accessor :styles def initialize(page:, start_depth:, styles: {}, show_heading: true) @page = page unless @page.nil? start_page = if @page.depth == start_depth @page else @page.ancestors.find { |anc| anc.depth == start_depth } end menu = start_page&.page_menu return if menu.nil? @menu_item = menu.menu_items.order(:lft)&.first @show_heading = show_heading # Set some default styles for sanity @styles = styles @styles[:indent_with] ||= "pl-2" end end def render? @page&.path != "/" && @menu_item.present? end end end
Version data entries
3 entries across 3 versions & 1 rubygems