Sha256: 7bd9423e0b5e778668b9661f7c9f919393d6db11eb42f60aa6fdff54c54bb7ee

Contents?: true

Size: 880 Bytes

Versions: 77

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

class Avo::Sidebar::LinkComponent < ViewComponent::Base
  attr_reader :active
  attr_reader :target
  attr_reader :label
  attr_reader :path
  attr_reader :data
  attr_reader :icon

  def initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {}, icon: nil)
    @label = label
    @path = path
    @active = active
    @target = target
    @data = data
    @icon = icon
  end

  def is_external?
    # If the path contains the scheme, check if it includes the root path or not
    return !path.include?(Avo.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

77 entries across 77 versions & 1 rubygems

Version Path
avo-3.6.4 app/components/avo/sidebar/link_component.rb
avo-3.6.3 app/components/avo/sidebar/link_component.rb
avo-3.6.2 app/components/avo/sidebar/link_component.rb
avo-3.6.1 app/components/avo/sidebar/link_component.rb
avo-3.6.0 app/components/avo/sidebar/link_component.rb
avo-3.5.8 app/components/avo/sidebar/link_component.rb
avo-3.5.7 app/components/avo/sidebar/link_component.rb
avo-3.5.6 app/components/avo/sidebar/link_component.rb
avo-3.5.6.beta1 app/components/avo/sidebar/link_component.rb
avo-3.5.5 app/components/avo/sidebar/link_component.rb
avo-3.5.4 app/components/avo/sidebar/link_component.rb
avo-3.5.3 app/components/avo/sidebar/link_component.rb
avo-3.5.2 app/components/avo/sidebar/link_component.rb
avo-3.5.1 app/components/avo/sidebar/link_component.rb
avo-3.5.0 app/components/avo/sidebar/link_component.rb
avo-3.4.4 app/components/avo/sidebar/link_component.rb
avo-3.4.3 app/components/avo/sidebar/link_component.rb
avo-3.4.2 app/components/avo/sidebar/link_component.rb
avo-3.4.1 app/components/avo/sidebar/link_component.rb
avo-3.4.0 app/components/avo/sidebar/link_component.rb