[Enhancement] Hide sidebar on tablets (#358)
* [Enhancement] Hide sidebar on tablets * Remove unnecessary console.log * Use beforeDestroy
This commit is contained in:
parent
2b41e91768
commit
febc4bef83
12 changed files with 136 additions and 38 deletions
|
@ -456,12 +456,12 @@ $meter-fill-bad: $alert-color;
|
||||||
// --------------
|
// --------------
|
||||||
|
|
||||||
$offcanvas-sizes: (
|
$offcanvas-sizes: (
|
||||||
small: 250px,
|
small: 23rem,
|
||||||
medium: 350px,
|
medium: 23rem,
|
||||||
);
|
);
|
||||||
$offcanvas-vertical-sizes: (
|
$offcanvas-vertical-sizes: (
|
||||||
small: 250px,
|
small: 23rem,
|
||||||
medium: 350px,
|
medium: 23rem,
|
||||||
);
|
);
|
||||||
$offcanvas-background: $light-gray;
|
$offcanvas-background: $light-gray;
|
||||||
$offcanvas-shadow: 0 0 10px rgba($black, 0.7);
|
$offcanvas-shadow: 0 0 10px rgba($black, 0.7);
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
@include flex;
|
@include flex;
|
||||||
@include flex-align($x: center, $y: middle);
|
@include flex-align($x: center, $y: middle);
|
||||||
@include margin($zero);
|
@include margin($zero);
|
||||||
> span {
|
|
||||||
@include padding($zero $space-small $zero $space-small);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,14 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.chat-list__top {
|
.chat-list__top {
|
||||||
|
@include flex;
|
||||||
@include padding($space-normal $zero $space-small $zero);
|
@include padding($space-normal $zero $space-small $zero);
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
.page-title {
|
.page-title {
|
||||||
float: left;
|
@include flex;
|
||||||
margin-bottom: $zero;
|
margin-bottom: $zero;
|
||||||
margin-left: $space-normal;
|
margin-left: $space-normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,3 +126,22 @@
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hamburger--menu {
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
margin-right: $space-normal;
|
||||||
|
|
||||||
|
@media screen and (max-width: 1200px){
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header--icon {
|
||||||
|
display: block;
|
||||||
|
margin-right: $space-normal;
|
||||||
|
|
||||||
|
@media screen and (max-width: 1200px){
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<div class="conversations-sidebar medium-4 columns">
|
<div class="conversations-sidebar medium-4 columns">
|
||||||
<div class="chat-list__top">
|
<div class="chat-list__top">
|
||||||
<h1 class="page-title">
|
<h1 class="page-title">
|
||||||
|
<woot-sidemenu-icon></woot-sidemenu-icon>
|
||||||
{{ getInboxName }}
|
{{ getInboxName }}
|
||||||
</h1>
|
</h1>
|
||||||
<chat-filter @statusFilterChange="getDataForStatusTab"></chat-filter>
|
<chat-filter @statusFilterChange="getDataForStatusTab"></chat-filter>
|
||||||
|
|
14
app/javascript/dashboard/components/SidemenuIcon.vue
Normal file
14
app/javascript/dashboard/components/SidemenuIcon.vue
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<template>
|
||||||
|
<i class="ion-android-menu hamburger--menu" @click="onMenuItemClick"></i>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/* global bus */
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
onMenuItemClick() {
|
||||||
|
bus.$emit('sidemenu_icon_click');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -7,6 +7,7 @@ import LoadingState from './widgets/LoadingState';
|
||||||
import Modal from './Modal';
|
import Modal from './Modal';
|
||||||
import ModalHeader from './ModalHeader';
|
import ModalHeader from './ModalHeader';
|
||||||
import ReportStatsCard from './widgets/ReportStatsCard';
|
import ReportStatsCard from './widgets/ReportStatsCard';
|
||||||
|
import SidemenuIcon from './SidemenuIcon';
|
||||||
import Spinner from './Spinner';
|
import Spinner from './Spinner';
|
||||||
import SubmitButton from './buttons/FormSubmitButton';
|
import SubmitButton from './buttons/FormSubmitButton';
|
||||||
import Tabs from './ui/Tabs/Tabs';
|
import Tabs from './ui/Tabs/Tabs';
|
||||||
|
@ -19,6 +20,7 @@ const WootUIKit = {
|
||||||
Modal,
|
Modal,
|
||||||
ModalHeader,
|
ModalHeader,
|
||||||
ReportStatsCard,
|
ReportStatsCard,
|
||||||
|
SidemenuIcon,
|
||||||
Spinner,
|
Spinner,
|
||||||
SubmitButton,
|
SubmitButton,
|
||||||
Tabs,
|
Tabs,
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { mount } from '@vue/test-utils';
|
||||||
|
import SidemenuIcon from '../SidemenuIcon';
|
||||||
|
|
||||||
|
describe('SidemenuIcon', () => {
|
||||||
|
test('matches snapshot', () => {
|
||||||
|
const wrapper = mount(SidemenuIcon);
|
||||||
|
expect(wrapper.isVueInstance()).toBeTruthy();
|
||||||
|
expect(wrapper.element).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,7 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`SidemenuIcon matches snapshot 1`] = `
|
||||||
|
<i
|
||||||
|
class="ion-android-menu hamburger--menu"
|
||||||
|
/>
|
||||||
|
`;
|
|
@ -1,27 +1,72 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="row app-wrapper">
|
<div class="row app-wrapper">
|
||||||
<sidebar :route="currentRoute"></sidebar>
|
<sidebar :route="currentRoute" :class="sidebarClassName"></sidebar>
|
||||||
|
<section class="app-content columns" :class="contentClassName">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/* eslint no-console: 0 */
|
/* global bus */
|
||||||
import Sidebar from '../../components/layout/Sidebar';
|
import Sidebar from '../../components/layout/Sidebar';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
Sidebar,
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
mainViewComponent: String,
|
mainViewComponent: String,
|
||||||
sidebarMenu: String,
|
sidebarMenu: String,
|
||||||
page: String,
|
page: String,
|
||||||
},
|
},
|
||||||
components: {
|
data() {
|
||||||
Sidebar,
|
return {
|
||||||
|
isSidebarOpen: false,
|
||||||
|
isOnDesktop: true,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentRoute() {
|
currentRoute() {
|
||||||
return ' ';
|
return ' ';
|
||||||
},
|
},
|
||||||
|
sidebarClassName() {
|
||||||
|
if (this.isOnDesktop) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (this.isSidebarOpen) {
|
||||||
|
return 'off-canvas is-open ';
|
||||||
|
}
|
||||||
|
return 'off-canvas position-left is-transition-push is-closed';
|
||||||
|
},
|
||||||
|
contentClassName() {
|
||||||
|
if (this.isOnDesktop) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (this.isSidebarOpen) {
|
||||||
|
return 'off-canvas-content is-open-left has-transition-push has-position-left';
|
||||||
|
}
|
||||||
|
return 'off-canvas-content';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
window.addEventListener('resize', this.handleResize);
|
||||||
|
this.handleResize();
|
||||||
|
bus.$on('sidemenu_icon_click', () => {
|
||||||
|
this.isSidebarOpen = !this.isSidebarOpen;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('resize', this.handleResize);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleResize() {
|
||||||
|
if (window.innerWidth > 1200) {
|
||||||
|
this.isOnDesktop = true;
|
||||||
|
} else {
|
||||||
|
this.isOnDesktop = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="settings-header">
|
<div class="settings-header">
|
||||||
<h1 class="page-title">
|
<h1 class="page-title">
|
||||||
|
<woot-sidemenu-icon></woot-sidemenu-icon>
|
||||||
<back-button v-if="!showButton"></back-button>
|
<back-button v-if="!showButton"></back-button>
|
||||||
<i :class="icon"></i>
|
<i :class="iconClass"></i>
|
||||||
<span>{{ headerTitle }}</span>
|
<span>{{ headerTitle }}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<router-link
|
<router-link
|
||||||
|
@ -39,7 +40,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
iconClass() {
|
iconClass() {
|
||||||
return `icon ${this.props.icon}`;
|
return `icon ${this.icon} header--icon`;
|
||||||
},
|
},
|
||||||
currentRole() {
|
currentRole() {
|
||||||
const { role } = Auth.getCurrentUser();
|
const { role } = Auth.getCurrentUser();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<template>
|
<template>
|
||||||
<section class="app-content columns">
|
|
||||||
<div class="view-box columns bg-light">
|
<div class="view-box columns bg-light">
|
||||||
<settings-header
|
<settings-header
|
||||||
button-route="new"
|
button-route="new"
|
||||||
|
@ -9,13 +8,10 @@
|
||||||
:show-button="showButton()"
|
:show-button="showButton()"
|
||||||
:show-new-button="showNewButton()"
|
:show-new-button="showNewButton()"
|
||||||
/>
|
/>
|
||||||
<!-- <transition name="slide-fade"> -->
|
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<!-- </transition> -->
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -23,9 +19,8 @@
|
||||||
import SettingsHeader from './SettingsHeader';
|
import SettingsHeader from './SettingsHeader';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
components: {
|
||||||
return {
|
SettingsHeader,
|
||||||
};
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
headerTitle: String,
|
headerTitle: String,
|
||||||
|
@ -33,8 +28,8 @@ export default {
|
||||||
icon: String,
|
icon: String,
|
||||||
newButtonRoutes: Array,
|
newButtonRoutes: Array,
|
||||||
},
|
},
|
||||||
components: {
|
data() {
|
||||||
SettingsHeader,
|
return {};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentPage() {
|
currentPage() {
|
||||||
|
@ -44,7 +39,9 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
showButton() {
|
showButton() {
|
||||||
/* eslint-disable no-unneeded-ternary */
|
/* eslint-disable no-unneeded-ternary */
|
||||||
return this.newButtonRoutes ? this.newButtonRoutes.indexOf(this.currentPage) > -1 : true;
|
return this.newButtonRoutes
|
||||||
|
? this.newButtonRoutes.indexOf(this.currentPage) > -1
|
||||||
|
: true;
|
||||||
},
|
},
|
||||||
showNewButton() {
|
showNewButton() {
|
||||||
return this.newButtonRoutes ? true : false;
|
return this.newButtonRoutes ? true : false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue