Sha256: f944e5da5f77b90fc82fec6301c116ba217c0e5a3177d79480b3cbbbc62566c6

Contents?: true

Size: 641 Bytes

Versions: 3

Compression:

Stored size: 641 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?
    URI(path).scheme.present?
  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 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
avo-2.5.2.pre.5 app/components/avo/sidebar/link_component.rb
avo-2.5.2.pre.4 app/components/avo/sidebar/link_component.rb
avo-2.5.2.pre.3 app/components/avo/sidebar/link_component.rb