Add Menu and Navigation

This commit is contained in:
2018-02-12 19:48:25 +00:00
parent 5f05b29d0b
commit 285305af67
16 changed files with 453 additions and 43 deletions

31
js/nav.js Normal file
View File

@@ -0,0 +1,31 @@
const CLS = {
open: 'Nav--open',
};
export default class Nav {
constructor(cfg) {
this.el = cfg.el;
this.menu = cfg.menu;
this.attachEvents();
}
attachEvents() {
this.menu.el.addEventListener('click', () => {
this.menu.hideMenu();
this.openNav();
});
this.el.querySelector('.Nav-close').addEventListener('click', () => {
this.menu.showMenu();
this.closeNav();
});
}
openNav() {
this.el.classList.add(CLS.open);
}
closeNav() {
this.el.classList.remove(CLS.open);
}
}