Sha256: 4f736ac4b01fffed86b3d19b14e6fd66ed97a56cda5b8a78da328e2ab51df662

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

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

  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 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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
avo-2.0.0 app/components/avo/panel_component.rb