Skip to content

Commit

Permalink
🐛 Fix minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Jun 11, 2024
1 parent 2db1410 commit 6c31bbd
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 48 deletions.
25 changes: 25 additions & 0 deletions components/buttons/NavButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script setup lang="ts">
import {useRoute} from "vue-router";
const {path, icon} = defineProps<{
path: string,
icon: string,
}>();
const route = useRoute();
function getButtonVariant(){
return route.path === path ? "secondary" : "ghost";
}
</script>

<template>
<Button :variant="getButtonVariant()" @click="navigateTo(path)">
<Icon :name="icon" class="w-4 h-4 mr-2"/>
<slot/>
</Button>
</template>

<style scoped>
</style>
1 change: 0 additions & 1 deletion components/top/AvatarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {Avatar, AvatarImage, AvatarFallback} from "~/components/ui/avatar";
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem @click="$router.push('/')">Home</DropdownMenuItem>
<DropdownMenuItem @click="$router.push('/settings')">Settings</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
21 changes: 12 additions & 9 deletions components/top/BurgerMenu.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<script setup lang="ts">
import {Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger} from "~/components/ui/sheet";
import {Button} from "~/components/ui/button";
import {useRoute} from "vue-router";
const route = useRoute();
import {Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger} from "~/components/ui/sheet";
import NavButton from "~/components/buttons/NavButton.vue";
function getButtonVariant(path: string){
return route.path === path ? "secondary" : "outline";
}
</script>

<template>
Expand All @@ -20,8 +15,16 @@ function getButtonVariant(path: string){
<SheetHeader>
<SheetTitle>Open Webtoon Reader</SheetTitle>
<SheetDescription class="flex flex-col gap-2">
<Button :variant="getButtonVariant('/')" class="w-full" @click="$router.push('/')">Home</Button>
<Button :variant="getButtonVariant('/settings')" class="w-full" @click="$router.push('/settings')">Settings</Button>
<SheetClose as-child>
<NavButton path="/" icon="iconoir:home">
Home
</NavButton>
</SheetClose>
<SheetClose as-child>
<NavButton path="/settings" icon="iconoir:home">
Settings
</NavButton>
</SheetClose>
</SheetDescription>
</SheetHeader>
</SheetContent>
Expand Down
38 changes: 12 additions & 26 deletions components/top/TopMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,28 @@
import BurgerMenu from "~/components/top/BurgerMenu.vue";
import AvatarMenu from "~/components/top/AvatarMenu.vue";
import {Separator} from "~/components/ui/separator";
import {
NavigationMenu,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu";
import {useRoute} from "vue-router";
import NavButton from "~/components/buttons/NavButton.vue";
const route = useRoute();
function getButtonVariant(path: string){
return route.path === path;
}
</script>

<template>
<div>
<div id="mobile" class="md:hidden items-center flex p-2 px-4">
<BurgerMenu/>
<div class="w-full">
<h1 class="text-center p-2 sm:hidden">OWR</h1>
<h1 class="text-center p-2 max-sm:hidden">Open Webtoon Reader</h1>
<h2 class="h2-reset text-center p-2 sm:hidden">OWR</h2>
<h2 class="h2-reset text-center p-2 max-sm:hidden">Open Webtoon Reader</h2>
</div>
<ThemeSwitcher/>
</div>
<div id="pc" class="max-md:hidden items-center flex p-2 px-4 justify-between">
<div class="flex items-center gap-8">
<h1 class="text-center p-2">Open Webtoon Reader</h1>
<NavigationMenu class="h-10">
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuLink href="/" :class="navigationMenuTriggerStyle()" :active="getButtonVariant('/')">
Home
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
<h2 class="h2-reset text-center p-2">Open Webtoon Reader</h2>
<div id="nav" class="flex gap-4">
<NavButton path="/" icon="iconoir:home">
Home
</NavButton>
</div>
</div>
<div id="right" class="flex gap-5">
<ThemeSwitcher/>
Expand All @@ -55,5 +39,7 @@ function getButtonVariant(path: string){
</template>

<style scoped>
h2.h2-reset{
@apply border-none;
}
</style>
18 changes: 18 additions & 0 deletions layouts/NavLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {Toaster} from "~/components/ui/toast";
</script>

<template>
<div>
<Toaster/>
<div class="flex flex-col min-h-screen">
<TopMenu/>
<slot/>
</div>
</div>
</template>

<style scoped>
</style>
1 change: 1 addition & 0 deletions middleware/apiurl.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {getFromLocalStorage, clearFromLocalStorage} from "~/utils/utils";
import {testApiConnection} from "~/utils/api";

export default defineNuxtRouteMiddleware(async() => {
const apiUrl = getFromLocalStorage("apiurl");
Expand Down
10 changes: 4 additions & 6 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import * as apiurlMiddleware from "~/middleware/apiurl.middleware";
definePageMeta({
middleware: [
apiurlMiddleware.default
]
],
layout: "nav-layout"
});
</script>

<template>
<div class="flex flex-col min-h-screen">
<TopMenu/>
<div class="flex flex-1 justify-center items-center text-center">
<h1>Home</h1>
</div>
<div class="flex flex-1 justify-center items-center text-center">
<h1>Home</h1>
</div>
</template>

Expand Down
12 changes: 6 additions & 6 deletions pages/settings/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
definePageMeta({
middleware: "apiurl-middleware",
layout: "nav-layout"
});
</script>

<template>
<div class="flex flex-col min-h-screen">
<TopMenu/>
<div class="flex flex-1 justify-center items-center text-center">
<h1>Settings</h1>
</div>
<div class="flex flex-1 justify-center items-center text-center">
<h1>Settings</h1>
</div>
</template>

Expand Down

0 comments on commit 6c31bbd

Please sign in to comment.