chore: Handled help center sidebar in small screen (#5293)

This commit is contained in:
Sivin Varghese
2022-08-18 11:14:06 +05:30
committed by GitHub
parent 8042810e42
commit 45d0d101b1
3 changed files with 57 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
<template> <template>
<div class="header--wrap"> <div class="header--wrap">
<div class="header-left--wrap"> <div class="header-left--wrap">
<woot-sidemenu-icon />
<h3 class="page-title">{{ headerTitle }}</h3> <h3 class="page-title">{{ headerTitle }}</h3>
<span class="text-block-title count-view">{{ `(${count})` }}</span> <span class="text-block-title count-view">{{ `(${count})` }}</span>
</div> </div>
@@ -156,6 +157,10 @@ export default {
.header-left--wrap { .header-left--wrap {
display: flex; display: flex;
align-items: center; align-items: center;
.page-title {
margin-bottom: 0;
}
} }
.header-right--wrap { .header-right--wrap {
display: flex; display: flex;

View File

@@ -8,6 +8,7 @@
/> />
<div v-if="portals.length" class="margin-right-small"> <div v-if="portals.length" class="margin-right-small">
<help-center-sidebar <help-center-sidebar
:class="sidebarClassName"
:header-title="headerTitle" :header-title="headerTitle"
:sub-title="localeName(selectedPortalLocale)" :sub-title="localeName(selectedPortalLocale)"
:accessible-menu-items="accessibleMenuItems" :accessible-menu-items="accessibleMenuItems"
@@ -16,7 +17,7 @@
@open-modal="onClickOpenAddCatogoryModal" @open-modal="onClickOpenAddCatogoryModal"
/> />
</div> </div>
<section class="app-content columns"> <section class="app-content columns" :class="contentClassName">
<router-view /> <router-view />
<command-bar /> <command-bar />
<woot-key-shortcut-modal <woot-key-shortcut-modal
@@ -48,6 +49,7 @@ import { mapGetters } from 'vuex';
import { frontendURL } from '../../../../helper/URLHelper'; import { frontendURL } from '../../../../helper/URLHelper';
import Sidebar from 'dashboard/components/layout/Sidebar'; import Sidebar from 'dashboard/components/layout/Sidebar';
import { BUS_EVENTS } from 'shared/constants/busEvents';
import PortalPopover from '../components/PortalPopover.vue'; import PortalPopover from '../components/PortalPopover.vue';
import HelpCenterSidebar from '../components/Sidebar/Sidebar.vue'; import HelpCenterSidebar from '../components/Sidebar/Sidebar.vue';
import CommandBar from 'dashboard/routes/dashboard/commands/commandbar.vue'; import CommandBar from 'dashboard/routes/dashboard/commands/commandbar.vue';
@@ -69,6 +71,8 @@ export default {
mixins: [portalMixin], mixins: [portalMixin],
data() { data() {
return { return {
isSidebarOpen: false,
isOnDesktop: true,
showShortcutModal: false, showShortcutModal: false,
showNotificationPanel: false, showNotificationPanel: false,
showPortalPopover: false, showPortalPopover: false,
@@ -85,6 +89,24 @@ export default {
meta: 'portals/getMeta', meta: 'portals/getMeta',
isFetching: 'portals/isFetchingPortals', isFetching: 'portals/isFetchingPortals',
}), }),
sidebarClassName() {
if (this.isOnDesktop) {
return '';
}
if (this.isSidebarOpen) {
return 'off-canvas is-open';
}
return 'off-canvas is-transition-push is-closed';
},
contentClassName() {
if (this.isOnDesktop) {
return '';
}
if (this.isSidebarOpen) {
return 'off-canvas-content is-open-left has-transition-push';
}
return 'off-canvas-content has-transition-push';
},
selectedPortalName() { selectedPortalName() {
return this.selectedPortal ? this.selectedPortal.name : ''; return this.selectedPortal ? this.selectedPortal.name : '';
}, },
@@ -177,9 +199,26 @@ export default {
}, },
}, },
mounted() { mounted() {
window.addEventListener('resize', this.handleResize);
this.handleResize();
bus.$on(BUS_EVENTS.TOGGLE_SIDEMENU, this.toggleSidebar);
this.fetchPortalsAndItsCategories(); this.fetchPortalsAndItsCategories();
}, },
beforeDestroy() {
bus.$off(BUS_EVENTS.TOGGLE_SIDEMENU, this.toggleSidebar);
window.removeEventListener('resize', this.handleResize);
},
methods: { methods: {
handleResize() {
if (window.innerWidth > 1200) {
this.isOnDesktop = true;
} else {
this.isOnDesktop = false;
}
},
toggleSidebar() {
this.isSidebarOpen = !this.isSidebarOpen;
},
fetchPortalsAndItsCategories() { fetchPortalsAndItsCategories() {
this.$store.dispatch('portals/index').then(() => { this.$store.dispatch('portals/index').then(() => {
this.$store.dispatch('categories/index', { this.$store.dispatch('categories/index', {

View File

@@ -1,7 +1,10 @@
<template> <template>
<div class="container"> <div class="container">
<div class="header-wrap"> <div class="header-wrap">
<h1 class="page-title">{{ $t('HELP_CENTER.PORTAL.HEADER') }}</h1> <div class="header-left-wrap">
<woot-sidemenu-icon />
<h1 class="page-title">{{ $t('HELP_CENTER.PORTAL.HEADER') }}</h1>
</div>
<woot-button color-scheme="primary" size="small" @click="addPortal"> <woot-button color-scheme="primary" size="small" @click="addPortal">
{{ $t('HELP_CENTER.PORTAL.NEW_BUTTON') }} {{ $t('HELP_CENTER.PORTAL.NEW_BUTTON') }}
</woot-button> </woot-button>
@@ -87,6 +90,14 @@ export default {
align-items: center; align-items: center;
margin: 0 0 var(--space-small) 0; margin: 0 0 var(--space-small) 0;
height: var(--space-larger); height: var(--space-larger);
.header-left-wrap {
display: flex;
align-items: center;
.page-title {
margin-bottom: 0;
}
}
} }
.portal-container { .portal-container {
height: 90vh; height: 90vh;