Class: BetterUi::Drawer::NavGroupComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::Drawer::NavGroupComponent
- Defined in:
- app/components/better_ui/drawer/nav_group_component.rb
Overview
A navigation group component for sidebar menus with a title and collection of items.
Constant Summary collapse
- VARIANTS =
Visual variant configurations for title
{ light: { title: "text-grayscale-500" }, dark: { title: "text-grayscale-400" }, primary: { title: "text-primary-200" } }.freeze
Constants inherited from ApplicationComponent
ApplicationComponent::SHADOWS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED
Instance Attribute Summary collapse
-
#title ⇒ String?
readonly
Returns the title text.
Instance Method Summary collapse
-
#initialize(title: nil, variant: :light, container_classes: nil, **options) ⇒ NavGroupComponent
constructor
Initializes a new nav group component.
-
#with_item {|item| ... } ⇒ Object
Slot for rendering navigation items.
Constructor Details
#initialize(title: nil, variant: :light, container_classes: nil, **options) ⇒ NavGroupComponent
Initializes a new nav group component.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/components/better_ui/drawer/nav_group_component.rb', line 69 def initialize( title: nil, variant: :light, container_classes: nil, ** ) @title = title @variant = validate_variant(variant) @container_classes = container_classes @options = end |
Instance Attribute Details
#title ⇒ String? (readonly)
Returns the title text.
84 85 86 |
# File 'app/components/better_ui/drawer/nav_group_component.rb', line 84 def title @title end |
Instance Method Details
#with_item {|item| ... } ⇒ Object
Slot for rendering navigation items. All parameters are passed to NavItemComponent.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/better_ui/drawer/nav_group_component.rb', line 48 renders_many :items, ->(label:, href:, active: false, method: nil, container_classes: nil, **, &block) { NavItemComponent.new( label: label, href: href, active: active, method: method, variant: @variant, container_classes: container_classes, **, &block ) } |