|
1 | 1 | <template> |
2 | | - <nav class="bg-white dark:bg-gray-900 absolute w-full z-20 top-0 left-0 border-b border-gray-200 dark:border-gray-600 md:h-[64px]"> |
3 | | - <div class="max-w-screen-xl flex flex-col md:flex-row items-start md:items-center justify-between mx-auto p-4"> |
4 | | - <!-- Left Side --> |
5 | | - <div class="flex md:order-2 text-center justify-between w-full md:w-min"> |
6 | | - <router-link to="/" class="flex items-center"> |
7 | | - <WizarrLogo class="mr-3" rounded /> |
8 | | - <span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Wizarr</span> |
9 | | - </router-link> |
10 | | - <button data-collapse-toggle="navbar-default" aria-controls="navbar-default" aria-expanded="false" type="button" class="text-gray-500 dark:text-gray-400 focus:outline-none block md:hidden" @click="expanded = !expanded"> |
11 | | - <i class="fa-solid fa-md fa-xl fa-bars"></i> |
12 | | - </button> |
13 | | - </div> |
14 | | - |
15 | | - <!-- Right Side --> |
16 | | - <div class="flex md:order-2 text-center overflow-hidden justify-end w-full md:w-min mt-3 md:mt-0 md:block" :class="expanded ? 'block' : 'hidden'"> |
17 | | - <ul class="flex flex-col md:flex-row md:space-x-8 md:text-sm md:font-medium w-full md:w-min"> |
18 | | - <!-- Page Links --> |
19 | | - <li v-for="page in pages" :key="page.name" class="flex text-center items-center"> |
20 | | - <router-link :to="page.url" as="button" class="text-left md:text-center w-full md:w-auto block py-2 pl-3 pr-4 text-gray-700 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-primary md:p-0 dark:text-gray-400 md:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent" :class="$route.path == page.url || (page.url == '/admin/settings' && $route.path.includes('/admin/settings')) ? 'text-black dark:text-white' : ''"> |
21 | | - {{ __(page.name) }} |
22 | | - </router-link> |
23 | | - </li> |
24 | | - |
25 | | - <!-- Quick Actions --> |
26 | | - <li class="flex bg-gray-100 dark:bg-gray-800 md:bg-transparent md:dark:bg-transparent rounded text-center p-2 px-3 w-full mt-3 md:mt-0 md:justify-end md:px-0 md:p-0"> |
27 | | - <div class="flex flex-column w-full space-x-3 justify-between"> |
28 | | - <div class="flex flex-column space-x-1"> |
29 | | - <LanguageSelector /> |
30 | | - <ThemeToggle /> |
31 | | - <HelpButton /> |
32 | | - </div> |
33 | | - <span class="inline-flex hidden md:block w-px h-6 bg-gray-200 dark:bg-gray-700"></span> |
34 | | - <LogoutButton /> |
| 2 | + <Disclosure as="nav" class="z-20 bg-white dark:bg-gray-900 absolute w-full top-0 left-0 right-0 border-b border-gray-200 dark:border-gray-600 md:h-[64px]" v-slot="{ open }"> |
| 3 | + <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8"> |
| 4 | + <div class="flex h-16 items-center justify-between"> |
| 5 | + <div class="flex items-center"> |
| 6 | + <router-link to="/" class="flex items-center"> |
| 7 | + <WizarrLogo class="rounded-md" /> |
| 8 | + </router-link> |
| 9 | + <div class="hidden sm:ml-6 sm:block"> |
| 10 | + <div class="flex space-x-4"> |
| 11 | + <router-link v-for="page in pages" :key="page.name" :to="page.url" class="rounded-md px-3 py-2 text-sm font-semibold" :class="$route.path == page.url || (page.url == '/admin/settings' && $route.path.includes('/admin/settings')) ? 'bg-gray-800 text-white' : 'text-black dark:text-gray-300 hover:bg-gray-700 hover:text-white'"> |
| 12 | + {{ __(page.name) }} |
| 13 | + </router-link> |
35 | 14 | </div> |
36 | | - </li> |
37 | | - </ul> |
| 15 | + </div> |
| 16 | + </div> |
| 17 | + <div class="hidden sm:ml-6 sm:block"> |
| 18 | + <div class="flex items-center space-x-3"> |
| 19 | + <LanguageSelector /> |
| 20 | + <ThemeToggle /> |
| 21 | + <HelpButton /> |
| 22 | + <button type="button" class="relative rounded-full text-gray-400 hover:text-white focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800"> |
| 23 | + <span class="sr-only">View notifications</span> |
| 24 | + <BellIcon class="size-5" aria-hidden="true" /> |
| 25 | + </button> |
| 26 | + <Menu as="div" class="relative"> |
| 27 | + <MenuButton class="relative flex rounded-full bg-gray-800 text-sm focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800"> |
| 28 | + <span class="sr-only">Open user menu</span> |
| 29 | + <img class="size-8 rounded-full" src="../../assets/img/profile.jpg" alt="User avatar" /> |
| 30 | + </MenuButton> |
| 31 | + <transition enter-active-class="transition ease-out duration-100" enter-from-class="transform opacity-0 scale-95" enter-to-class="transform opacity-100 scale-100" leave-active-class="transition ease-in duration-75" leave-from-class="transform opacity-100 scale-100" leave-to-class="transform opacity-0 scale-95"> |
| 32 | + <MenuItems class="absolute right-0 z-21 mt-2 w-48 origin-top-right rounded-md bg-white dark:bg-gray-800 ring-1 shadow-lg ring-black/5 overflow-hidden"> |
| 33 | + <MenuItem v-for="item in menuItems" :key="item.text" v-slot="{ active }"> |
| 34 | + <a href="#" :class="[active ? 'bg-gray-100 dark:bg-gray-700' : '', 'block px-4 py-2 text-sm text-gray-700 dark:text-white flex justify-between items-center']"> |
| 35 | + <span>{{ item.text }}</span> |
| 36 | + <i :class="['fa-solid fa-lg', item.icon]"></i> |
| 37 | + </a> |
| 38 | + </MenuItem> |
| 39 | + </MenuItems> |
| 40 | + </transition> |
| 41 | + </Menu> |
| 42 | + </div> |
| 43 | + </div> |
| 44 | + <div class="-mr-2 flex sm:hidden"> |
| 45 | + <DisclosureButton class="relative inline-flex items-center justify-center rounded-md p-2 text-gray-400 hover:bg-gray-700 hover:text-white focus:ring-2 focus:ring-white focus:ring-inset"> |
| 46 | + <Bars3Icon v-if="!open" class="block size-6" aria-hidden="true" /> |
| 47 | + <XMarkIcon v-else class="block size-6" aria-hidden="true" /> |
| 48 | + </DisclosureButton> |
| 49 | + </div> |
38 | 50 | </div> |
39 | 51 | </div> |
40 | | - </nav> |
| 52 | + <DisclosurePanel class="sm:hidden h-[100%]"> |
| 53 | + <div class="border-y border-gray-700 pt-4 pb-3"> |
| 54 | + <div class="flex items-center px-5"> |
| 55 | + <div class="shrink-0"> |
| 56 | + <img class="size-10 rounded-full" src="../../assets/img/profile.jpg" alt="" /> |
| 57 | + </div> |
| 58 | + <div class="ml-3"> |
| 59 | + <div class="text-base font-medium text-white">Tom Cook</div> |
| 60 | + <div class="text-sm font-medium text-gray-400">tom@example.com</div> |
| 61 | + </div> |
| 62 | + <!-- <button type="button" class="relative ml-auto shrink-0 rounded-full bg-gray-800 p-1 text-gray-400 hover:text-white focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800 focus:outline-hidden"> |
| 63 | + <span class="absolute -inset-1.5" /> |
| 64 | + <span class="sr-only">View notifications</span> |
| 65 | + <BellIcon class="size-6" aria-hidden="true" /> |
| 66 | + </button> --> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + <div class="space-y-1 px-2 pt-2 pb-3"> |
| 70 | + <router-link v-for="page in pages" :key="page.name" :to="page.url" class="block rounded-md px-3 py-2 text-base font-medium" :class="$route.path == page.url ? 'bg-gray-900 text-white' : 'text-gray-300 hover:bg-gray-700 hover:text-white'"> |
| 71 | + {{ __(page.name) }} |
| 72 | + </router-link> |
| 73 | + </div> |
| 74 | + </DisclosurePanel> |
| 75 | + </Disclosure> |
41 | 76 | </template> |
42 | 77 |
|
43 | | -<script lang="ts"> |
44 | | -import { defineComponent } from "vue"; |
45 | | -import { useUserStore } from "@/stores/user"; |
46 | | -import { mapState } from "pinia"; |
| 78 | +<style> |
| 79 | +nav[data-headlessui-state="open"] { |
| 80 | + height: 100%; |
| 81 | +} |
| 82 | +</style> |
47 | 83 |
|
48 | | -import WizarrLogo from "@/components/WizarrLogo.vue"; |
| 84 | +<script setup> |
| 85 | +import { Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue"; |
| 86 | +import { Bars3Icon, BellIcon, XMarkIcon, ExclamationCircleIcon, LanguageIcon } from "@heroicons/vue/24/outline"; |
49 | 87 |
|
50 | | -import AccountButton from "@/components/Buttons/AccountButton.vue"; |
| 88 | +import WizarrLogo from "@/components/WizarrLogo.vue"; |
51 | 89 | import LanguageSelector from "@/components/Buttons/LanguageSelector.vue"; |
52 | 90 | import ThemeToggle from "@/components/Buttons/ThemeToggle.vue"; |
53 | | -import ViewToggle from "@/components/Buttons/ViewToggle.vue"; |
54 | 91 | import HelpButton from "@/components/Buttons/HelpButton.vue"; |
55 | | -import LogoutButton from "@/components/Buttons/LogoutButton.vue"; |
56 | 92 |
|
57 | | -export default defineComponent({ |
58 | | - name: "AdminNavBar", |
59 | | - components: { |
60 | | - WizarrLogo, |
61 | | - AccountButton, |
62 | | - LanguageSelector, |
63 | | - ThemeToggle, |
64 | | - ViewToggle, |
65 | | - HelpButton, |
66 | | - LogoutButton, |
67 | | - }, |
68 | | - computed: { |
69 | | - activeLink() { |
70 | | - return this.$route.path; |
71 | | - }, |
72 | | - ...mapState(useUserStore, ["user"]), |
73 | | - }, |
74 | | - data() { |
75 | | - return { |
76 | | - pages: [ |
77 | | - { |
78 | | - name: this.__("Home"), |
79 | | - url: "/admin", |
80 | | - }, |
81 | | - { |
82 | | - name: this.__("Invitations"), |
83 | | - url: "/admin/invitations", |
84 | | - }, |
85 | | - { |
86 | | - name: this.__("Servers"), |
87 | | - url: "/admin/servers", |
88 | | - }, |
89 | | - { |
90 | | - name: this.__("Users"), |
91 | | - url: "/admin/users", |
92 | | - }, |
93 | | - { |
94 | | - name: this.__("Settings"), |
95 | | - url: "/admin/settings", |
96 | | - }, |
97 | | - ], |
98 | | - expanded: false, |
99 | | - }; |
100 | | - }, |
101 | | - watch: { |
102 | | - "$route.path"() { |
103 | | - this.expanded = false; |
104 | | - }, |
105 | | - }, |
106 | | -}); |
| 93 | +const pages = [ |
| 94 | + { name: "Home", url: "/admin" }, |
| 95 | + { name: "Invitations", url: "/admin/invitations" }, |
| 96 | + { name: "Servers", url: "/admin/servers" }, |
| 97 | + { name: "Users", url: "/admin/users" }, |
| 98 | + { name: "Settings", url: "/admin/settings" }, |
| 99 | +]; |
| 100 | +
|
| 101 | +const menuItems = [ |
| 102 | + { text: "Your Profile", icon: "fa-user" }, |
| 103 | + { text: "Settings", icon: "fa-gear" }, |
| 104 | + { text: "Logout", icon: "fa-right-from-bracket" }, |
| 105 | +]; |
107 | 106 | </script> |
0 commit comments