Class: SdrViewComponents::Elements::BreadcrumbComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Elements::BreadcrumbComponent
- Defined in:
- app/components/sdr_view_components/elements/breadcrumb_component.rb
Overview
Displays an item in the top breadcrumb navigation
Instance Attribute Summary collapse
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(text:, link: nil, active: false, truncate_length: 150) ⇒ BreadcrumbComponent
constructor
A new instance of BreadcrumbComponent.
- #truncated_text ⇒ Object
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
#link ⇒ Object (readonly)
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 |
#text ⇒ Object (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
#classes ⇒ Object
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_text ⇒ Object
17 18 19 |
# File 'app/components/sdr_view_components/elements/breadcrumb_component.rb', line 17 def truncated_text truncate(text, length: @truncate_length) end |