Sha256: 090a73b33f3539d9eca3e50a29965e88bbfdfc04ef2268479e025e77810b1bfa

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

class Avo::PanelComponent < ViewComponent::Base
  attr_reader :title

  renders_one :tools
  renders_one :body
  renders_one :bare_content
  renders_one :footer_tools
  renders_one :footer

  def initialize(title: nil, description: nil, body_classes: nil, data: {}, display_breadcrumbs: false, index: nil)
    @title = title
    @description = description
    @body_classes = body_classes
    @data = data
    @display_breadcrumbs = display_breadcrumbs
    @index = index
  end

  private

  def white_panel_classes
    "bg-white rounded shadow"
  end

  def data_attributes
    @data.merge({'panel-index': @index}).map do |key, value|
      " data-#{key}=\"#{value}\""
    end.join
  end

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

  def description
    return @description if @description.present?

    ""
  end

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

  def render_footer_tools?
    footer_tools.present?
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avo-2.7.1.pre.1 app/components/avo/panel_component.rb
avo-2.7.0 app/components/avo/panel_component.rb
avo-2.6.1.pre.2 app/components/avo/panel_component.rb
avo-2.6.1.pre.1 app/components/avo/panel_component.rb
avo-2.6.0 app/components/avo/panel_component.rb
avo-2.5.2.pre.6 app/components/avo/panel_component.rb
avo-2.5.2.pre.5 app/components/avo/panel_component.rb
avo-2.5.2.pre.4 app/components/avo/panel_component.rb
avo-2.5.2.pre.3 app/components/avo/panel_component.rb