Skip to content

Commit

Permalink
Recreate improved sidebar toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 15, 2024
1 parent 0e43590 commit af52ebc
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<button
id="sidebar-toggle"
title="Toggle sidebar"
aria-label="Toggle sidebar navigation menu"
@click="sidebarOpen = ! sidebarOpen"
:class="{'[&>span:first-child]:opacity-0 [&>span:nth-child(2)]:rotate-45 [&>span:nth-child(3)]:-rotate-45 [&>span:last-child]:opacity-0': sidebarOpen}"
class="relative inline-block w-8 h-8 hover:text-gray-700 dark:text-gray-200"
>
<span class="block w-5 h-0.5 bg-current absolute left-1.5 top-1 transition-all duration-300 ease-out" role="presentation"></span>
<span class="block w-5 h-0.5 bg-current absolute left-1.5 top-2.5 transition-all duration-300 ease-out origin-center" role="presentation"></span>
<span class="block w-5 h-0.5 bg-current absolute left-1.5 top-2.5 transition-all duration-300 ease-out origin-center" role="presentation"></span>
<span class="block w-5 h-0.5 bg-current absolute left-1.5 top-4 transition-all duration-300 ease-out" role="presentation"></span>
aria-label="Toggle sidebar navigation menu"
@click="sidebarOpen = !sidebarOpen"
class="flex items-center justify-center w-8 h-8 px-2 py-1 hover:text-gray-700 dark:text-gray-200 opacity-75 hover:opacity-100"
>
<div class="relative w-5 h-4">
<div class="absolute top-0 w-5 h-0.5 bg-current transition-all duration-300 ease-in-out" :class="sidebarOpen ? 'opacity-0' : ''"></div>
<div class="absolute inset-0 my-auto w-5 h-0.5 bg-current transition-all duration-300 ease-in-out origin-center" :class="sidebarOpen ? 'rotate-45' : ''"></div>
<div class="absolute inset-0 my-auto w-5 h-0.5 bg-current transition-all duration-300 ease-in-out origin-center" :class="sidebarOpen ? '-rotate-45' : ''"></div>
<div class="absolute bottom-0 w-5 h-0.5 bg-current transition-all duration-300 ease-in-out" :class="sidebarOpen ? 'opacity-0' : ''"></div>
</div>
</button>

0 comments on commit af52ebc

Please sign in to comment.