Class: SdrViewComponents::Elements::BreadcrumbComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/sdr_view_components/elements/breadcrumb_component.rb

Overview

Displays an item in the top breadcrumb navigation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#args_for, #merge_actions, #merge_classes

Constructor Details

#initialize(text:, link: nil, active: false, truncate_length: 150) ⇒ BreadcrumbComponent

Returns a new instance of BreadcrumbComponent.



7
8
9
10
11
12
13
# File 'app/components/sdr_view_components/elements/breadcrumb_component.rb', line 7

def initialize(text:, link: nil, active: false, truncate_length: 150)
  @text = text
  @link = link
  @active = active
  @truncate_length = truncate_length
  super()
end

Instance Attribute Details

Returns the value of attribute link.



15
16
17
# File 'app/components/sdr_view_components/elements/breadcrumb_component.rb', line 15

def link
  @link
end

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'app/components/sdr_view_components/elements/breadcrumb_component.rb', line 15

def text
  @text
end

Instance Method Details

#classesObject



21
22
23
24
25
# File 'app/components/sdr_view_components/elements/breadcrumb_component.rb', line 21

def classes
  return 'breadcrumb-item active' if link.nil? || @active

  'breadcrumb-item'
end

#truncated_textObject



17
18
19
# File 'app/components/sdr_view_components/elements/breadcrumb_component.rb', line 17

def truncated_text
  truncate(text, length: @truncate_length)
end