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:, css_classes: []) ⇒ Link

Returns a new instance of Link

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>)

    list of additional CSS classes



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

def initialize(text:, path:, css_classes: [])
  @text = text.freeze
  @path = path.freeze
  @css_classes = Array.wrap(css_classes).dup.freeze
end

Instance Attribute Details

#css_classesArray<String> (readonly)

Returns list of additional CSS classes

Returns:

  • (Array<String>)

    list of additional CSS classes



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

def css_classes
  @css_classes
end

#pathString (readonly)

Supports dynamic paths by setting the base property as a Proc

Returns:

  • (String)

    path for the given link



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

def path
  @path
end

#textString (readonly)

Returns text of the link

Returns:

  • (String)

    text of the link



9
10
11
# File 'app/components/kadmin/navbar/link.rb', line 9

def text
  @text
end