Class: Maquina::Navbar::ProfileMenu
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Maquina::Navbar::ProfileMenu
- Includes:
- ApplicationView
- Defined in:
- app/views/maquina/navbar/profile_menu.rb
Overview
Desktop profile menu at Navbar
Renders dropdown profile menu on desktop.
Requires Rails Helper method to get access to options for this menu. Method ‘profile_menu_options` example:
def profile_menu_options
if Current.user.present?
{
profile: profiles_path
signout: { method: :delete, path: session_path }
}
else
{
signin: new_session_path
}
end
end
‘ProfileMenu` uses I18n to translate menu options. Translation example:
menu:
profile:
profile: My profile
signout: Close session
signin: Login
‘ProfileMenu` is initialized by default to render links for desktop. To render mobile links, initialize `ProfileMenu` as follow:
Views::Navbar::ProfileMenu.new(desktop: false)
Instance Method Summary collapse
-
#initialize(desktop: true) ⇒ ProfileMenu
constructor
A new instance of ProfileMenu.
- #view_template ⇒ Object
Methods included from ApplicationView
#attribute_human_name, #button_to, #image_tag, #link_to, #model_human_name, #svg_icon
Constructor Details
#initialize(desktop: true) ⇒ ProfileMenu
Returns a new instance of ProfileMenu.
41 42 43 |
# File 'app/views/maquina/navbar/profile_menu.rb', line 41 def initialize(desktop: true) @desktop = desktop end |
Instance Method Details
#view_template ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/views/maquina/navbar/profile_menu.rb', line 45 def view_template div(**) do .each_pair do |option, path| link_path, attributes = (path) render Maquina::Navbar::ProfileMenuItemLink.new(option, link_path, attributes, desktop: @desktop) end end end |