Sha256: 2e8ea91e32a094fd22cf25a769a431e9732ac6fc1c575c9a51ce37cdc20c656f

Contents?: true

Size: 1.25 KB

Versions: 18

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

class Avo::PanelComponent < ViewComponent::Base
  include Avo::ApplicationHelper

  attr_reader :title # deprecating title in favor of name
  attr_reader :name
  attr_reader :classes

  delegate :white_panel_classes, to: :helpers

  renders_one :tools
  renders_one :body
  renders_one :sidebar
  renders_one :bare_sidebar
  renders_one :bare_content
  renders_one :footer_tools
  renders_one :footer

  def initialize(name: nil, description: nil, body_classes: nil, data: {}, display_breadcrumbs: false, index: nil, classes: nil, reloadable: nil, **args)
    # deprecating title in favor of name
    @title = args[:title]
    @name = name || title
    @description = description
    @classes = classes
    @body_classes = body_classes
    @data = data
    @display_breadcrumbs = display_breadcrumbs
    @index = index
    @reloadable = reloadable
  end

  private

  def data_attributes
    @data.merge({"panel-index": @index})
  end

  def display_breadcrumbs?
    @display_breadcrumbs == true && Avo.configuration.display_breadcrumbs == true
  end

  def description
    return @description if @description.present?

    ""
  end

  def render_header?
    @name.present? || description.present? || tools.present? || display_breadcrumbs?
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
avo-3.6.1 app/components/avo/panel_component.rb
avo-3.6.0 app/components/avo/panel_component.rb
avo-3.5.8 app/components/avo/panel_component.rb
avo-3.5.7 app/components/avo/panel_component.rb
avo-3.5.6 app/components/avo/panel_component.rb
avo-3.5.6.beta1 app/components/avo/panel_component.rb
avo-3.5.5 app/components/avo/panel_component.rb
avo-3.5.4 app/components/avo/panel_component.rb
avo-3.5.3 app/components/avo/panel_component.rb
avo-3.5.2 app/components/avo/panel_component.rb
avo-3.5.1 app/components/avo/panel_component.rb
avo-3.5.0 app/components/avo/panel_component.rb
avo-3.4.4 app/components/avo/panel_component.rb
avo-3.4.3 app/components/avo/panel_component.rb
avo-3.4.2 app/components/avo/panel_component.rb
avo-3.4.1 app/components/avo/panel_component.rb
avo-3.4.0 app/components/avo/panel_component.rb
avo-3.3.6 app/components/avo/panel_component.rb