Class: BetterUi::Drawer::SidebarComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::Drawer::SidebarComponent
- Defined in:
- app/components/better_ui/drawer/sidebar_component.rb
Overview
A flexible sidebar component for drawer layouts with support for header, navigation, and footer.
This component provides a responsive sidebar that can slide in from left or right on mobile, with configurable width and visual variants. It supports slots for header (logo/brand), main navigation, and footer sections.
Constant Summary collapse
- WIDTHS =
Width configurations
{ sm: "w-16", # 64px - icon-only sidebar md: "w-64", # 256px - standard sidebar lg: "w-80" # 320px - wide sidebar }.freeze
- POSITIONS =
Position configurations
%i[left right].freeze
- SIDEBAR_VARIANTS =
Visual variant configurations
{ light: { bg: "bg-white", border: "border-grayscale-200", text: "text-grayscale-900" }, dark: { bg: "bg-grayscale-900", border: "border-grayscale-700", text: "text-white" }, primary: { bg: "bg-primary-800", border: "border-primary-900", 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 Attribute Summary collapse
-
#position ⇒ Symbol
readonly
Returns the sidebar position.
Instance Method Summary collapse
-
#initialize(variant: :light, position: :left, width: :md, collapsible: true, container_classes: nil, header_classes: nil, navigation_classes: nil, footer_classes: nil, **options) ⇒ SidebarComponent
constructor
Initializes a new sidebar component.
-
#with_footer ⇒ Object
Slot for rendering the sidebar footer section (user info, settings).
-
#with_header ⇒ Object
Slot for rendering the sidebar header section (logo, brand).
-
#with_navigation ⇒ Object
Slot for rendering the main navigation content.
Constructor Details
#initialize(variant: :light, position: :left, width: :md, collapsible: true, container_classes: nil, header_classes: nil, navigation_classes: nil, footer_classes: nil, **options) ⇒ SidebarComponent
Initializes a new sidebar component.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/components/better_ui/drawer/sidebar_component.rb', line 86 def initialize( variant: :light, position: :left, width: :md, collapsible: true, container_classes: nil, header_classes: nil, navigation_classes: nil, footer_classes: nil, ** ) @variant = validate_variant(variant) @position = validate_position(position) @width = validate_width(width) @collapsible = collapsible @container_classes = container_classes @header_classes = header_classes @navigation_classes = @footer_classes = @options = end |
Instance Attribute Details
#position ⇒ Symbol (readonly)
Returns the sidebar position.
111 112 113 |
# File 'app/components/better_ui/drawer/sidebar_component.rb', line 111 def position @position end |
Instance Method Details
#with_footer ⇒ Object
Slot for rendering the sidebar footer section (user info, settings).
69 |
# File 'app/components/better_ui/drawer/sidebar_component.rb', line 69 renders_one :footer |
#with_header ⇒ Object
Slot for rendering the sidebar header section (logo, brand).
59 |
# File 'app/components/better_ui/drawer/sidebar_component.rb', line 59 renders_one :header |
#with_navigation ⇒ Object
Slot for rendering the main navigation content.
64 |
# File 'app/components/better_ui/drawer/sidebar_component.rb', line 64 renders_one :navigation |