Merge pull request #1238 from Bnyro/master

make navigation bar responsive (for mobile screens)
This commit is contained in:
Kavin 2022-07-25 10:10:19 +05:30 committed by GitHub
commit 0f16b037fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 26 deletions

View file

@ -208,4 +208,8 @@ h2 {
.auto .link-secondary { .auto .link-secondary {
@apply dark:(text-gray-300 hover:(text-gray-400 underline underline-gray-400)); @apply dark:(text-gray-300 hover:(text-gray-400 underline underline-gray-400));
} }
.line {
@apply px-2.5 py-0.25 my-0.45 rounded-xl bg-white;
}
</style> </style>

View file

@ -26,33 +26,67 @@
@blur="onInputBlur" @blur="onInputBlur"
/> />
</div> </div>
<div class="flex-1 flex justify-end"> <!-- three vertical lines for toggling the hamburger menu on mobile -->
<ul class="flex text-1xl children:pl-3"> <button class="md:hidden flex flex-col justify-end mr-3" @click="showTopNav = !showTopNav">
<li v-if="shouldShowTrending"> <span class="line"></span>
<router-link v-t="'titles.trending'" to="/trending" /> <span class="line"></span>
</li> <span class="line"></span>
<li> </button>
<router-link v-t="'titles.preferences'" to="/preferences" /> <!-- navigation bar for large screen devices -->
</li> <ul class="hidden md:(flex-1 flex justify-end flex text-1xl children:pl-3)">
<li v-if="shouldShowLogin"> <li v-if="shouldShowTrending">
<router-link v-t="'titles.login'" to="/login" /> <router-link v-t="'titles.trending'" to="/trending" />
</li> </li>
<li v-if="shouldShowLogin"> <li>
<router-link v-t="'titles.register'" to="/register" /> <router-link v-t="'titles.preferences'" to="/preferences" />
</li> </li>
<li v-if="shouldShowHistory"> <li v-if="shouldShowLogin">
<router-link v-t="'titles.history'" to="/history" /> <router-link v-t="'titles.login'" to="/login" />
</li> </li>
<li v-if="authenticated"> <li v-if="shouldShowLogin">
<router-link v-t="'titles.playlists'" to="/playlists" /> <router-link v-t="'titles.register'" to="/register" />
</li> </li>
<li v-if="authenticated"> <li v-if="shouldShowHistory">
<router-link v-t="'titles.feed'" to="/feed" /> <router-link v-t="'titles.history'" to="/history" />
</li> </li>
</ul> <li v-if="authenticated">
</div> <router-link v-t="'titles.playlists'" to="/playlists" />
</li>
<li v-if="authenticated && !shouldShowTrending">
<router-link v-t="'titles.feed'" to="/feed" />
</li>
</ul>
</nav> </nav>
<div class="w-full md:hidden"> <!-- navigation bar for mobile devices -->
<ul
v-if="showTopNav"
class="flex flex-col justify-center items-end mb-4 children:(my-0.5 mr-5)"
@click="showTopNav = false"
>
<li v-if="shouldShowTrending">
<router-link v-t="'titles.trending'" to="/trending" />
</li>
<li>
<router-link v-t="'titles.preferences'" to="/preferences" />
</li>
<li v-if="shouldShowLogin">
<router-link v-t="'titles.login'" to="/login" />
</li>
<li v-if="shouldShowLogin">
<router-link v-t="'titles.register'" to="/register" />
</li>
<li v-if="shouldShowHistory">
<router-link v-t="'titles.history'" to="/history" />
</li>
<li v-if="authenticated">
<router-link v-t="'titles.playlists'" to="/playlists" />
</li>
<li v-if="authenticated && !shouldShowTrending">
<router-link v-t="'titles.feed'" to="/feed" />
</li>
</ul>
<!-- search suggestions for mobile devices -->
<div class="w-{full - 4} md:hidden mx-2">
<input <input
v-model="searchText" v-model="searchText"
class="input !h-10 !w-full" class="input !h-10 !w-full"
@ -85,6 +119,7 @@ export default {
return { return {
searchText: "", searchText: "",
suggestionsVisible: false, suggestionsVisible: false,
showTopNav: false,
}; };
}, },
mounted() { mounted() {