Class: BetterUi::Breadcrumb::ItemComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::Breadcrumb::ItemComponent
- Defined in:
- app/components/better_ui/breadcrumb/item_component.rb
Overview
A breadcrumb item component that renders as a link or current page indicator.
When an href is provided, the item renders as a link. When href is nil, it renders as a span with aria-current="page" to indicate the current page.
Constant Summary
Constants inherited from ApplicationComponent
ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED
Instance Method Summary collapse
-
#current? ⇒ Boolean
Whether this item represents the current page.
-
#initialize(label:, href: nil, **options) ⇒ ItemComponent
constructor
Initializes a new breadcrumb item component.
-
#with_icon_before ⇒ Object
Slot for rendering an icon before the label.
Constructor Details
#initialize(label:, href: nil, **options) ⇒ ItemComponent
Initializes a new breadcrumb item component.
33 34 35 36 37 |
# File 'app/components/better_ui/breadcrumb/item_component.rb', line 33 def initialize(label:, href: nil, **) @label = label @href = href @options = end |
Instance Method Details
#current? ⇒ Boolean
Whether this item represents the current page.
42 43 44 |
# File 'app/components/better_ui/breadcrumb/item_component.rb', line 42 def current? @href.nil? end |
#with_icon_before ⇒ Object
Slot for rendering an icon before the label.
26 |
# File 'app/components/better_ui/breadcrumb/item_component.rb', line 26 renders_one :icon_before |