Class: EasyAdmin::SidebarComponent
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- EasyAdmin::SidebarComponent
- Defined in:
- app/components/easy_admin/sidebar_component.rb
Instance Method Summary collapse
-
#initialize(items: nil, current_path: nil, current_user: nil) ⇒ SidebarComponent
constructor
A new instance of SidebarComponent.
- #view_template ⇒ Object
Constructor Details
#initialize(items: nil, current_path: nil, current_user: nil) ⇒ SidebarComponent
Returns a new instance of SidebarComponent.
3 4 5 6 7 |
# File 'app/components/easy_admin/sidebar_component.rb', line 3 def initialize(items: nil, current_path: nil, current_user: nil) @items = items || EasyAdmin.configuration. @current_path = current_path @current_user = current_user end |
Instance Method Details
#view_template ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/components/easy_admin/sidebar_component.rb', line 9 def view_template div(data: { controller: "sidebar-mobile" }) do # Sidebar overlay for mobile div( class: "fixed inset-0 z-40 lg:hidden bg-gray-600 bg-opacity-75 transition-opacity duration-300 opacity-0 pointer-events-none sidebar-overlay", data: { sidebar_target: "overlay", sidebar_mobile_target: "overlay", action: "click->sidebar-mobile#close click->sidebar#close" } ) # Sidebar container aside( class: "fixed inset-y-0 left-0 z-50 w-64 bg-white border-r border-gray-200 transform transition-transform duration-300 -translate-x-full lg:translate-x-0 shadow-lg sidebar", data: { sidebar_target: "container", sidebar_mobile_target: "container", controller: "sidebar-nav" } ) do # Header with logo and brand div(class: "flex items-center justify-between px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-blue-600 to-blue-700 transition-all duration-300") do # Logo container - centers when collapsed div(class: "flex items-center space-x-3 transition-all duration-300 sidebar-logo-container") do div(class: "min-w-[2.5rem] w-10 h-10 bg-white rounded-lg flex items-center justify-center flex-shrink-0 sidebar-logo") do span(class: "text-blue-600 font-bold text-xl") { "EA" } end # App name - hidden when collapsed h2(class: "text-white font-semibold text-lg hidden lg:block transition-opacity duration-300 sidebar-app-name") do EasyAdmin.configuration.app_name end end # Mobile close button ( class: "lg:hidden p-1 rounded-md text-white hover:bg-blue-800 transition-colors", data: { action: "click->sidebar#toggle" } ) do unsafe_raw('<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>') end end # Navigation menu nav(class: "flex-1 px-4 py-6 overflow-y-auto") do ul(class: "space-y-2") do filtered_items.each do |item| (item) end end end end end end |