fox-send/app/ui/header.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-10-25 02:07:10 +00:00
const html = require('choo/html');
const Component = require('choo/component');
const Account = require('./account');
2019-02-19 21:13:14 +00:00
const assets = require('../../common/assets');
2019-01-23 23:10:09 +00:00
const { platform } = require('../utils');
2018-10-25 02:07:10 +00:00
class Header extends Component {
constructor(name, state, emit) {
super(name);
this.state = state;
this.emit = emit;
this.account = state.cache(Account, 'account');
}
update() {
this.account.render();
return false;
}
createElement() {
const title =
2019-01-23 23:10:09 +00:00
platform() === 'android'
? html`
2019-09-09 17:34:55 +00:00
<a class="flex flex-row items-center">
<img src="${assets.get('icon.svg')}" />
<svg class="w-48">
<use xlink:href="${assets.get('wordmark.svg')}#logo" />
</svg>
</a>
`
: html`
2019-09-09 17:34:55 +00:00
<a class="flex flex-row items-center" href="/">
<img
alt="${this.state.translate('title')}"
src="${assets.get('icon.svg')}"
/>
2020-07-25 18:22:57 +00:00
<svg viewBox="66 0 340 64" class="w-48 md:w-64">
2019-09-09 17:34:55 +00:00
<use xlink:href="${assets.get('wordmark.svg')}#logo" />
</svg>
</a>
`;
return html`
<header
2019-05-03 16:26:10 +00:00
class="main-header relative flex-none flex flex-row items-center justify-between w-full px-6 md:px-8 h-16 md:h-24 z-20 bg-transparent"
>
${title} ${this.account.render()}
</header>
`;
}
}
module.exports = Header;