Skip to content

Commit 7012722

Browse files
authored
Merge pull request #24 from ltv/feat/PT-66
feat(frontend)::guitar: Design Left Sidebar layout || JIRA: PT-66
2 parents 3fe2178 + 5be3a46 commit 7012722

File tree

9 files changed

+139
-39
lines changed

9 files changed

+139
-39
lines changed

src/components/Navigation/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex items-center px-4 py-2 shadow-sm">
2+
<div class="flex items-center px-4 py-2 shadow-sm bg-slate-100">
33
<div class="mr-auto"><strong>Hi Bieber,</strong> Have a nice day!</div>
44
<div class="flex">
55
<el-button type="primary" class="rounded-full px-2 ml-2">

src/components/Sidebar/SidebarNav.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const navigation = () => {
44
return routes.reduce((prev: any, curr) => {
55
const { meta, path, name } = curr
66
if (meta.icon) {
7-
prev.push({ name, href: path, icon: meta.icon, title: meta.title })
7+
prev.push({ name, href: path, icon: meta.icon, color: meta.color, title: meta.title })
88
}
99
return prev
1010
}, [])

src/components/Sidebar/index.vue

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,73 @@
11
<template>
22
<aside
3+
@mouseover="hoverLeftBar(true)"
4+
@mouseleave="hoverLeftBar(false)"
35
aria-labelledby="primary-heading"
4-
class="z-20 bg-slate-100 flex-shrink-0 w-64 overflow-y-auto h-full rounded-tr-3xl rounded-br-3xl hidden md:block"
6+
class="transition-all duration-300 fixed z-20 bg-white flex-shrink-0 w-15 overflow-y-auto h-full hidden md:block items-center"
7+
:class="{ 'w-64': isHover }"
58
>
6-
<div class="py-4 text-gray-500">
7-
<ul class="mt-2">
8-
<li class="relative px-6 py-3" v-for="(item, index) in menuItems" :key="index">
9-
<span
10-
v-if="route.name === item.name"
11-
class="absolute inset-y-0 left-0 w-1 bg-purple-600 rounded-tr-lg rounded-br-lg"
12-
aria-hidden="true"
13-
></span>
14-
<router-link
15-
:class="{ 'text-gray-800': route.name === item.name }"
16-
class="inline-flex items-center w-full text-sm font-semibold transition-colors duration-150 hover:text-gray-800"
17-
:to="{ name: item.name }"
18-
:title="item.title"
9+
<div class="container flex flex-col mx-auto items-stretch">
10+
<div class="h-20 flex items-center">
11+
<a
12+
v-if="isHover"
13+
class="flex p-6 block"
14+
href="https://argon-dashboard-pro-laravel.creative-tim.com/dashboard"
15+
>
16+
<img
17+
src="https://argon-dashboard-pro-laravel.creative-tim.com/argon/img/brand/blue.png"
18+
class="max-h-9 max-w-full align-middle"
19+
alt="..."
20+
/>
21+
</a>
22+
<div class="ml-auto">
23+
<div class="lg:col-span-10 xl:col-span-10 flex">
24+
<div class="hidden md:block flex-grow">
25+
<div class="flex items-center space-x-2 2xl:space-x-4 text-black px-5">
26+
<MenuIcon v-if="isHide" class="cursor-pointer h-6 w-6" @click="isHide = !isHide" />
27+
<MenuAlt1Icon
28+
v-if="isHover && !isHide"
29+
class="cursor-pointer h-6 w-6"
30+
@click="isHide = !isHide"
31+
/>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
<div class="flex flex-col text-gray-400 px-6 before:block before:mt-6">
38+
<ul class="flex flex-col -mx-6">
39+
<li
40+
class="relative flex flex-row px-5 py-3 h-12"
41+
v-for="(item, index) in menuItems"
42+
:key="index"
1943
>
20-
<component :is="item.icon" class="h-5 w-5" aria-hidden="true" />
21-
<span class="ml-4">{{ item.title }}</span>
22-
</router-link>
23-
</li>
24-
</ul>
44+
<span
45+
v-if="route.name === item.name"
46+
class="absolute flex inset-y-1 left-0 w-0.5 h-5/6 bg-indigo-500 rounded-tr-lg rounded-br-lg"
47+
aria-hidden="true"
48+
></span>
49+
<router-link
50+
class="inline-flex items-center w-full text-sm my-0.5 transition-colors duration-150 hover:text-gray-800"
51+
:class="{ 'text-gray-800': route.name === item.name }"
52+
:to="{ name: item.name }"
53+
:title="item.title"
54+
>
55+
<div>
56+
<component
57+
:is="item.icon"
58+
:class="'h-6 w-6 block ' + item.color"
59+
aria-hidden="true"
60+
/>
61+
</div>
62+
<span
63+
class="transition-opacity opacity-1 duration-300 ml-4 text-base"
64+
:class="{ 'opacity-0': !isHover }"
65+
>{{ item.title }}</span
66+
>
67+
</router-link>
68+
</li>
69+
</ul>
70+
</div>
2571
</div>
2672
</aside>
2773
</template>
@@ -30,35 +76,58 @@
3076
import { defineComponent, ref, watch } from 'vue'
3177
import { useRoute } from 'vue-router'
3278
import navigation from './SidebarNav'
79+
import { BellIcon, MenuIcon, MenuAlt1Icon } from '@heroicons/vue/outline'
80+
import { useDashboardStore } from '../../modules/dashboard/store'
3381
3482
interface MenuItem {
3583
title: string
3684
icon: any
3785
path: string
3886
name: string
87+
color: string
3988
}
4089
4190
export default defineComponent({
4291
name: 'Sidebar',
92+
components: {
93+
BellIcon,
94+
MenuIcon,
95+
MenuAlt1Icon,
96+
},
4397
setup() {
4498
const route = useRoute()
45-
const menuItems = ref<MenuItem[]>(navigation)
99+
const store = useDashboardStore()
100+
const routeItems = ref<MenuItem[]>(navigation)
101+
const menuItems = routeItems.value.sort((a, b) => a.title.localeCompare(b.title))
46102
const isPagesMenuOpen = ref(false)
47103
const isSideMenuOpen = ref(false)
104+
const isHover = ref<boolean>(true)
105+
const isHide = ref<boolean>(false)
106+
107+
watch(isHide, () => {
108+
store.setSideBar(isHide.value)
109+
})
110+
48111
const togglePagesMenu = () => {
49112
isSideMenuOpen.value = !isSideMenuOpen.value
50113
}
114+
51115
const closeSideMenu = () => {
52116
isSideMenuOpen.value = false
53117
}
54-
watch(route, () => {
55-
console.log(route.name)
56-
})
118+
119+
const hoverLeftBar = (b: boolean) => {
120+
if (isHide.value) isHover.value = b
121+
}
122+
57123
return {
58124
isPagesMenuOpen,
125+
isHover,
59126
isSideMenuOpen,
60127
menuItems,
61128
route,
129+
isHide,
130+
hoverLeftBar,
62131
togglePagesMenu,
63132
closeSideMenu,
64133
}

src/layouts/default-layout.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
2-
<div class="h-screen overflow-hidden flex bg-white">
2+
<div class="h-screen overflow-hidden flex bg-slate-100">
33
<sidebar />
4-
<div class="flex flex-col flex-1 w-full">
4+
<div
5+
class="transition-all duration-300 flex flex-col flex-1 w-full"
6+
:class="`${isExpanded ? 'ml-14' : 'ml-64'}`"
7+
>
58
<navigation />
69
<router-view v-slot="{ Component }">
710
<div class="overflow-auto p-4">
@@ -13,14 +16,17 @@
1316
</template>
1417

1518
<script lang="ts">
16-
import { defineComponent } from 'vue'
19+
import { defineComponent, computed } from 'vue'
20+
import { useDashboardStore } from '../modules/dashboard/store'
1721
1822
export default defineComponent({
1923
name: 'Layout',
2024
components: {},
2125
2226
setup() {
23-
return {}
27+
const store = useDashboardStore()
28+
const isExpanded = computed(() => store.isHide)
29+
return { isExpanded }
2430
},
2531
})
2632
</script>

src/modules/dashboard/store/actions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ export const useActions = defineStore('dashboard.actions', () => {
1717
state.welcomeText = value
1818
}
1919

20+
const setSideBar = (value:boolean) => state.isHide = value
21+
2022
return {
2123
showWelcomeText,
2224
setWelcomeText,
25+
setSideBar,
2326
}
2427
})

src/modules/dashboard/store/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const useState = defineStore({
66
state: (): DashboardState => {
77
return {
88
welcomeText: 'Welcome to Dashboard! ...',
9+
isHide: false,
910
}
1011
},
1112
})

src/modules/dashboard/store/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export interface DashboardState {
22
welcomeText: string
3+
isHide?: boolean
34
}

src/router/routes.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import {
2-
HomeIcon,
2+
ViewBoardsIcon,
33
TableIcon,
44
ViewGridIcon,
55
CreditCardIcon,
6-
IdentificationIcon,
7-
MenuAlt1Icon,
8-
AnnotationIcon,
6+
CursorClickIcon,
7+
DocumentTextIcon,
8+
GlobeAltIcon,
9+
BellIcon,
910
} from '@heroicons/vue/outline'
1011

12+
1113
const NotFound = () => import('modules/pages/views/404.vue')
1214
const Dashboard = () => import('modules/dashboard/views/index.vue')
1315
const Table = () => import('modules/table/views/index.vue')
@@ -23,8 +25,9 @@ const routes = [
2325
component: Dashboard,
2426
name: 'Dashboard',
2527
meta: {
26-
title: 'Dashboard',
27-
icon: HomeIcon,
28+
title: 'Dashboards',
29+
icon: ViewBoardsIcon,
30+
color: 'text-left-bar-gray'
2831
},
2932
},
3033
{
@@ -33,7 +36,8 @@ const routes = [
3336
name: 'Button',
3437
meta: {
3538
title: 'Buttons',
36-
icon: MenuAlt1Icon,
39+
icon: CursorClickIcon,
40+
color: 'text-left-bar-orange'
3741
},
3842
},
3943
{
@@ -42,7 +46,8 @@ const routes = [
4246
name: 'Notifications',
4347
meta: {
4448
title: 'Notifications',
45-
icon: AnnotationIcon,
49+
icon: BellIcon,
50+
color: 'text-left-bar-rose'
4651
},
4752
},
4853
{
@@ -52,6 +57,7 @@ const routes = [
5257
meta: {
5358
title: 'Tables',
5459
icon: TableIcon,
60+
color: 'text-left-bar-red'
5561
},
5662
},
5763
{
@@ -61,6 +67,7 @@ const routes = [
6167
meta: {
6268
title: 'Grid',
6369
icon: ViewGridIcon,
70+
color: 'text-left-bar-cyan'
6471
},
6572
},
6673
{
@@ -69,7 +76,8 @@ const routes = [
6976
name: 'Typography',
7077
meta: {
7178
title: 'Typography',
72-
icon: HomeIcon,
79+
icon: DocumentTextIcon,
80+
color: 'text-left-bar-yellow'
7381
},
7482
},
7583
{
@@ -79,6 +87,7 @@ const routes = [
7987
meta: {
8088
title: 'Cards',
8189
icon: CreditCardIcon,
90+
color: 'text-left-bar-indigo'
8291
},
8392
},
8493
{
@@ -87,7 +96,8 @@ const routes = [
8796
name: 'Icons',
8897
meta: {
8998
title: 'Icons',
90-
icon: IdentificationIcon,
99+
icon: GlobeAltIcon,
100+
color: 'text-left-bar-red'
91101
},
92102
},
93103
{

tailwind.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@ module.exports = {
33
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
44
theme: {
55
extend: {
6+
width: {
7+
'15': '3.75rem',
8+
},
69
colors: {
10+
'left-bar-yellow': '#ffd600',
11+
'left-bar-indigo': '#5e72e4',
12+
'left-bar-gray': '#939cac',
13+
'left-bar-red': '#f5365c',
14+
'left-bar-orange': '#fb6340',
15+
'left-bar-cyan': '#22d1f0',
16+
'left-bar-rose': '#f4645f',
717
primary: {
818
DEFAULT: 'rgb(50 50 93)',
919
100: 'rgb(82 95 127)',

0 commit comments

Comments
 (0)