header.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const html = require('choo/html');
  2. const Component = require('choo/component');
  3. const Account = require('./account');
  4. const assets = require('../../common/assets');
  5. const { platform } = require('../utils');
  6. class Header extends Component {
  7. constructor(name, state, emit) {
  8. super(name);
  9. this.state = state;
  10. this.emit = emit;
  11. this.account = state.cache(Account, 'account');
  12. }
  13. update() {
  14. this.account.render();
  15. return false;
  16. }
  17. createElement() {
  18. const title =
  19. platform() === 'android'
  20. ? html`
  21. <a class="flex flex-row items-center">
  22. <img src="${assets.get('icon.svg')}" />
  23. <svg class="w-48">
  24. <use xlink:href="${assets.get('wordmark.svg')}#logo" />
  25. </svg>
  26. </a>
  27. `
  28. : html`
  29. <a class="flex flex-row items-center" href="/">
  30. <img
  31. alt="${this.state.translate('title')}"
  32. src="${assets.get('icon.svg')}"
  33. />
  34. <svg class="w-48 md:w-64">
  35. <use xlink:href="${assets.get('wordmark.svg')}#logo" />
  36. </svg>
  37. </a>
  38. `;
  39. return html`
  40. <header
  41. 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"
  42. >
  43. ${title} ${this.account.render()}
  44. </header>
  45. `;
  46. }
  47. }
  48. module.exports = Header;