Sha256: cc64e252a246036281f73e82aec14f828259f04bc054e72fd9f5eb77be1a81a7

Contents?: true

Size: 783 Bytes

Versions: 41

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

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

  def initialize(label: nil, path: nil, active: :inclusive, target: nil)
    @label = label
    @path = path
    @active = active
    @target = target
  end

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

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
avo-2.15.3 app/components/avo/sidebar/link_component.rb
avo-2.15.2 app/components/avo/sidebar/link_component.rb
avo-2.15.2.pre.1 app/components/avo/sidebar/link_component.rb
avo-2.15.1 app/components/avo/sidebar/link_component.rb
avo-2.15.0 app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.7.polytranslations1 app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.6.nosprockets app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.5.nosprockets app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.4.tosqlfix app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.3.jsbundling app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.2.tailwindcss app/components/avo/sidebar/link_component.rb
avo-2.14.3.pre.1.branding app/components/avo/sidebar/link_component.rb
avo-2.14.2 app/components/avo/sidebar/link_component.rb
avo-2.14.2.pre.1 app/components/avo/sidebar/link_component.rb
avo-2.14.1 app/components/avo/sidebar/link_component.rb
avo-2.14.1.pre.1 app/components/avo/sidebar/link_component.rb
avo-2.14.0 app/components/avo/sidebar/link_component.rb
avo-2.13.6.pre.2 app/components/avo/sidebar/link_component.rb
avo-2.13.6.pre.1 app/components/avo/sidebar/link_component.rb
avo-2.13.5.pre.2 app/components/avo/sidebar/link_component.rb