import styles from './_styles.scss'; // universal zap component styles
import parse from 'url-parse';
import buttonData from './link-data.json';
import ZapDropDown from '../zap-dropdown/index.js';
import brandLogos from './logos.json';
class ZapHeader extends HTMLElement {
connectedCallback() {
const url = parse(window.location.toString(), true);
const self = this;
fetch(url).then(function(response) {
return response.json();
}).then(function(json) {
self.data = json;
self.data.agentBox = require('./agentbox.html')(self.data);
const html = require('./index.html')(self.data);
self.innerHTML = html;
self.dropDownSetup();
self.hamburgerHelper();
self.agentInfoDisplay();
});
}
dropDownSetup() {
const dropdowns = document.querySelectorAll('.menu-container zap-dropdown');
const self = this;
dropdowns.forEach(function(menu,i) {
menu.data = self.data.buttons[i];
})
}
hamburgerHelper() {
const hamburger = document.querySelector('.hamburger-container');
hamburger.addEventListener('click',function(e) {
e.preventDefault();
const menuC = document.querySelector('.menu-container');
if(menuC.style.left !== '0px') {
document.querySelector('.agent-profile').style.display = 'block';
menuC.style.left = '0px';
} else {
menuC.style.left = '-100%';
setTimeout(function() {
document.querySelector('.agent-profile').style.display = 'none';
},300)
}
})
}
agentInfoDisplay() {
const agentLink = document.querySelector('.agent-link');
if(agentLink) {
const agentContainer = document.querySelector('.agent-container');
agentContainer.addEventListener('mouseenter',function(e) {
agentContainer.querySelector('.agent-profile').style.display = 'block';
})
agentContainer.addEventListener('mouseleave',function(e) {
agentContainer.querySelector('.agent-profile').style.display = 'none';
})
}
}
}
window.customElements.define('zap-header', ZapHeader)
New project setup from scratch through deploying staging and production environments including Lambda's, API Gateway, dynamoDb using arc.codes for both an HTML and JSON endpoint
This yaml file is the configuration to create the html and json endpoints below accessible via API Gateway with sessions recorded in dynamoDB
@app
zap-lambda-helloWorld
@html
get /
@json
get /api