Class: UI::SidebarProvider
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SidebarProvider
- Includes:
- SidebarProviderBehavior
- Defined in:
- app/components/ui/sidebar_provider.rb
Overview
SidebarProvider - Phlex implementation
Root container for sidebar that manages state via Stimulus controller. Wraps the entire layout (sidebar + main content).
Instance Method Summary collapse
-
#initialize(open: true, collapsible: "icon", side: "left", cookie_name: "sidebar_state", sidebar_width: "16rem", sidebar_width_mobile: "18rem", sidebar_width_icon: "3rem", classes: "", **attributes) ⇒ SidebarProvider
constructor
A new instance of SidebarProvider.
- #view_template(&block) ⇒ Object
Methods included from SidebarProviderBehavior
#sidebar_provider_classes, #sidebar_provider_data_attributes, #sidebar_provider_html_attributes, #sidebar_provider_style
Constructor Details
#initialize(open: true, collapsible: "icon", side: "left", cookie_name: "sidebar_state", sidebar_width: "16rem", sidebar_width_mobile: "18rem", sidebar_width_icon: "3rem", classes: "", **attributes) ⇒ SidebarProvider
Returns a new instance of SidebarProvider.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/ui/sidebar_provider.rb', line 34 def initialize( open: true, collapsible: "icon", side: "left", cookie_name: "sidebar_state", sidebar_width: "16rem", sidebar_width_mobile: "18rem", sidebar_width_icon: "3rem", classes: "", **attributes ) @open = open @collapsible = collapsible @side = side @cookie_name = @sidebar_width = @sidebar_width_mobile = @sidebar_width_icon = @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/components/ui/sidebar_provider.rb', line 56 def view_template(&block) all_attributes = # Merge classes with TailwindMerge if @attributes.key?(:class) merged_class = TailwindMerge::Merger.new.merge([ all_attributes[:class], @attributes[:class] ].compact.join(" ")) all_attributes = all_attributes.merge(class: merged_class) end # Deep merge other attributes (excluding class) all_attributes = all_attributes.deep_merge(@attributes.except(:class)) div(**all_attributes, &block) end |