drop.chapril.org-firefoxsend/app/templates/userAccount/index.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-07-31 20:09:18 +02:00
const html = require('choo/html');
const assets = require('../../../common/assets');
// eslint-disable-next-line no-unused-vars
module.exports = function(state) {
2018-08-03 21:24:41 +02:00
const notLoggedInMenu = html`
<ul class="account_dropdown"
tabindex="-1"
>
<li>
<a class=account_dropdown__link>${state.translate(
'accountMenuOption'
)}</a>
</li>
<li>
<a href="/signin"
class=account_dropdown__link>${state.translate(
'signInMenuOption'
)}</a>
</li>
</ul>
`;
2018-07-31 20:09:18 +02:00
return html`
<div class="account">
<img
src="${assets.get('user.svg')}"
2018-08-03 21:24:41 +02:00
onclick=${avatarClick}
2018-07-31 20:09:18 +02:00
alt="account"/>
2018-08-03 21:24:41 +02:00
${notLoggedInMenu}
2018-07-31 20:09:18 +02:00
</div>`;
2018-08-03 21:24:41 +02:00
function avatarClick(event) {
2018-07-31 20:09:18 +02:00
event.preventDefault();
const dropdown = document.querySelector('.account_dropdown');
dropdown.classList.toggle('visible');
2018-08-03 21:24:41 +02:00
dropdown.focus();
}
//the onblur trick makes links unclickable wtf
/*
function hideMenu(event) {
event.stopPropagation();
const dropdown = document.querySelector('.account_dropdown');
dropdown.classList.remove('visible');
2018-07-31 20:09:18 +02:00
}
2018-08-03 21:24:41 +02:00
*/
2018-07-31 20:09:18 +02:00
};