Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move scripts into app.js #35

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
</section>

@includeUnless(config('hyde.footer.enabled', true) && ($withoutNavigation ?? false), 'hyde::layouts.footer')

<!-- The main app script -->
<script defer src="{{ Hyde::relativePath('media/app.js', $currentPage) }}"></script>
</body>
</html>
46 changes: 0 additions & 46 deletions resources/views/layouts/docs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,5 @@
@include('hyde::components.docs.content')
</main>

<script>
var sidebarOpen = screen.width >= 768;

const sidebar = document.getElementById("documentation-sidebar");
const main = document.getElementById("documentation-content");
const backdrop = document.getElementById("sidebar-backdrop");

const toggleButtons = document.querySelectorAll(".sidebar-button-wrapper");

function toggleSidebar() {
if (sidebarOpen) {
hideSidebar();
} else {
showSidebar();
}
}

function showSidebar() {
sidebar.classList.remove("hidden");
sidebar.classList.add("flex");
backdrop.classList.remove("hidden");
document.getElementById("app").style.overflow = "hidden";

toggleButtons.forEach((button) => {
button.classList.remove("open");
button.classList.add("closed");
});

sidebarOpen = true;
}

function hideSidebar() {
sidebar.classList.add("hidden");
sidebar.classList.remove("flex");
backdrop.classList.add("hidden");
document.getElementById("app").style.overflow = null;

toggleButtons.forEach((button) => {
button.classList.add("open");
button.classList.remove("closed");
});

sidebarOpen = false;
}

</script>
<div id="sidebar-backdrop" class="hidden" title="Click to close sidebar" onClick="hideSidebar()"></div>
@endsection
34 changes: 2 additions & 32 deletions resources/views/layouts/navigation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</a>
</header>

<button class="navigation-toggle-button md:hidden" title="Open navigation menu" onClick="showNavigation()">
<button class="navigation-toggle-button md:hidden px-4" title="Open navigation menu" onClick="showNavigation()">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>
</button>

Expand All @@ -35,7 +35,7 @@
</a>
</header>

<button class="navigation-toggle-button" title="Close navigation menu" onClick="hideNavigation()">
<button class="navigation-toggle-button px-4" title="Close navigation menu" onClick="hideNavigation()">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
</button>
</div>
Expand All @@ -56,33 +56,3 @@
@endforeach
</ul>
</nav>


<script>
const mainNavigation = document.getElementById("main-navigation");
const mobileNavigation = document.getElementById("mobile-navigation");
var navigationOpen = false;

function toggleNavigation() {
if (navigationOpen) {
hideNavigation();
} else {
showNavigation();
}
}

function showNavigation() {
mobileNavigation.classList.add("flex");
mobileNavigation.classList.remove("hidden");

navigationOpen = true;
}

function hideNavigation() {
mobileNavigation.classList.remove("flex");
mobileNavigation.classList.add("hidden");

navigationOpen = false;
}

</script>