2019-09-07 21:54:44 +02:00
|
|
|
import html from 'choo/html';
|
|
|
|
|
2019-09-10 20:41:06 +02:00
|
|
|
import headerImage from '../../dev/images/header.png';
|
|
|
|
|
2019-09-26 00:48:35 +02:00
|
|
|
export const globalView = (state, emit, view) => {
|
|
|
|
const { i18n } = state;
|
2019-10-28 07:01:27 +01:00
|
|
|
if (i18n.needsFetch) {
|
2019-10-28 07:02:19 +01:00
|
|
|
return html`<body><i class="icon-loading animate-spin"></i></body>`;
|
2019-10-28 07:01:27 +01:00
|
|
|
}
|
2019-09-07 21:54:44 +02:00
|
|
|
// Create a wrapper for view content that includes global header/footer
|
2019-09-25 20:32:52 +02:00
|
|
|
return html`<body>
|
2019-09-07 21:54:44 +02:00
|
|
|
<header>
|
|
|
|
<nav>
|
|
|
|
<div class="brand">
|
2019-09-08 21:44:01 +02:00
|
|
|
<a href="/">
|
2019-09-10 20:41:06 +02:00
|
|
|
<span><img src=${headerImage} alt="Readlebee"></span>
|
2019-09-07 21:54:44 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- responsive-->
|
|
|
|
<input id="navMenu" type="checkbox" class="show">
|
2019-09-12 07:44:31 +02:00
|
|
|
<label for="navMenu" class="burger pseudo button">${'\u2261'}</label>
|
2019-09-07 21:54:44 +02:00
|
|
|
|
|
|
|
<div class="menu">
|
2019-10-18 05:10:15 +02:00
|
|
|
<a href="/search" class="pseudo button">
|
|
|
|
<i class="icon-search" aria-labeledBy="searchLabel"></i> <span id="searchLabel">${i18n.__('global.menu_search')}</span>
|
|
|
|
</a>
|
|
|
|
<a href="/about" class="pseudo button">${i18n.__('global.menu_about')}</a>
|
|
|
|
${
|
|
|
|
state.isLoggedIn === true
|
|
|
|
? [
|
2019-12-24 00:37:33 +01:00
|
|
|
html`<a href="/shelves" class="pseudo button">${i18n.__('global.menu_shelves')}</a>`,
|
2019-10-18 05:10:15 +02:00
|
|
|
html`<a href="/account" class="pseudo button">${i18n.__('global.menu_account')}</a>`,
|
|
|
|
html`<a href="/logout" class="pseudo button">${i18n.__('global.menu_logout')}</a>`,
|
|
|
|
]
|
|
|
|
: html`<a href="/login" class="pseudo button">${i18n.__('global.menu_login')}</a>`
|
|
|
|
}
|
2019-09-07 21:54:44 +02:00
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<main class="container">
|
2019-09-25 20:32:52 +02:00
|
|
|
${view(state, emit, i18n)}
|
2019-09-07 21:54:44 +02:00
|
|
|
</main>
|
2019-09-08 22:04:26 +02:00
|
|
|
|
|
|
|
<footer>
|
2019-10-18 06:15:31 +02:00
|
|
|
<nav class="flex one">
|
|
|
|
<div class="two-third-600">
|
|
|
|
<div class="links">
|
|
|
|
<a href="https://gitlab.com/Alamantus/Readlebee" class="pseudo button">
|
|
|
|
${i18n.__('global.footer_repo')}
|
|
|
|
</a>
|
|
|
|
<a href="https://gitter.im/Readlebee/community" class="pseudo button">
|
|
|
|
${i18n.__('global.footer_chat')}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="third-600">
|
|
|
|
<label class="flex">
|
|
|
|
<span class="third">${i18n.__('global.change_language')}:</span>
|
|
|
|
<select class="two-third" onchange=${e => emit('set-language', e.target.value)}>
|
2019-10-28 07:01:27 +01:00
|
|
|
${i18n.availableLanguages.map(language => {
|
2019-10-18 06:15:31 +02:00
|
|
|
return html`<option value=${language.locale} ${state.language === language.locale ? 'selected' : null}>
|
|
|
|
${language.name}
|
|
|
|
</option>`;
|
|
|
|
})}
|
|
|
|
</select>
|
|
|
|
</label>
|
2019-09-08 22:04:26 +02:00
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</footer>
|
2019-09-07 21:54:44 +02:00
|
|
|
</body>`;
|
|
|
|
}
|