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,8 +26,14 @@
@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">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</button>
<!-- navigation bar for large screen devices -->
<ul class="hidden md:(flex-1 flex justify-end flex text-1xl children:pl-3)">
<li v-if="shouldShowTrending"> <li v-if="shouldShowTrending">
<router-link v-t="'titles.trending'" to="/trending" /> <router-link v-t="'titles.trending'" to="/trending" />
</li> </li>
@ -46,13 +52,41 @@
<li v-if="authenticated"> <li v-if="authenticated">
<router-link v-t="'titles.playlists'" to="/playlists" /> <router-link v-t="'titles.playlists'" to="/playlists" />
</li> </li>
<li v-if="authenticated"> <li v-if="authenticated && !shouldShowTrending">
<router-link v-t="'titles.feed'" to="/feed" /> <router-link v-t="'titles.feed'" to="/feed" />
</li> </li>
</ul> </ul>
</div>
</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() {