Skip to content

Commit

Permalink
Revert toggle sidebar
Browse files Browse the repository at this point in the history
Still needs to handle some edge cases on page navigation
Reopens #105
  • Loading branch information
leandrocp committed Feb 13, 2024
1 parent 36ad981 commit 6be3925
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 69 deletions.
18 changes: 0 additions & 18 deletions assets/js/beacon_live_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ window.addEventListener("phx:page-loading-start", (_event) => {

window.addEventListener("phx:page-loading-stop", (_event) => {
topbar.hide()

const sidebarVisivility = localStorage.getItem("beacon:admin:sidebar-visibility")
let sidebar = document.getElementById("sidebar")
let sidebarShow = document.getElementById("sidebar-show")
if (sidebarVisivility === "hidden" && sidebar) { sidebar.style.display = "none" }
if (sidebarVisivility === "hidden" && sidebarShow) { sidebarShow.style.display = "block" }
})

window.addEventListener("beacon_admin:clipcopy", (event) => {
Expand Down Expand Up @@ -57,18 +51,6 @@ window.addEventListener("beacon_admin:clipcopy", (event) => {
}
});

window.addEventListener("beacon:admin:sidebar-visible", (_event) => {
localStorage.setItem("beacon:admin:sidebar-visibility", "visible")
let sidebarShow = document.getElementById("sidebar-show")
if (sidebarShow) { sidebarShow.style.display = "none" }
})

window.addEventListener("beacon:admin:sidebar-hidden", (_event) => {
localStorage.setItem("beacon:admin:sidebar-visibility", "hidden")
let sidebarShow = document.getElementById("sidebar-show")
if (sidebarShow) { sidebarShow.style.display = "block" }
})

let socketPath = document.querySelector("html").getAttribute("phx-socket") || "/live"
let csrfToken = document .querySelector("meta[name='csrf-token']") .getAttribute("content")
let liveSocket = new LiveView.LiveSocket(socketPath, Phoenix.Socket, {
Expand Down
12 changes: 0 additions & 12 deletions lib/beacon/live_admin/page_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,4 @@ defmodule Beacon.LiveAdmin.PageLive do
<span class=""><%= @text %></span>
"""
end

defp show_sidebar do
%JS{}
|> JS.show(to: "#sidebar", time: 300)
|> JS.dispatch("beacon:admin:sidebar-visible")
end

defp hide_sidebar do
%JS{}
|> JS.hide(to: "#sidebar", time: 300)
|> JS.dispatch("beacon:admin:sidebar-hidden")
end
end
6 changes: 0 additions & 6 deletions lib/beacon/live_admin/page_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<div class="flex flex-col h-full min-h-screen px-1 py-2 bg-white shadow-xl @[180px]:pr-0 @[180px]:pl-2 @[240px]:pl-3 @[350px]:pl-6">
<header class="p-2 @[240px]:py-2.5 @[300px]:py-3.5 @[350px]:py-4.5">
<div class="flex items-center justify-center @[180px]:justify-start gap-0 @[180px]:gap-1.5 @[240px]:gap-2.5 @[300px]:gap-3.5 @[350px]:gap-4">
<button id="sidebar-hide" phx-click={hide_sidebar()}>
<.icon name="hero-arrow-long-left" />
</button>
<!--
<% # @Hanna, ask about image paths %>
<img
Expand Down Expand Up @@ -33,8 +30,5 @@
</aside>

<main class="w-full px-4 pt-4 sm:px-6 lg:px-6">
<button id="sidebar-show" phx-click={show_sidebar()} class="hidden">
<.icon name="hero-bars-3" />
</button>
<%= render_page(@beacon_page.module, assigns) %>
</main>
23 changes: 0 additions & 23 deletions priv/static/beacon_live_admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions priv/static/beacon_live_admin.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion priv/static/beacon_live_admin.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion priv/static/beacon_live_admin.min.css.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions priv/static/beacon_live_admin.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions priv/static/beacon_live_admin.min.js.map

Large diffs are not rendered by default.

0 comments on commit 6be3925

Please sign in to comment.