Sha256: 524af1b4a53b00cadf879f3b214291aacce39267982ed2e85fbde9e052d75087

Contents?: true

Size: 785 Bytes

Versions: 10

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

class Avo::Sidebar::LinkComponent < Avo::BaseComponent
  prop :label
  prop :path
  prop :active, default: :inclusive do |value|
    value&.to_sym
  end
  prop :target do |value|
    value&.to_sym
  end
  prop :data, default: {}.freeze
  prop :icon
  prop :args, kind: :**, default: {}.freeze

  def is_external?
    # If the path contains the scheme, check if it includes the root path or not
    return !@path.include?(helpers.mount_path) if URI(@path).scheme.present?

    false
  end

  # For external links active_link_to marks them all as active.
  def link_method
    is_external? ? :link_to : :active_link_to
  end

  def classes
    "px-4 pr-0 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100 gap-1"
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
avo-3.15.1 app/components/avo/sidebar/link_component.rb
avo-3.15.0 app/components/avo/sidebar/link_component.rb
avo-3.14.5 app/components/avo/sidebar/link_component.rb
avo-3.14.4 app/components/avo/sidebar/link_component.rb
avo-3.14.3 app/components/avo/sidebar/link_component.rb
avo-3.14.2 app/components/avo/sidebar/link_component.rb
avo-3.14.1 app/components/avo/sidebar/link_component.rb
avo-3.14.0 app/components/avo/sidebar/link_component.rb
avo-3.13.7 app/components/avo/sidebar/link_component.rb
avo-3.13.6 app/components/avo/sidebar/link_component.rb