You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
852 B
22 lines
852 B
3 years ago
|
import {AppModel, TopAppModelImpl} from 'app/client/models/AppModel';
|
||
|
import {setUpErrorHandling} from 'app/client/models/errors';
|
||
|
import {buildSnackbarDom} from 'app/client/ui/NotifyUI';
|
||
|
import {addViewportTag} from 'app/client/ui/viewport';
|
||
|
import {attachCssRootVars} from 'app/client/ui2018/cssVars';
|
||
|
import {dom, DomContents} from 'grainjs';
|
||
|
|
||
|
/**
|
||
|
* Sets up error handling and global styles, and replaces the DOM body with
|
||
|
* the result of calling `buildPage`.
|
||
|
*/
|
||
|
export function setupPage(buildPage: (appModel: AppModel) => DomContents) {
|
||
|
setUpErrorHandling();
|
||
|
const topAppModel = TopAppModelImpl.create(null, {});
|
||
|
attachCssRootVars(topAppModel.productFlavor);
|
||
|
addViewportTag();
|
||
|
dom.update(document.body, dom.maybe(topAppModel.appObs, (appModel) => [
|
||
|
buildPage(appModel),
|
||
|
buildSnackbarDom(appModel.notifier, appModel),
|
||
|
]));
|
||
|
}
|