Class: IronAdmin::Resources::BreadcrumbComponent::ItemComponent Private
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Resources::BreadcrumbComponent::ItemComponent
- Defined in:
- app/components/iron_admin/resources/breadcrumb_component.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Individual breadcrumb item component.
Instance Attribute Summary collapse
-
#current ⇒ Boolean
readonly
private
Whether this is the current page.
-
#href ⇒ String?
readonly
private
Item link URL.
-
#label ⇒ String
readonly
private
Item label text.
Instance Method Summary collapse
-
#call ⇒ String
private
Renders the breadcrumb item.
-
#initialize(label:, href: nil, current: false) ⇒ ItemComponent
constructor
private
A new instance of ItemComponent.
-
#item_classes ⇒ String
private
CSS classes for breadcrumb item.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
Constructor Details
#initialize(label:, href: nil, current: false) ⇒ ItemComponent
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ItemComponent.
30 31 32 33 34 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 30 def initialize(label:, href: nil, current: false) @label = label @href = href @current = current end |
Instance Attribute Details
#current ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Whether this is the current page.
25 26 27 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 25 def current @current end |
#href ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Item link URL.
22 23 24 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 22 def href @href end |
#label ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Item label text.
19 20 21 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 19 def label @label end |
Instance Method Details
#call ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Renders the breadcrumb item.
54 55 56 57 58 59 60 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 54 def call if href && !current link_to(label, href, class: item_classes) else tag.span(label, class: item_classes, aria: current ? { current: "page" } : {}) end end |
#item_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for breadcrumb item.
44 45 46 47 48 49 50 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 44 def item_classes if current "text-sm font-medium #{theme.body_text}" else "text-sm #{theme.link}" end end |
#theme ⇒ IronAdmin::Configuration::Theme
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Theme configuration.
38 39 40 |
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 38 def theme IronAdmin.configuration.theme end |