Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ramsaylanier/8b89c53bc0a6729b1c4e82feb7518d3e to your computer and use it in GitHub Desktop.
Save ramsaylanier/8b89c53bc0a6729b1c4e82feb7518d3e to your computer and use it in GitHub Desktop.
<template>
<button :class="[open ? $style.active : '', $style.button]" @click="handleClick">
<component :is="icon"/>
</button>
</template>
<script>
export default {
name: 'sidebar-toggle',
props: ['sidebarComponent', 'icon'],
computed: {
open () {
return this.$store.state.ui.sidebarOpen && this.$store.state.ui.sidebarComponent === this.sidebarComponent
}
},
methods: {
handleClick () {
this.$store.dispatch('toggleSidebar', {component: this.sidebarComponent})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment