Class: BetterUi::Drawer::LayoutComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::Drawer::LayoutComponent
- Defined in:
- app/components/better_ui/drawer/layout_component.rb
Overview
A responsive layout component that composes header and sidebar with mobile drawer support.
This component provides a complete page layout with a sticky header, responsive sidebar, and main content area. On mobile, the sidebar becomes a slide-out drawer that can be toggled via a menu button.
Constant Summary collapse
- BREAKPOINTS =
Breakpoint configurations for desktop mode
{ md: "md:flex", lg: "lg:flex", xl: "xl:flex" }.freeze
- POSITIONS =
Position configurations
%i[left right].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 Attribute Summary collapse
-
#sidebar_breakpoint ⇒ Symbol
readonly
Returns the sidebar breakpoint.
-
#sidebar_position ⇒ Symbol
readonly
Returns the sidebar position.
Instance Method Summary collapse
-
#initialize(sidebar_position: :left, sidebar_breakpoint: :lg, container_classes: nil, main_classes: nil, **options) ⇒ LayoutComponent
constructor
Initializes a new layout component.
-
#with_header {|header| ... } ⇒ Object
Slot for rendering the HeaderComponent.
-
#with_main ⇒ Object
Slot for rendering the main content area.
-
#with_sidebar {|sidebar| ... } ⇒ Object
Slot for rendering the SidebarComponent.
Constructor Details
#initialize(sidebar_position: :left, sidebar_breakpoint: :lg, container_classes: nil, main_classes: nil, **options) ⇒ LayoutComponent
Initializes a new layout component.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/components/better_ui/drawer/layout_component.rb', line 70 def initialize( sidebar_position: :left, sidebar_breakpoint: :lg, container_classes: nil, main_classes: nil, ** ) @sidebar_position = validate_position() @sidebar_breakpoint = validate_breakpoint() @container_classes = container_classes @main_classes = main_classes @options = end |
Instance Attribute Details
#sidebar_breakpoint ⇒ Symbol (readonly)
Returns the sidebar breakpoint.
92 93 94 |
# File 'app/components/better_ui/drawer/layout_component.rb', line 92 def @sidebar_breakpoint end |
#sidebar_position ⇒ Symbol (readonly)
Returns the sidebar position.
87 88 89 |
# File 'app/components/better_ui/drawer/layout_component.rb', line 87 def @sidebar_position end |
Instance Method Details
#with_header {|header| ... } ⇒ Object
Slot for rendering the HeaderComponent.
47 |
# File 'app/components/better_ui/drawer/layout_component.rb', line 47 renders_one :header, HeaderComponent |
#with_main ⇒ Object
Slot for rendering the main content area.
58 |
# File 'app/components/better_ui/drawer/layout_component.rb', line 58 renders_one :main |
#with_sidebar {|sidebar| ... } ⇒ Object
Slot for rendering the SidebarComponent.
53 |
# File 'app/components/better_ui/drawer/layout_component.rb', line 53 renders_one :sidebar, SidebarComponent |