Class: HakumiComponents::Breadcrumb::Item::Component
- Inherits:
-
HakumiComponents::BaseComponent
- Object
- ViewComponent::Base
- HakumiComponents::BaseComponent
- HakumiComponents::Breadcrumb::Item::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/breadcrumb/item/component.rb
Constant Summary
Constants inherited from HakumiComponents::BaseComponent
HakumiComponents::BaseComponent::ControllerOptions, HakumiComponents::BaseComponent::DateInput, HakumiComponents::BaseComponent::DateLikeValue, HakumiComponents::BaseComponent::DimensionInput, HakumiComponents::BaseComponent::HtmlPayloadInput, HakumiComponents::BaseComponent::I18nOptionValue, HakumiComponents::BaseComponent::PresenceArray, HakumiComponents::BaseComponent::PresenceScalar, HakumiComponents::BaseComponent::PresenceValue, HakumiComponents::BaseComponent::RawHtmlInput, HakumiComponents::BaseComponent::SIZES, HakumiComponents::BaseComponent::SizeValue, HakumiComponents::BaseComponent::SymbolInput
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#menu ⇒ Object
readonly
Returns the value of attribute menu.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #display_title ⇒ Object
-
#initialize(title: nil, href: nil, target: nil, menu: nil, **html_options) ⇒ Component
constructor
A new instance of Component.
- #item_attributes(extra_classes: []) ⇒ Object
- #item_classes ⇒ Object
- #link? ⇒ Boolean
- #link_attributes ⇒ Object
- #menu? ⇒ Boolean
Methods inherited from HakumiComponents::BaseComponent
#append_data_token, boolean_html_param, #build_inline_style, cast_boolean, #cast_boolean, #class_names, #component_classes, #data_attributes_from, #dimension_to_css, #ensure_dom_id!, float_html_param, #generate_id, #html_classes, html_param, html_primitive_param, #html_style, #i18n_scope, integer_html_param, #merge_attributes, #render_value, #size_to_pixels, #stimulus_attrs, string_html_param, string_or_symbol_array_html_param, symbol_html_param, #t_default, #translate_with_default, #validate_inclusion!, #validate_required!, #value_present?
Constructor Details
#initialize(title: nil, href: nil, target: nil, menu: nil, **html_options) ⇒ Component
Returns a new instance of Component.
19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 19 def initialize(title: nil, href: nil, target: nil, menu: nil, **) @title = T.let(title, T.nilable(String)) @href = T.let(href, T.nilable(String)) @target = T.let(target, T.nilable(String)) @menu = T.let( HakumiComponents::Breadcrumb::Item::MenuEntry.coerce_all(), T.nilable(T::Array[HakumiComponents::Breadcrumb::Item::MenuEntry]) ) @html_options = T.let(, Types::HtmlAttributes) end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
34 35 36 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 34 def href @href end |
#menu ⇒ Object (readonly)
Returns the value of attribute menu.
40 41 42 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 40 def @menu end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
37 38 39 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 37 def target @target end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
31 32 33 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 31 def title @title end |
Instance Method Details
#display_title ⇒ Object
77 78 79 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 77 def display_title content.presence || @title end |
#item_attributes(extra_classes: []) ⇒ Object
48 49 50 51 52 53 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 48 def item_attributes(extra_classes: []) merge_attributes( { class: ([ item_classes ] + extra_classes).join(" ") }, @html_options ) end |
#item_classes ⇒ Object
43 44 45 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 43 def item_classes "hakumi-breadcrumb-link" end |
#link? ⇒ Boolean
64 65 66 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 64 def link? href.present? end |
#link_attributes ⇒ Object
56 57 58 59 60 61 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 56 def link_attributes attrs = item_attributes attrs[:href] = href attrs[:target] = target if target.present? attrs end |
#menu? ⇒ Boolean
69 70 71 72 73 74 |
# File 'app/components/hakumi_components/breadcrumb/item/component.rb', line 69 def m = @menu return false if m.nil? m.any? end |