fix: sh-admin dashboard bugs and UI polish (#56)

This commit is contained in:
Nivedin
2023-03-29 23:49:34 +05:30
committed by GitHub
parent b826b53cee
commit 885c0dc500
14 changed files with 815 additions and 591 deletions

View File

@@ -1,31 +1,32 @@
<template>
<header
class="flex items-center justify-between border-b border-gray-600 px-6 py-4 bg-neutral-900 shadow-lg"
class="flex items-center justify-between border-b border-divider px-6 py-4 bg-primary shadow-lg"
>
<div class="flex items-center">
<button
<HoppButtonSecondary
v-tippy="{ theme: 'tooltip' }"
title="Open navigation"
:icon="IconMenu"
class="transform !md:hidden mr-2"
@click="isOpen = true"
class="text-gray-200 focus:outline-none md:hidden mr-2"
>
<icon-lucide-menu class="text-gray-300 w-6" />
</button>
<div class="mr-3 mt-2 xs:hidden md:block">
<button @click="expandSidebar">
<icon-lucide-sidebar-open
v-if="isExpanded"
class="text-gray-300 w-6"
/>
<icon-lucide-sidebar-close v-else class="text-gray-300 w-6" />
</button>
</div>
/>
<HoppButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="isExpanded ? 'Collapse sidebar' : 'Expand sidebar'"
:icon="isExpanded ? IconSidebarClose : IconSidebarOpen"
class="transform"
@click="expandSidebar"
/>
</div>
<div class="flex items-center">
<div v-if="currentUser" class="relative">
<button
@click="dropdownOpen = !dropdownOpen"
class="relative z-10 block w-8 h-8 overflow-hidden rounded-full shadow focus:outline-none"
<tippy
interactive
trigger="click"
theme="popover"
arrow
:on-shown="() => tippyActions!.focus()"
>
<ProfilePicture
v-if="currentUser.photoURL"
@@ -42,29 +43,19 @@
:title="currentUser.displayName ?? currentUser.email ?? 'No Name'"
:initial="currentUser.displayName ?? currentUser.email"
/>
</button>
<div
v-show="dropdownOpen"
@click="dropdownOpen = false"
class="fixed inset-0 z-10 w-full h-full"
></div>
<transition
enter-active-class="transition duration-150 ease-out transform"
enter-from-class="scale-95 opacity-0"
enter-to-class="scale-100 opacity-100"
leave-active-class="transition duration-150 ease-in transform"
leave-from-class="scale-100 opacity-100"
leave-to-class="scale-95 opacity-0"
>
<div
v-show="dropdownOpen"
class="absolute right-0 z-20 w-48 py-2 mt-2 bg-zinc-800 rounded-md shadow-xl"
>
<AppLogout ref="logout" />
</div>
</transition>
<template #content="{ hide }">
<div
ref="tippyActions"
class="flex flex-col focus:outline-none"
tabindex="0"
@keyup.escape="hide()"
>
<div>
<AppLogout ref="logout" @click="hide()" />
</div>
</div>
</template>
</tippy>
</div>
</div>
</header>
@@ -72,9 +63,13 @@
<script setup lang="ts">
import { ref } from 'vue';
import { TippyComponent } from 'vue-tippy';
import { useReadonlyStream } from '~/composables/stream';
import { useSidebar } from '~/composables/useSidebar';
import { auth } from '~/helpers/auth';
import IconMenu from '~icons/lucide/menu';
import IconSidebarOpen from '~icons/lucide/sidebar-open';
import IconSidebarClose from '~icons/lucide/sidebar-close';
const { isOpen, isExpanded } = useSidebar();
@@ -87,5 +82,6 @@ const expandSidebar = () => {
isExpanded.value = !isExpanded.value;
};
const dropdownOpen = ref(false);
// Template refs
const tippyActions = ref<TippyComponent | null>(null);
</script>

View File

@@ -4,7 +4,7 @@
<div
:class="isOpen ? 'block' : 'hidden'"
@click="isOpen = false"
class="fixed inset-0 z-20 transition-opacity bg-black opacity-50 lg:hidden"
class="fixed inset-0 z-20 transition-opacity bg-primary opacity-50 lg:hidden"
></div>
<!-- End Backdrop -->
@@ -12,60 +12,45 @@
:class="isOpen ? '' : '!-translate-x-full ease-in'"
class="sidebar-container transform !md:translate-x-0 ease-out"
>
<div :class="isExpanded ? 'w-64' : 'w-full'">
<div class="flex items-center justify-start mt-6 ml-6">
<div :class="isExpanded ? 'w-xs' : 'w-full'">
<div class="flex items-center justify-start px-4 my-4">
<div class="flex items-center">
<HoppSmartLink class="flex items-center space-x-4" to="/dashboard">
<img src="/cover.jpg" alt="hoppscotch-logo" class="h-7" />
<span
v-if="isExpanded"
class="mx-2 text-xl font-semibold text-gray-200"
>Hoppscotch</span
<span v-if="isExpanded" class="font-semibold text-accentContrast"
>HOPPSCOTCH</span
>
</HoppSmartLink>
</div>
</div>
<nav class="mt-10">
<router-link
class="flex items-center px-6 py-4 duration-200 border-l-4"
:class="[route.name === '/dashboard' ? activeClass : inactiveClass]"
to="/dashboard"
<nav class="my-5">
<HoppSmartLink
v-for="(navigation, index) in primaryNavigations"
:key="`navigation-${index}`"
v-tippy="{
theme: 'tooltip',
placement: 'right',
content: !isExpanded ? navigation.label : null,
}"
:to="navigation.to"
tabindex="0"
:exact="navigation.exact"
class="nav-link"
:class="
!isExpanded
? 'flex items-center justify-center'
: 'flex items-center'
"
>
<icon-lucide-layout-dashboard
class="text-xl"
:class="route.name === '/dashboard' ? 'white' : 'gray'"
/>
<span v-if="isExpanded" class="mx-4 font-semibold">Dashboard</span>
</router-link>
<router-link
class="flex items-center px-6 py-4 duration-200 border-l-4 rounded-sm"
:class="[route.name === 'User' ? activeClass : inactiveClass]"
to="/users"
>
<icon-lucide-user
class="text-xl"
:class="route.path === '/users' ? 'white' : 'gray'"
/>
<span v-if="isExpanded" class="mx-4 font-semibold">Users</span>
</router-link>
<router-link
class="flex items-center px-6 py-4 duration-200 border-l-4 rounded-sm"
:class="[route.name === '/teams' ? activeClass : inactiveClass]"
to="/teams"
>
<icon-lucide-users
class="text-xl"
:class="route.name === '/teams' ? 'white' : 'gray'"
/>
<span v-if="isExpanded" class="mx-4 font-semibold">Teams</span>
</router-link>
<div v-if="navigation.icon">
<component :is="navigation.icon" class="svg-icons" />
</div>
<span v-if="isExpanded" class="nav-title">
{{ navigation.label }}
</span>
</HoppSmartLink>
</nav>
</div>
</div>
@@ -75,23 +60,88 @@
<script setup lang="ts">
import { HoppSmartLink } from '@hoppscotch/ui';
import { useSidebar } from '../../composables/useSidebar';
import { useRoute } from 'vue-router';
import IconDashboard from '~icons/lucide/layout-dashboard';
import IconUser from '~icons/lucide/user';
import IconUsers from '~icons/lucide/users';
const { isOpen, isExpanded } = useSidebar();
const route = useRoute();
const activeClass =
'bg-gray-600 bg-opacity-25 text-gray-100 border-gray-100 border-emerald-600';
const inactiveClass =
'border-gray-900 text-gray-500 hover:bg-gray-600 hover:bg-opacity-25 hover:text-gray-100';
const primaryNavigations = [
{
label: 'Dashboard',
icon: IconDashboard,
to: '/dashboard',
exact: true,
},
{
label: 'Users',
icon: IconUser,
to: '/users',
exact: false,
},
{
label: 'Teams',
icon: IconUsers,
to: '/teams',
exact: false,
},
];
</script>
<style scoped>
<style scoped lang="scss">
.sidebar-container {
@apply fixed md:static md:translate-x-0 md:inset-0 inset-y-0 left-0 z-30;
@apply transition duration-300;
@apply flex overflow-y-auto bg-primary border-r border-divider;
}
@apply flex overflow-y-auto bg-neutral-900 border-r border-gray-600;
.nav-link {
@apply relative;
@apply p-4;
@apply flex flex-1;
@apply items-center;
@apply space-x-4;
@apply hover: (bg-primaryDark text-secondaryDark);
@apply focus-visible: text-secondaryDark;
@apply after:absolute;
@apply after:inset-x-0;
@apply after:md: inset-x-auto;
@apply after:md: inset-y-0;
@apply after:bottom-0;
@apply after:md: bottom-auto;
@apply after:md: left-0;
@apply after:z-2;
@apply after:h-0.5;
@apply after:md: h-full;
@apply after:w-full;
@apply after:md: w-0.5;
@apply after:content-DEFAULT;
@apply focus: after: bg-divider;
.svg-icons {
@apply opacity-75;
}
&.router-link-active {
@apply text-secondaryDark;
@apply bg-primaryLight;
@apply hover: text-secondaryDark;
@apply after:bg-accent;
.svg-icons {
@apply opacity-100;
}
}
&.exact-active-link {
@apply text-secondaryDark;
@apply bg-primaryLight;
@apply hover: text-secondaryDark;
@apply after:bg-accent;
.svg-icons {
@apply opacity-100;
}
}
}
</style>