Class: BetterUi::Drawer::HeaderComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::Drawer::HeaderComponent
- Defined in:
- app/components/better_ui/drawer/header_component.rb
Overview
A flexible header component for drawer layouts with support for logo, navigation, and actions.
This component provides a responsive header with slots for logo, navigation, actions, and mobile menu button. It supports sticky positioning and multiple visual variants.
Constant Summary collapse
- HEIGHTS =
Height configurations
{ sm: "h-12", md: "h-16", lg: "h-20" }.freeze
- HEADER_VARIANTS =
Visual variant configurations
{ light: { bg: "bg-white", border: "border-b border-grayscale-200", text: "text-grayscale-900" }, dark: { bg: "bg-grayscale-900", border: "border-b border-grayscale-700", text: "text-white" }, transparent: { bg: "bg-transparent", border: "", text: "text-grayscale-900" }, primary: { bg: "bg-primary-600", border: "border-b border-primary-700", text: "text-white" } }.freeze
Constants inherited from ApplicationComponent
ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, 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 Method Summary collapse
-
#initialize(variant: :light, sticky: true, height: :md, container_classes: nil, **options) ⇒ HeaderComponent
constructor
Initializes a new header component.
-
#with_actions ⇒ Object
Slot for rendering actions section (right side).
-
#with_logo ⇒ Object
Slot for rendering the logo/brand section (left side).
-
#with_mobile_menu_button ⇒ Object
Slot for rendering the mobile menu toggle button.
-
#with_navigation ⇒ Object
Slot for rendering the main navigation (center or after logo).
Constructor Details
#initialize(variant: :light, sticky: true, height: :md, container_classes: nil, **options) ⇒ HeaderComponent
Initializes a new header component.
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/components/better_ui/drawer/header_component.rb', line 92 def initialize( variant: :light, sticky: true, height: :md, container_classes: nil, ** ) @variant = validate_variant(variant) @sticky = sticky @height = validate_height(height) @container_classes = container_classes @options = end |
Instance Method Details
#with_actions ⇒ Object
Slot for rendering actions section (right side). Typically contains user menu, notifications, etc.
74 |
# File 'app/components/better_ui/drawer/header_component.rb', line 74 renders_one :actions |
#with_logo ⇒ Object
Slot for rendering the logo/brand section (left side).
62 |
# File 'app/components/better_ui/drawer/header_component.rb', line 62 renders_one :logo |
#with_mobile_menu_button ⇒ Object
Slot for rendering the mobile menu toggle button. Only visible on mobile screens.
80 |
# File 'app/components/better_ui/drawer/header_component.rb', line 80 renders_one :mobile_menu_button |
#with_navigation ⇒ Object
Slot for rendering the main navigation (center or after logo). Hidden on mobile by default.
68 |
# File 'app/components/better_ui/drawer/header_component.rb', line 68 renders_one :navigation |