Merge pull request #14 from bdfin/add-mobile-friendly-nav

Add mobile friendly nav bar
This commit is contained in:
2024-03-14 22:07:38 +00:00
committed by GitHub
4 changed files with 208 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
<footer class="mt-auto"> <footer class="mt-auto">
<div class="mx-auto py-8 px-4 md:px-12"> <div class="mx-auto py-8">
<div class="md:flex md:items-center md:justify-between"> <div class="md:flex md:items-center md:justify-between">
<div class="flex space-x-6 md:order-2"> <div class="flex space-x-6 md:order-2">
<a href="https://github.com/bdfin" class="text-slate-200 hover:text-slate-500"> <a href="https://github.com/bdfin" class="text-slate-200 hover:text-slate-500">

View File

@@ -1,9 +1,9 @@
@inherits LayoutComponentBase @inherits LayoutComponentBase
<div class="flex flex-col min-h-screen fade-in"> <div class="flex flex-col min-h-screen mx-auto max-w-screen-2xl fade-in px-4 md:px-12 lg:px-24">
<NavBar/> <NavBar/>
<div class="flex-1 px-4 md:px-12 lg:px-24 xl:px-32 py-4"> <div class="flex-1 py-8">
@Body @Body
</div> </div>

View File

@@ -1,11 +1,85 @@
<nav class="flex items-center justify-center py-8 md:py-12 space-x-8"> <nav class="bg-black py-4">
<NavLink href="/" Match="NavLinkMatch.All" ActiveClass="border-l-2 border-r-2 px-2 rounded"> <div class="mx-auto">
Home <div class="relative flex h-20 items-center justify-between">
</NavLink> <div class="absolute inset-y-0 left-0 flex items-center sm:hidden">
<NavLink href="/contact" Match="NavLinkMatch.All" ActiveClass="border-l-2 border-r-2 px-2 rounded"> <!-- Mobile menu button-->
Contact <button @onclick="ToggleMenu" type="button" class="relative inline-flex items-center justify-center rounded-md p-2 text-gray-400 hover:text-white" aria-controls="mobile-menu" aria-expanded="false">
</NavLink> <span class="sr-only">Open main menu</span>
<NavLink href="/about" Match="NavLinkMatch.All" ActiveClass="border-l-2 border-r-2 px-2 rounded"> @if (menuOpen)
This App {
</NavLink> <i class="fa-solid fa-xmark fa-xl"></i>
}
else
{
<i class="fa-solid fa-bars fa-xl"></i>
}
</button>
</div>
<div class="flex flex-1 items-center justify-center sm:items-stretch sm:justify-start">
<div class="flex flex-shrink-0 items-center">
<img class="h-16 w-auto" src="images/logo.png" alt="Your Company">
</div>
<div class="items-center hidden sm:flex sm:flex-1 justify-center">
<div class="flex space-x-4">
<NavLink href="/"
Match="NavLinkMatch.All"
ActiveClass="bg-gray-900 text-white"
class="text-gray-300 hover:bg-gray-800 hover:text-white rounded-md px-3 py-2 font-medium">
Home
</NavLink>
<NavLink href="/contact"
Match="NavLinkMatch.Prefix"
ActiveClass="bg-gray-900 text-white"
class="text-gray-300 hover:bg-gray-800 hover:text-white rounded-md px-3 py-2 font-medium">
Contact
</NavLink>
<NavLink href="/about"
Match="NavLinkMatch.Prefix"
ActiveClass="bg-gray-900 text-white"
class="text-gray-300 hover:bg-gray-800 hover:text-white rounded-md px-3 py-2 font-medium">
This App
</NavLink>
</div>
</div>
</div>
</div>
</div>
@if (menuOpen)
{
<div class="sm:hidden" id="mobile-menu">
<div class="space-y-1 px-2 pb-3 pt-2">
<NavLink href="/"
Match="NavLinkMatch.All"
ActiveClass="bg-gray-900 text-white"
class="block text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 font-medium">
Home
</NavLink>
<NavLink href="/contact"
Match="NavLinkMatch.Prefix"
ActiveClass="bg-gray-900 text-white"
class="block text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 font-medium">
Contact
</NavLink>
<NavLink href="/about"
Match="NavLinkMatch.Prefix"
ActiveClass="bg-gray-900 text-white"
class="block text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 font-medium">
This App
</NavLink>
</div>
</div>
}
</nav> </nav>
@code {
private bool menuOpen;
private void ToggleMenu()
{
menuOpen = !menuOpen;
}
}

View File

@@ -560,6 +560,23 @@ video {
position: static; position: static;
} }
.absolute {
position: absolute;
}
.relative {
position: relative;
}
.inset-y-0 {
top: 0px;
bottom: 0px;
}
.left-0 {
left: 0px;
}
.m-auto { .m-auto {
margin: auto; margin: auto;
} }
@@ -605,14 +622,30 @@ video {
display: flex; display: flex;
} }
.inline-flex {
display: inline-flex;
}
.grid { .grid {
display: grid; display: grid;
} }
.hidden {
display: none;
}
.h-12 { .h-12 {
height: 3rem; height: 3rem;
} }
.h-14 {
height: 3.5rem;
}
.h-20 {
height: 5rem;
}
.h-5 { .h-5 {
height: 1.25rem; height: 1.25rem;
} }
@@ -629,6 +662,10 @@ video {
height: 100%; height: 100%;
} }
.h-16 {
height: 4rem;
}
.min-h-screen { .min-h-screen {
min-height: 100vh; min-height: 100vh;
} }
@@ -657,10 +694,18 @@ video {
width: 100%; width: 100%;
} }
.max-w-7xl {
max-width: 80rem;
}
.max-w-xl { .max-w-xl {
max-width: 36rem; max-width: 36rem;
} }
.max-w-screen-2xl {
max-width: 1536px;
}
.flex-1 { .flex-1 {
flex: 1 1 0%; flex: 1 1 0%;
} }
@@ -703,6 +748,10 @@ video {
justify-content: center; justify-content: center;
} }
.justify-between {
justify-content: space-between;
}
.gap-x-8 { .gap-x-8 {
-moz-column-gap: 2rem; -moz-column-gap: 2rem;
column-gap: 2rem; column-gap: 2rem;
@@ -712,6 +761,12 @@ video {
row-gap: 1.5rem; row-gap: 1.5rem;
} }
.space-x-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
}
.space-x-6 > :not([hidden]) ~ :not([hidden]) { .space-x-6 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0; --tw-space-x-reverse: 0;
margin-right: calc(1.5rem * var(--tw-space-x-reverse)); margin-right: calc(1.5rem * var(--tw-space-x-reverse));
@@ -724,31 +779,38 @@ video {
margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse))); margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse)));
} }
.rounded { .space-y-1 > :not([hidden]) ~ :not([hidden]) {
border-radius: 0.25rem; --tw-space-y-reverse: 0;
margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(0.25rem * var(--tw-space-y-reverse));
}
.rounded-md {
border-radius: 0.375rem;
} }
.border-0 { .border-0 {
border-width: 0px; border-width: 0px;
} }
.border-l-2 {
border-left-width: 2px;
}
.border-r-2 {
border-right-width: 2px;
}
.bg-black { .bg-black {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity)); background-color: rgb(0 0 0 / var(--tw-bg-opacity));
} }
.bg-gray-900 {
--tw-bg-opacity: 1;
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}
.fill-gray-600 { .fill-gray-600 {
fill: #4b5563; fill: #4b5563;
} }
.p-2 {
padding: 0.5rem;
}
.px-2 { .px-2 {
padding-left: 0.5rem; padding-left: 0.5rem;
padding-right: 0.5rem; padding-right: 0.5rem;
@@ -818,6 +880,10 @@ video {
padding-bottom: 0.5rem; padding-bottom: 0.5rem;
} }
.pb-3 {
padding-bottom: 0.75rem;
}
.pb-4 { .pb-4 {
padding-bottom: 1rem; padding-bottom: 1rem;
} }
@@ -834,6 +900,10 @@ video {
padding-top: 4rem; padding-top: 4rem;
} }
.pt-2 {
padding-top: 0.5rem;
}
.pt-4 { .pt-4 {
padding-top: 1rem; padding-top: 1rem;
} }
@@ -906,6 +976,16 @@ video {
color: rgb(229 231 235 / var(--tw-text-opacity)); color: rgb(229 231 235 / var(--tw-text-opacity));
} }
.text-gray-300 {
--tw-text-opacity: 1;
color: rgb(209 213 219 / var(--tw-text-opacity));
}
.text-gray-400 {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
}
.text-green-500 { .text-green-500 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(34 197 94 / var(--tw-text-opacity)); color: rgb(34 197 94 / var(--tw-text-opacity));
@@ -1038,6 +1118,11 @@ body::-webkit-scrollbar-thumb {
color: rgb(156 163 175 / var(--tw-text-opacity)); color: rgb(156 163 175 / var(--tw-text-opacity));
} }
.hover\:bg-gray-700:hover {
--tw-bg-opacity: 1;
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
}
.hover\:bg-gray-800:hover { .hover\:bg-gray-800:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(31 41 55 / var(--tw-bg-opacity)); background-color: rgb(31 41 55 / var(--tw-bg-opacity));
@@ -1048,6 +1133,11 @@ body::-webkit-scrollbar-thumb {
color: rgb(100 116 139 / var(--tw-text-opacity)); color: rgb(100 116 139 / var(--tw-text-opacity));
} }
.hover\:text-white:hover {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}
.focus\:ring-2:focus { .focus\:ring-2:focus {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
@@ -1093,9 +1183,29 @@ body::-webkit-scrollbar-thumb {
grid-column: span 2 / span 2; grid-column: span 2 / span 2;
} }
.sm\:flex {
display: flex;
}
.sm\:hidden {
display: none;
}
.sm\:flex-1 {
flex: 1 1 0%;
}
.sm\:grid-cols-2 { .sm\:grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-columns: repeat(2, minmax(0, 1fr));
} }
.sm\:items-stretch {
align-items: stretch;
}
.sm\:justify-start {
justify-content: flex-start;
}
} }
@media (min-width: 768px) { @media (min-width: 768px) {
@@ -1127,11 +1237,6 @@ body::-webkit-scrollbar-thumb {
padding-left: 3rem; padding-left: 3rem;
padding-right: 3rem; padding-right: 3rem;
} }
.md\:py-12 {
padding-top: 3rem;
padding-bottom: 3rem;
}
} }
@media (min-width: 1024px) { @media (min-width: 1024px) {