forked from vuestorefront/vue-storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vuestorefront#44] Use vuex ui-store instead of global events from ev…
…ent-bus in UI interactionse
- Loading branch information
Showing
11 changed files
with
113 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
<template> | ||
<div class="hamburger-icon"> | ||
<div class="hamburger-icon" @click="toggleSidebarMenu"> | ||
Core Hamburger | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapState } from 'vuex' | ||
export default { | ||
name: 'hamburger-icon' | ||
name: 'hamburger-icon', | ||
computed: mapState({ | ||
isOpen: state => state.ui.sidebar | ||
}), | ||
methods: { | ||
toggleSidebarMenu () { | ||
this.$store.commit('setSidebar', !this.isOpen) | ||
} | ||
} | ||
} | ||
</script> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,40 @@ | ||
<template> | ||
<div class="sidebar-menu"> | ||
Core Sidebar Menu | ||
<div class="sidebar-menu" :class="{ active: isOpen }"> | ||
<ul> | ||
<li @click="closeMenu" v-for='category in categories'> | ||
<router-link v-if='category.product_count >0 || category.children_data.length>0' :to="{ name: 'category', params: { id: category.id, slug: category.slug }}">{{ category.name }}</router-link> | ||
<ul v-if="category.children_data"> | ||
<li @click="closeMenu" v-for='subcat in category.children_data' style="display: none"> | ||
<router-link :to="{ name: 'category', params: { id: subcat.id, slug: subcat.slug }}">{{ subcat.name }}</router-link> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapState } from 'vuex' | ||
export default { | ||
name: 'sidebar-menu' | ||
name: 'sidebar-menu', | ||
computed: { | ||
categories () { | ||
return this.$store.state.category.list.filter((op) => { | ||
return op.level === 2 // display only the root level (level =1 => Default Category) | ||
}) | ||
}, | ||
...mapState({ | ||
isOpen: state => state.ui.sidebar | ||
}) | ||
}, | ||
created () { | ||
this.$store.dispatch('category/list', {}) | ||
}, | ||
methods: { | ||
closeMenu () { | ||
this.$store.commit('setSidebar', false) | ||
} | ||
} | ||
} | ||
</script> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default { | ||
// TO-DO: Make ui-stores inheritance in themes from default ui-store like pages/components | ||
state: { | ||
sidebar: false, | ||
microcart: false, | ||
overlay: false | ||
}, | ||
getters: { | ||
ui (state) { | ||
return { | ||
sidebar: state.sidebar, | ||
microcart: state.microcart, | ||
overlay: state.overlay | ||
} | ||
} | ||
}, | ||
mutations: { | ||
setOverlay (state, action) { | ||
state.overlay = action === true | ||
}, | ||
setMicrocart (state, action) { | ||
state.microcart = action === true | ||
}, | ||
setSidebar (state, action) { | ||
state.sidebar = action === true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/themes/default/components/core/blocks/Header/MicrocartIcon.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters