Sha256: d276c69d2b6f5fe2efb447095b8c18d8ca38d5920b8e7d292b0d141cb6eb9451

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 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

10 entries across 10 versions & 1 rubygems

Version Path
avo-2.9.2.pre1 app/components/avo/panel_component.rb
avo-2.9.1.pre7 app/components/avo/panel_component.rb
avo-2.9.1.pre6 app/components/avo/panel_component.rb
avo-2.9.1.pre5 app/components/avo/panel_component.rb
avo-2.9.1.pre4 app/components/avo/panel_component.rb
avo-2.9.1.pre3 app/components/avo/panel_component.rb
avo-2.9.1.pre2 app/components/avo/panel_component.rb
avo-2.9.1.pre1 app/components/avo/panel_component.rb
avo-2.9.0 app/components/avo/panel_component.rb
avo-2.8.0 app/components/avo/panel_component.rb