Class: Railsboot::Breadcrumb::ItemComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::Breadcrumb::ItemComponent
- Defined in:
- app/components/railsboot/breadcrumb/item_component.rb
Overview
ViewComponent: renders the item block.
Instance Method Summary collapse
-
#before_render ⇒ void
protected
Sets the aria-current attribute when the item is active.
-
#initialize(text: "", href: "", active: false, **html_attributes) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
Constructor Details
#initialize(text: "", href: "", active: false, **html_attributes) ⇒ ItemComponent
Returns a new instance of ItemComponent.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/railsboot/breadcrumb/item_component.rb', line 9 def initialize(text: "", href: "", active: false, **html_attributes) @text = text @href = href @active = active @html_attributes = html_attributes @html_attributes[:tag] = "li" @html_attributes[:class] = class_names( "breadcrumb-item", { "active" => @active }, html_attributes.delete(:class) ) end |
Instance Method Details
#before_render ⇒ void (protected)
This method returns an undefined value.
Sets the aria-current attribute when the item is active.
27 28 29 |
# File 'app/components/railsboot/breadcrumb/item_component.rb', line 27 def before_render @html_attributes["aria-current"] = "page" if @active end |