Add mobile friendly nav bar

This commit is contained in:
2024-03-14 21:47:11 +00:00
parent 76fbd3ae9f
commit 94f4726e3a
4 changed files with 270 additions and 14 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">
<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 fade-in px-4 md:px-12 lg:px-24 xl:px-32">
<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">
<NavLink href="/" Match="NavLinkMatch.All" ActiveClass="border-l-2 border-r-2 px-2 rounded"> <div class="mx-auto max-w-7xl">
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-14 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,10 +622,22 @@ video {
display: flex; display: flex;
} }
.inline-flex {
display: inline-flex;
}
.grid { .grid {
display: grid; display: grid;
} }
.hidden {
display: none;
}
.h-10 {
height: 2.5rem;
}
.h-12 { .h-12 {
height: 3rem; height: 3rem;
} }
@@ -629,6 +658,26 @@ video {
height: 100%; height: 100%;
} }
.h-32 {
height: 8rem;
}
.h-20 {
height: 5rem;
}
.h-14 {
height: 3.5rem;
}
.h-28 {
height: 7rem;
}
.h-24 {
height: 6rem;
}
.min-h-screen { .min-h-screen {
min-height: 100vh; min-height: 100vh;
} }
@@ -657,6 +706,10 @@ video {
width: 100%; width: 100%;
} }
.max-w-7xl {
max-width: 80rem;
}
.max-w-xl { .max-w-xl {
max-width: 36rem; max-width: 36rem;
} }
@@ -703,6 +756,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 +769,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,14 +787,28 @@ video {
margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse))); margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse)));
} }
.space-y-1 > :not([hidden]) ~ :not([hidden]) {
--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 { .rounded {
border-radius: 0.25rem; border-radius: 0.25rem;
} }
.rounded-md {
border-radius: 0.375rem;
}
.border-0 { .border-0 {
border-width: 0px; border-width: 0px;
} }
.border {
border-width: 1px;
}
.border-l-2 { .border-l-2 {
border-left-width: 2px; border-left-width: 2px;
} }
@@ -745,10 +822,29 @@ video {
background-color: rgb(0 0 0 / var(--tw-bg-opacity)); background-color: rgb(0 0 0 / var(--tw-bg-opacity));
} }
.bg-gray-800 {
--tw-bg-opacity: 1;
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
}
.bg-gray-900 {
--tw-bg-opacity: 1;
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}
.bg-slate-900 {
--tw-bg-opacity: 1;
background-color: rgb(15 23 42 / 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 +914,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 +934,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 +1010,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));
@@ -941,6 +1055,16 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity)); color: rgb(255 255 255 / var(--tw-text-opacity));
} }
.text-slate-300 {
--tw-text-opacity: 1;
color: rgb(203 213 225 / var(--tw-text-opacity));
}
.text-slate-400 {
--tw-text-opacity: 1;
color: rgb(148 163 184 / var(--tw-text-opacity));
}
.underline { .underline {
text-decoration-line: underline; text-decoration-line: underline;
} }
@@ -1038,16 +1162,36 @@ 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));
} }
.hover\:bg-slate-700:hover {
--tw-bg-opacity: 1;
background-color: rgb(51 65 85 / var(--tw-bg-opacity));
}
.hover\:bg-slate-800:hover {
--tw-bg-opacity: 1;
background-color: rgb(30 41 59 / var(--tw-bg-opacity));
}
.hover\:text-slate-500:hover { .hover\:text-slate-500:hover {
--tw-text-opacity: 1; --tw-text-opacity: 1;
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 +1237,42 @@ body::-webkit-scrollbar-thumb {
grid-column: span 2 / span 2; grid-column: span 2 / span 2;
} }
.sm\:ml-6 {
margin-left: 1.5rem;
}
.sm\:block {
display: block;
}
.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;
}
.sm\:px-6 {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
} }
@media (min-width: 768px) { @media (min-width: 768px) {
@@ -1139,6 +1316,11 @@ body::-webkit-scrollbar-thumb {
padding-left: 6rem; padding-left: 6rem;
padding-right: 6rem; padding-right: 6rem;
} }
.lg\:px-8 {
padding-left: 2rem;
padding-right: 2rem;
}
} }
@media (min-width: 1280px) { @media (min-width: 1280px) {