Class: HakumiComponents::Menu::SubMenu::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Menu::SubMenu::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/menu/sub_menu/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
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#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.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
Instance Method Summary collapse
- #display_label ⇒ Object
- #icon_component ⇒ Object
-
#initialize(key:, label: nil, icon: nil, disabled: false, mode: :vertical, **html_options) ⇒ Component
constructor
A new instance of Component.
- #popup? ⇒ Boolean
- #submenu_classes ⇒ Object
- #title_classes ⇒ Object
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, mode: :vertical, **html_options) ⇒ Component
Returns a new instance of Component.
48 49 50 51 52 53 54 55 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 48 def initialize(key:, label: nil, icon: nil, disabled: false, mode: :vertical, **) @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) @mode = T.let(mode, Symbol) @html_options = T.let(, Types::HtmlAttributes) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
67 68 69 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 67 def disabled @disabled end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
64 65 66 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 64 def icon @icon end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
58 59 60 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 58 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
61 62 63 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 61 def label @label end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
70 71 72 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 70 def mode @mode end |
Instance Method Details
#display_label ⇒ Object
90 91 92 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 90 def display_label content.presence || label end |
#icon_component ⇒ Object
95 96 97 98 99 100 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 95 def icon_component ic = @icon return nil if ic.nil? ic.is_a?(Symbol) ? HakumiComponents::Icon::Component.new(name: ic) : ic end |
#popup? ⇒ Boolean
85 86 87 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 85 def popup? mode != :inline end |
#submenu_classes ⇒ Object
73 74 75 76 77 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 73 def modifiers = T.let({ disabled: disabled }, Types::ClassModifiers) modifiers[popup? ? :popup : :inline] = true class_names("menu-submenu", modifiers) end |
#title_classes ⇒ Object
80 81 82 |
# File 'app/components/hakumi_components/menu/sub_menu/component.rb', line 80 def title_classes "hakumi-menu-submenu-title" end |