Create new toggle menu component

This commit is contained in:
leigh-mil
2019-11-25 10:33:25 -05:00
parent 9131fc7849
commit f4922f0db2
3 changed files with 93 additions and 71 deletions

View File

@@ -0,0 +1,25 @@
import ToggleMixin from '../mixins/toggle'
export default {
name: 'toggleMenu',
mixins: [ToggleMixin],
methods: {
toggle: function(e) {
if (this.$el.contains(e.target)) {
this.isVisible = !this.isVisible
} else {
this.isVisible = false
}
},
},
mounted: function() {
document.addEventListener('click', this.toggle)
},
beforeDestroy: function() {
document.removeEventListener('click', this.toggle)
},
}

View File

@@ -30,6 +30,7 @@ import ToForm from './components/forms/to_form'
import ClinFields from './components/clin_fields'
import PopDateRange from './components/pop_date_range'
import Accordion from './components/accordion'
import ToggleMenu from './components/toggle_menu'
Vue.config.productionTip = false
@@ -61,6 +62,7 @@ const app = new Vue({
ToForm,
ClinFields,
PopDateRange,
ToggleMenu,
},
mounted: function() {