Class: HakumiComponents::Menu::Item::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Menu::Item::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/menu/item/component.rb
Constant Summary
Constants inherited from BaseComponent
BaseComponent::ControllerOptions, BaseComponent::DateInput, BaseComponent::DateLikeValue, BaseComponent::DimensionInput, BaseComponent::HtmlPayloadInput, BaseComponent::I18nOptionValue, BaseComponent::PresenceArray, BaseComponent::PresenceScalar, BaseComponent::PresenceValue, BaseComponent::RawHtmlInput, BaseComponent::SIZES, BaseComponent::SizeValue, BaseComponent::SymbolInput
Instance Attribute Summary collapse
-
#danger ⇒ Object
readonly
Returns the value of attribute danger.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #display_label ⇒ Object
- #icon_component ⇒ Object
-
#initialize(key:, label: nil, icon: nil, disabled: false, danger: false, href: nil, target: nil, **html_options) ⇒ Component
constructor
A new instance of Component.
- #item_classes ⇒ Object
- #link? ⇒ Boolean
Methods inherited from 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(key:, label: nil, icon: nil, disabled: false, danger: false, href: nil, target: nil, **html_options) ⇒ Component
Returns a new instance of Component.
22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 22 def initialize(key:, label: nil, icon: nil, disabled: false, danger: false, href: nil, target: nil, **) @key = T.let(key, String) @label = T.let(label, T.nilable(String)) @icon = T.let(icon, T.nilable(T.any(Symbol, ViewComponent::Base))) @disabled = T.let(disabled, T::Boolean) @danger = T.let(danger, T::Boolean) @href = T.let(href, T.nilable(String)) @target = T.let(target, T.nilable(String)) @html_options = T.let(, Types::HtmlAttributes) end |
Instance Attribute Details
#danger ⇒ Object (readonly)
Returns the value of attribute danger.
43 44 45 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 43 def danger @danger end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
43 44 45 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 43 def disabled @disabled end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
37 38 39 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 37 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
40 41 42 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 40 def icon @icon end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
34 35 36 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 34 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
37 38 39 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 37 def label @label end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
37 38 39 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 37 def target @target end |
Instance Method Details
#display_label ⇒ Object
56 57 58 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 56 def display_label content.presence || label end |
#icon_component ⇒ Object
61 62 63 64 65 66 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 61 def icon_component ic = @icon return nil if ic.nil? ic.is_a?(Symbol) ? HakumiComponents::Icon::Component.new(name: ic) : ic end |
#item_classes ⇒ Object
46 47 48 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 46 def item_classes class_names("menu-item", { disabled: disabled, danger: danger }) end |
#link? ⇒ Boolean
51 52 53 |
# File 'app/components/hakumi_components/menu/item/component.rb', line 51 def link? href.present? end |