git ssb

16+

Dominic / patchbay



Tree: c0bb55d9b169c5943cb5dfabbd5a58a241a238af

Files: c0bb55d9b169c5943cb5dfabbd5a58a241a238af / app / html / render.js

776 bytesRaw
1const fs = require('fs')
2const h = require('../h')
3const { Value } = require('mutant')
4const insertCss = require('insert-css')
5
6exports.gives = nest([
7 'app.html.render',
8 'app.mcss.render'
9])
10
11exports.needs = nest({
12 'page.html.render': 'first',
13 styles: 'first'
14})
15
16exports.create = function (api) {
17 return {
18 app,
19 mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
20 }
21
22 function app () {
23 process.nextTick(() => insertCss(api.styles()))
24
25 var view = Value(getView())
26 var screen = h('App', view)
27
28 window.onhashchange = () => view.set(getView())
29 document.body.appendChild(screen)
30
31 return screen
32 }
33
34 function getView () {
35 const view = window.location.hash.substring(1) || 'tabs'
36 return api.page(view)
37 }
38}
39
40

Built with git-ssb-web