2018-10-25 04:07:10 +02:00
|
|
|
const html = require('choo/html');
|
2018-11-12 20:13:31 +01:00
|
|
|
const Component = require('choo/component');
|
|
|
|
const Account = require('./account');
|
2019-02-19 22:13:14 +01:00
|
|
|
const assets = require('../../common/assets');
|
2019-01-24 00:10:09 +01:00
|
|
|
const { platform } = require('../utils');
|
2018-10-25 04:07:10 +02:00
|
|
|
|
2018-11-12 20:13:31 +01: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;
|
|
|
|
}
|
2021-01-27 00:13:56 +01:00
|
|
|
|
2018-11-12 20:13:31 +01:00
|
|
|
createElement() {
|
2022-04-12 15:58:58 +02:00
|
|
|
let assetMap = {};
|
|
|
|
if (this.state.ui !== undefined) assetMap = this.state.ui.assets;
|
|
|
|
else
|
|
|
|
assetMap = {
|
|
|
|
icon:
|
|
|
|
this.state.WEB_UI.CUSTOM_ASSETS.icon !== ''
|
|
|
|
? this.state.WEB_UI.CUSTOM_ASSETS.icon
|
|
|
|
: assets.get('icon.svg'),
|
|
|
|
wordmark:
|
|
|
|
this.state.WEB_UI.CUSTOM_ASSETS.wordmark !== ''
|
|
|
|
? this.state.WEB_UI.CUSTOM_ASSETS.wordmark
|
|
|
|
: assets.get('wordmark.svg') + '#logo'
|
|
|
|
};
|
2019-01-08 22:50:47 +01:00
|
|
|
const title =
|
2019-01-24 00:10:09 +01:00
|
|
|
platform() === 'android'
|
2019-01-08 22:50:47 +01:00
|
|
|
? html`
|
2019-09-09 19:34:55 +02:00
|
|
|
<a class="flex flex-row items-center">
|
2022-04-12 15:58:58 +02:00
|
|
|
<img src="${assetMap.icon}" />
|
2019-09-09 19:34:55 +02:00
|
|
|
<svg class="w-48">
|
2022-04-12 15:58:58 +02:00
|
|
|
<use xlink:href="${assetMap.wordmark}" />
|
2019-09-09 19:34:55 +02:00
|
|
|
</svg>
|
|
|
|
</a>
|
2019-01-08 22:50:47 +01:00
|
|
|
`
|
|
|
|
: html`
|
2019-09-09 19:34:55 +02:00
|
|
|
<a class="flex flex-row items-center" href="/">
|
|
|
|
<img
|
|
|
|
alt="${this.state.translate('title')}"
|
2022-04-12 15:58:58 +02:00
|
|
|
src="${assetMap.icon}"
|
2019-09-09 19:34:55 +02:00
|
|
|
/>
|
2020-07-25 20:22:57 +02:00
|
|
|
<svg viewBox="66 0 340 64" class="w-48 md:w-64">
|
2022-04-12 15:58:58 +02:00
|
|
|
<use xlink:href="${assetMap.wordmark}" />
|
2019-09-09 19:34:55 +02:00
|
|
|
</svg>
|
|
|
|
</a>
|
2019-01-08 22:50:47 +01:00
|
|
|
`;
|
2018-11-12 20:13:31 +01:00
|
|
|
return html`
|
|
|
|
<header
|
2019-05-03 18:26:10 +02: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"
|
2018-11-12 20:13:31 +01:00
|
|
|
>
|
2019-01-08 22:50:47 +01:00
|
|
|
${title} ${this.account.render()}
|
2018-11-12 20:13:31 +01:00
|
|
|
</header>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Header;
|