Class: Kadmin::Navbar::Link

Inherits:
Object
  • Object
show all
Includes:
Presentable
Defined in:
app/components/kadmin/navbar/link.rb

Overview

A navigation link for use with the navbar items

Defined Under Namespace

Classes: Presenter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Presentable

#present

Constructor Details

#initialize(text:, path:, engine: nil, css_classes: []) ⇒ Rails::Application

Returns app application providing URL helpers; if you’re in an engine, pass your engine.

Parameters:

  • text (String)

    the link text; can be HTML

  • path (String, Proc)

    the linked path; if a Proc, will get evaluated everytime when calling the reader

  • css_classes (Array<String>) (defaults to: [])

    list of additional CSS classes



26
27
28
29
30
31
# File 'app/components/kadmin/navbar/link.rb', line 26

def initialize(text:, path:, engine: nil, css_classes: [])
  @text = text.freeze
  @path = path.freeze
  @css_classes = Array.wrap(css_classes).dup.freeze
  @engine = engine || Rails.application
end

Instance Attribute Details

#css_classesArray<String> (readonly)

Returns list of additional CSS classes.

Returns:

  • (Array<String>)

    list of additional CSS classes



17
18
19
# File 'app/components/kadmin/navbar/link.rb', line 17

def css_classes
  @css_classes
end

#engineRails::Engine (readonly)

Returns only pass if you want to access engine routes.

Returns:

  • (Rails::Engine)

    only pass if you want to access engine routes



20
21
22
# File 'app/components/kadmin/navbar/link.rb', line 20

def engine
  @engine
end

#pathString (readonly)

Returns path for the given link.

Returns:

  • (String)

    path for the given link



14
15
16
# File 'app/components/kadmin/navbar/link.rb', line 14

def path
  @path
end

#textString (readonly)

Returns text of the link.

Returns:

  • (String)

    text of the link



11
12
13
# File 'app/components/kadmin/navbar/link.rb', line 11

def text
  @text
end