Sha256: 31c362f80b1bb002409373962341757db6d39ee123ab8fb9480444dfc988b318

Contents?: true

Size: 831 Bytes

Versions: 13

Compression:

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

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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
avo-3.0.0.pre13 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre12 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre10 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre11 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre8 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre9 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre7 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre5 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre6 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre4 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre3 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre2 app/components/avo/sidebar/link_component.rb
avo-3.0.0.pre1 app/components/avo/sidebar/link_component.rb