Skip to content

Commit

Permalink
Merge pull request misterGF#75 from Namoshek/refactor-dash-into-compo…
Browse files Browse the repository at this point in the history
…nents

Refactors common code into own components
  • Loading branch information
misterGF authored Jan 3, 2019
2 parents 9fed7a3 + 5db6754 commit 84c5135
Show file tree
Hide file tree
Showing 16 changed files with 641 additions and 264 deletions.
164 changes: 16 additions & 148 deletions src/components/Dash.vue
Original file line number Diff line number Diff line change
@@ -1,132 +1,12 @@
<template>
<div :class="['wrapper', classes]">
<header class="main-header">
<span class="logo-mini">
<a href="/"><img src="/static/img/copilot-logo-white.svg" alt="Logo" class="img-responsive center-block logo"></a>
</span>
<!-- Header Navbar -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="javascript:;" class="sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
<!-- Navbar Right Menu -->
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- Messages-->
<li class="dropdown messages-menu">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i>
<span class="label label-success">{{ userInfo.messages | count }}</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have {{ userInfo.messages | count }} message(s)</li>
<li v-if="userInfo.messages.length > 0">
<!-- inner menu: contains the messages -->
<ul class="menu">
<li>
<!-- start message -->
<a href="javascript:;">
<!-- Message title and timestamp -->
<h4>
Support Team
<small>
<i class="fa fa-clock-o"></i> 5 mins</small>
</h4>
<!-- The message -->
<p>Why not consider this a test message?</p>
</a>
</li>
<!-- end message -->
</ul>
<!-- /.menu -->
</li>
<li class="footer" v-if="userInfo.messages.length > 0">
<a href="javascript:;">See All Messages</a>
</li>
</ul>
</li>
<!-- /.messages-menu -->

<!-- Notifications Menu -->
<li class="dropdown notifications-menu">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<span class="label label-warning">{{ userInfo.notifications | count }}</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have {{ userInfo.notifications | count }} notification(s)</li>
<li v-if="userInfo.notifications.length > 0">
<!-- Inner Menu: contains the notifications -->
<ul class="menu">
<li>
<!-- start notification -->
<a href="javascript:;">
<i class="fa fa-users text-aqua"></i> 5 new members joined today
</a>
</li>
<!-- end notification -->
</ul>
</li>
<li class="footer" v-if="userInfo.notifications.length > 0">
<a href="javascript:;">View all</a>
</li>
</ul>
</li>

<!-- Tasks Menu -->
<li class="dropdown tasks-menu">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i>
<span class="label label-danger">{{ userInfo.tasks | count }} </span>
</a>
<ul class="dropdown-menu">
<li class="header">You have {{ userInfo.tasks | count }} task(s)</li>
<li v-if="userInfo.tasks.length > 0">
<!-- Inner menu: contains the tasks -->
<ul class="menu">
<li>
<!-- Task item -->
<a href="javascript:;">
<!-- Task title and progress text -->
<h3>
Design some buttons
<small class="pull-right">20%</small>
</h3>
<!-- The progress bar -->
<div class="progress xs">
<!-- Change the css width attribute to simulate progress -->
<div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">20% Complete</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
</ul>
</li>
<li class="footer" v-if="userInfo.tasks.length > 0">
<a href="javascript:;">View all tasks</a>
</li>
</ul>
</li>

<!-- User Account Menu -->
<li class="dropdown user user-menu">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<!-- The user image in the navbar-->
<img v-bind:src="demo.avatar" class="user-image" alt="User Image">
<!-- hidden-xs hides the username on small devices so only the image appears. -->
<span class="hidden-xs">{{ demo.displayName }}</span>
</a>
</li>
</ul>
</div>
</nav>
</header>
<!-- Horizontal bar at top. Contains messages, notifications, tasks and user menu -->
<dash-header :user="user"></dash-header>

<!-- Left side column. contains the logo and sidebar -->
<sidebar :display-name="demo.displayName" :picture-url="demo.avatar" />

<sidebar :user="user" />
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
Expand All @@ -147,56 +27,44 @@
<router-view></router-view>
</div>
<!-- /.content-wrapper -->

<!-- Main Footer -->
<footer class="main-footer">
<strong>Copyright &copy; {{year}}
<a href="javascript:;">CoPilot</a>.</strong> All rights reserved.
</footer>

<!-- Horizontal bar at bottom. Contains copy right -->
<dash-footer></dash-footer>
</div>
<!-- ./wrapper -->
</template>

<script>
import faker from 'faker'
import { mapState } from 'vuex'
import config from '../config'
import Sidebar from './Sidebar'
import DashFooter from './layout/DashFooter'
import DashHeader from './layout/DashHeader'
import Sidebar from './layout/Sidebar'
import 'hideseek'
export default {
name: 'Dash',
components: {
DashFooter,
DashHeader,
Sidebar
},
data: function () {
return {
// section: 'Dash',
year: new Date().getFullYear(),
classes: {
fixed_layout: config.fixedLayout,
hide_logo: config.hideLogoOnMobile
},
error: ''
}
}
},
computed: {
...mapState([
'userInfo'
]),
demo () {
user () {
return {
displayName: faker.name.findName(),
avatar: faker.image.avatar(),
email: faker.internet.email(),
randomCard: faker.helpers.createCard()
roles: [faker.name.jobTitle(), faker.name.jobTitle()]
}
}
},
methods: {
changeloading () {
this.$store.commit('TOGGLE_SEARCHING')
}
}
}
</script>
Expand Down
17 changes: 17 additions & 0 deletions src/components/layout/DashFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<footer class="main-footer">
<strong>Copyright &copy; {{ year }}
<a href="javascript:;">CoPilot</a>.</strong> All rights reserved.
</footer>
</template>

<script>
export default {
name: 'DashFooter',
data: function () {
return {
year: new Date().getFullYear()
}
}
}
</script>
48 changes: 48 additions & 0 deletions src/components/layout/DashHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template>
<header class="main-header">
<span class="logo-mini">
<a href="/"><img src="/static/img/copilot-logo-white.svg" alt="Logo" class="img-responsive center-block logo"></a>
</span>
<!-- Header Navbar -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="javascript:;" class="sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only">Toggle navigation</span>
</a>

<!-- Navbar Right Menu -->
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<messages-menu></messages-menu>
<notifications-menu></notifications-menu>
<tasks-menu></tasks-menu>
<user-menu :user="user"></user-menu>
</ul>
</div>
</nav>
</header>
</template>

<script>
import { mapState } from 'vuex'
import MessagesMenu from './MessagesMenu'
import NotificationsMenu from './NotificationsMenu'
import TasksMenu from './TasksMenu'
import UserMenu from './UserMenu'
export default {
name: 'DashHeader',
components: {
MessagesMenu,
NotificationsMenu,
TasksMenu,
UserMenu
},
props: ['user'],
computed: {
...mapState([
'userInfo'
])
}
}
</script>
28 changes: 28 additions & 0 deletions src/components/layout/MessageItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<li>
<a href="javascript:;">
<h4>
<span>{{message.title}}</span>
<small>
<i class="fa fa-clock-o"></i>
<span>{{message.createdAt}}</span>
</small>
</h4>
<p>{{message.body}}</p>
</a>
</li>
</template>

<script>
export default {
name: 'MessageItem',
props: ['message']
}
</script>

<style scoped>
.navbar-nav > .messages-menu > .dropdown-menu > li .menu > li > a > h4,
.navbar-nav > .messages-menu > .dropdown-menu > li .menu > li > a > p {
margin-left: 0;
}
</style>
40 changes: 40 additions & 0 deletions src/components/layout/MessagesMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<li class="dropdown messages-menu">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i>
<span class="label label-success">{{ userInfo.messages | count }}</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have {{ userInfo.messages | count }} message(s)</li>
<li v-if="userInfo.messages.length > 0">
<!-- inner menu: contains the messages -->
<ul class="menu">
<message-item v-for="message in userInfo.messages"
:key="message.id"
:message="message"></message-item>
</ul>
<!-- /.menu -->
</li>
<li class="footer" v-if="userInfo.messages.length > 0">
<a href="javascript:;">See All Messages</a>
</li>
</ul>
</li>
</template>

<script>
import { mapState } from 'vuex'
import MessageItem from './MessageItem'
export default {
name: 'MessagesMenu',
components: {
MessageItem
},
computed: {
...mapState([
'userInfo'
])
}
}
</script>
56 changes: 56 additions & 0 deletions src/components/layout/NotificationItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<li class="notification-item">
<a href="javascript:;">
<h4>
<span>{{ notification.title }}</span>
<small class="time pull-right">
<i class="fa fa-clock-o"></i>
<span>{{ notification.createdAt }}</span>
</small>
</h4>
<p>{{ notification.body }}</p>
</a>
</li>
</template>

<script>
export default {
props: {
notification: {
type: Object,
required: true
}
}
}
</script>

<style lang="scss" scoped>
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu > li > ul.menu {
li > a > h4,
li > a > p {
margin: 0;
white-space: normal;
word-break: break-word;
}
li > a > h4 {
font-size: 15px;
small {
font-size: 10px;
}
}
li > a > p {
font-size: 12px;
}
li > a > h4 > span {
display: inline-block;
}
li > a > h4 > small.time {
margin-top: 3px;
}
}
</style>
Loading

0 comments on commit 84c5135

Please sign in to comment.