import html from 'choo/html'; import headerImage from '../../dev/images/header.png'; import { I18n } from '../i18n'; import { homeView } from './home'; import { loginView } from './login'; import { searchView } from './search'; export const viewManager = (state, emit) => { const i18n = new I18n(state); // Global I18n class passed to all views // In viewManager all we are doing is checking the app's state // and passing the state and emit to the relevant view. let htmlContent = html`
loading
`; switch (state.params.page) { case 'home': default: { htmlContent = homeView(state, emit, i18n); break; } case 'login': { htmlContent = loginView(state, emit, i18n); break; } case 'search': { htmlContent = searchView(state, emit, i18n); break; } } // Create a wrapper for view content that includes global header/footer let view = html`
${htmlContent}
`; return view; }