Skip to content

Commit

Permalink
Close sidebar when dropdown toggle below 992px width
Browse files Browse the repository at this point in the history
  • Loading branch information
jericopulvera committed Aug 5, 2017
1 parent b78a006 commit 7eed832
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/layout/navbar/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<div class="offset-lg-8"></div>
<div class="col nav-item dropdown navbar-dropdown d-flex align-items-center justify-content-center" v-dropdown>
<a class="nav-link dropdown-toggle d-flex align-items-center justify-content" href="#">
<a class="nav-link dropdown-toggle d-flex align-items-center justify-content" href="#" @click.prevent="toggleDropdown">
<span class="i-nav-messages notify"></span>
</a>
<div class="dropdown-menu">
Expand All @@ -36,7 +36,7 @@
</div>
</div>
<div class="col nav-item dropdown navbar-dropdown d-flex align-items-center justify-content-center" v-dropdown>
<a class="nav-link dropdown-toggle d-flex align-items-center justify-content" href="#">
<a class="nav-link dropdown-toggle d-flex align-items-center justify-content" href="#" @click.prevent="toggleDropdown">
<span class="i-nav-notification notify"></span>
</a>
<div class="dropdown-menu">
Expand All @@ -55,7 +55,7 @@
</div>
</div>
<div class="col nav-item dropdown navbar-dropdown d-flex align-items-center justify-content-center" v-dropdown>
<a class="nav-link dropdown-toggle d-flex align-items-center justify-content" href="#">
<a class="nav-link dropdown-toggle d-flex align-items-center justify-content" href="#" @click.prevent="toggleDropdown">
<span class="avatar-container">
<img src="http://i.imgur.com/UTc7Fne.png" />
</span>
Expand Down Expand Up @@ -91,6 +91,7 @@
methods: {
...mapActions([
'toggleSidebar',
'toggleDropdown',
'isToggleWithoutAnimation'
])
}
Expand Down
8 changes: 8 additions & 0 deletions src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const mutations = {
[types.TOGGLE_SIDEBAR] (state, opened) {
state.sidebar.opened = opened
},
[types.TOGGLE_DROPDOWN] (state) {
if (document.documentElement.clientWidth < 992) {
state.sidebar.opened = false
}
},
[types.TOGGLE_WITHOUT_ANIMATION] (state, value) {
state.sidebar.withoutAnimation = value
},
Expand All @@ -42,6 +47,9 @@ const actions = {
toggleSidebar ({ commit }, opened) {
commit(types.TOGGLE_SIDEBAR, opened)
},
toggleDropdown ({ commit }) {
commit(types.TOGGLE_DROPDOWN)
},
isToggleWithoutAnimation ({ commit }, value) {
commit(types.TOGGLE_WITHOUT_ANIMATION, value)
}
Expand Down
2 changes: 2 additions & 0 deletions src/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export const TOGGLE_EXPAND_MENU_ITEM = 'TOGGLE_EXPAND_MENU_ITEM'

export const TOGGLE_SIDEBAR = 'TOGGLE_SIDEBAR'

export const TOGGLE_DROPDOWN = 'TOGGLE_DROPDOWN'

export const TOGGLE_WITHOUT_ANIMATION = 'TOGGLE_WITHOUT_ANIMATION'

0 comments on commit 7eed832

Please sign in to comment.