Class: Panda::Core::Admin::Navigation::SubItemComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- Panda::Core::Admin::Navigation::SubItemComponent
- Defined in:
- app/components/panda/core/admin/navigation/sub_item_component.rb
Overview
A child item within an expandable navigation menu Can render as a link or a button (for logout, etc.)
Constant Summary collapse
- BASE_CLASSES =
"group flex items-center w-full px-3 py-2 cursor-pointer " \ "text-sm font-medium transition-colors"
- ACTIVE_CLASSES =
"bg-primary-500/20 text-white"- INACTIVE_CLASSES =
"text-white/70 hover:bg-white/5"
Constants inherited from Base
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
rubocop:enable Metrics/ParameterLists.
-
#button_options ⇒ Object
readonly
rubocop:enable Metrics/ParameterLists.
-
#label ⇒ Object
readonly
rubocop:enable Metrics/ParameterLists.
-
#method ⇒ Object
readonly
rubocop:enable Metrics/ParameterLists.
-
#path ⇒ Object
readonly
rubocop:enable Metrics/ParameterLists.
-
#target ⇒ Object
readonly
rubocop:enable Metrics/ParameterLists.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #button? ⇒ Boolean
-
#initialize(label:, path: nil, active: false, method: nil, button_options: {}, target: nil, **attrs) ⇒ SubItemComponent
constructor
rubocop:disable Metrics/ParameterLists.
- #item_classes ⇒ Object
Constructor Details
#initialize(label:, path: nil, active: false, method: nil, button_options: {}, target: nil, **attrs) ⇒ SubItemComponent
rubocop:disable Metrics/ParameterLists
16 17 18 19 20 21 22 23 24 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 16 def initialize(label:, path: nil, active: false, method: nil, button_options: {}, target: nil, **attrs) @label = label @path = path @active = active @method = method @button_options = @target = target super(**attrs) end |
Instance Attribute Details
#active ⇒ Object (readonly)
rubocop:enable Metrics/ParameterLists
27 28 29 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 27 def active @active end |
#button_options ⇒ Object (readonly)
rubocop:enable Metrics/ParameterLists
27 28 29 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 27 def @button_options end |
#label ⇒ Object (readonly)
rubocop:enable Metrics/ParameterLists
27 28 29 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 27 def label @label end |
#method ⇒ Object (readonly)
rubocop:enable Metrics/ParameterLists
27 28 29 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 27 def method @method end |
#path ⇒ Object (readonly)
rubocop:enable Metrics/ParameterLists
27 28 29 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 27 def path @path end |
#target ⇒ Object (readonly)
rubocop:enable Metrics/ParameterLists
27 28 29 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 27 def target @target end |
Instance Method Details
#active? ⇒ Boolean
29 30 31 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 29 def active? @active end |
#button? ⇒ Boolean
33 34 35 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 33 def method.present? end |
#item_classes ⇒ Object
37 38 39 |
# File 'app/components/panda/core/admin/navigation/sub_item_component.rb', line 37 def item_classes "#{BASE_CLASSES} #{active? ? ACTIVE_CLASSES : INACTIVE_CLASSES}" end |