Sha256: 60b6ddcba909a5f0d0c8200ca9cbd87047a540565744a02dfa2cde2532f2d2d8

Contents?: true

Size: 871 Bytes

Versions: 7

Compression:

Stored size: 871 Bytes

Contents

# frozen_string_literal: true

class Avo::Sidebar::LinkComponent < Avo::BaseComponent
  prop :label, _Nilable(String)
  prop :path, _Nilable(String)
  prop :active, Symbol, default: :inclusive do |value|
    value&.to_sym
  end
  prop :target, _Nilable(Symbol) do |value|
    value&.to_sym
  end
  prop :data, Hash, default: {}.freeze
  prop :icon, _Nilable(String)
  prop :args, Hash, :**, 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

7 entries across 7 versions & 1 rubygems

Version Path
avo-3.13.5 app/components/avo/sidebar/link_component.rb
avo-3.13.4 app/components/avo/sidebar/link_component.rb
avo-3.13.3 app/components/avo/sidebar/link_component.rb
avo-3.13.2 app/components/avo/sidebar/link_component.rb
avo-3.13.1 app/components/avo/sidebar/link_component.rb
avo-3.13.0 app/components/avo/sidebar/link_component.rb
avo-3.12.0 app/components/avo/sidebar/link_component.rb