Add Jest tests

Automate CSS and JS Banners
Remove image fading for now
Reference docker-compose.yml restored
This commit is contained in:
2018-04-27 18:22:18 +01:00
parent 8492b7cf3d
commit 33ddd5f966
23 changed files with 3919 additions and 1032 deletions

49
js/navigation.js Normal file
View File

@@ -0,0 +1,49 @@
const STATES = {
open: 'is-open',
};
export default class Navigation {
constructor(cfg = {}) {
if (!cfg.container) return false;
if (!cfg.menu) return false;
this.state = 'hidden';
this.container = cfg.container;
this.menu = cfg.menu;
}
init() {
this.container.setAttribute('aria-hidden', true);
this.container.querySelector('.Nav-list').setAttribute('role', 'menubar');
this.container.querySelectorAll('.Nav-listItem').forEach((item) => {
// Override implied listitem role
item.setAttribute('role', 'none');
});
this.container.querySelectorAll('.Nav-link').forEach((link) => {
link.setAttribute('role', 'menuitem');
});
this.attachEvents();
}
attachEvents() {
this.menu.container.addEventListener('click', () => {
this.openNav();
});
this.container.querySelector('.Nav-close').addEventListener('click', () => {
this.closeNav();
});
}
openNav() {
this.state = 'visible';
this.menu.hideMenu();
this.container.classList.add(STATES.open);
this.container.setAttribute('aria-hidden', false);
}
closeNav() {
this.state = 'hidden';
this.menu.showMenu();
this.container.classList.remove(STATES.open);
this.container.setAttribute('aria-hidden', true);
}
}