-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: dropdown (and items) view component for navbar
- Loading branch information
Showing
12 changed files
with
69 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<button data-controller="dark-mode-switcher" data-action="click->dark-mode-switcher#toggle"> | ||
<i class="fa fa-lightbulb hidden dark:inline"></i> | ||
<i class="fa fa-moon inline dark:hidden"></i> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Navbar::DarkModeSwitch::Component < ApplicationViewComponent | ||
# with_collection_parameter :dark_mode_switch | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class Navbar::DarkModeSwitch::Preview < ApplicationViewComponentPreview | ||
# You can specify the container class for the default template | ||
# self.container_class = "w-1/2 border border-gray-300" | ||
|
||
def default | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%= link_to path, class: "flex items-center justify-between px-4 py-2.5 hover:bg-background" do %> | ||
<span><%= label %></span> | ||
<i class="<%= icon %> w-3 h-3 float-right"></i> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Navbar::Dropdown::Item::Component < ApplicationViewComponent | ||
option :label, default: -> { "Dropdown item" } | ||
option :icon, optional: true | ||
option :path | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class Navbar::Dropdown::Item::Preview < ApplicationViewComponentPreview | ||
# You can specify the container class for the default template | ||
# self.container_class = "w-1/2 border border-gray-300" | ||
|
||
def default | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
<%= navbar do |navbar| %> | ||
<%= render "partials/navbars/logo" %> | ||
|
||
<nav class="flex gap-x-8"> | ||
<%= user_signed_in? ? render("partials/navbars/protected", navbar:) : render("partials/navbars/public", navbar:) %> | ||
</nav> | ||
|
||
<% navbar.with_right_section do %> | ||
<button data-controller="dark-mode-switcher" data-action="click->dark-mode-switcher#toggle"> | ||
<i class="fa fa-lightbulb hidden dark:inline"></i> | ||
<i class="fa fa-moon inline dark:hidden"></i> | ||
</button> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
<%= link_to "Dashboard", dashboard_path %> | ||
|
||
<% navbar.with_right_section do %> | ||
<%= render(Navbar::AccountSelector::Component.new(current_user:, current_account:)) if onboarded? %> | ||
<%= button_to "Sign out", destroy_user_session_path, method: :delete %> | ||
<%= navbar.account_selector(current_user:, current_account:) if onboarded? %> | ||
|
||
<%= render(Navbar::Dropdown::Component.new(chevron: false)) do |dropdown| %> | ||
<% dropdown.with_custom_content do %> | ||
<i class="fa fa-gear"></i> | ||
<% end %> | ||
<%= dropdown.item(label: "Edit profile", icon: "fa fa-user", path: "#") %> | ||
<%= dropdown.item(label: "Change password", icon: "fa fa-key", path: edit_user_registration_path) %> | ||
<% end %> | ||
|
||
<%= navbar.dark_mode_switch %> | ||
<%= button_to destroy_user_session_path, method: :delete, class: "button" do %> | ||
<i class="fa fa-sign-out text-rose-400"></i> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters