const html = require('choo/html');
const itemClass =
'block px-4 py-2 text-grey-darkest hover:bg-blue hover:text-white cursor-pointer';
module.exports = function(state, emit) {
if (!state.capabilities.account) {
return null;
}
const user = state.user;
const menuItems = [];
if (user.loggedIn) {
menuItems.push(html`
${user.email}`);
menuItems.push(
html`${state.translate(
'logOut'
)}`
);
} else {
menuItems.push(
html`${state.translate(
'signInMenuOption'
)}`
);
}
return html``;
function avatarClick(event) {
event.preventDefault();
const menu = document.getElementById('accountMenu');
menu.classList.toggle('invisible');
menu.focus();
}
function hideMenu(event) {
event.stopPropagation();
const menu = document.getElementById('accountMenu');
menu.classList.add('invisible');
}
function login(event) {
event.preventDefault();
emit('login');
}
function logout(event) {
event.preventDefault();
emit('logout');
}
};