git ssb

16+

Dominic / patchbay



Tree: c38e965ff14b9067041ae577f0d73337d043aebf

Files: c38e965ff14b9067041ae577f0d73337d043aebf / app / html / tabs.js

937 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const Tabs = require('hypertabs')
4
5exports.gives = nest({
6 app: {
7 'html.tabs': true
8 }
9})
10
11exports.needs = nest({
12 'app.html': {
13 menu: 'first',
14 page: 'first',
15 searchBar: 'first'
16 },
17 'app.sync.addPage': 'first'
18})
19
20exports.create = function (api) {
21 var _tabs
22
23 function tabs (initialTabs = []) {
24 if (_tabs) return _tabs
25
26 const search = api.app.html.searchBar()
27 const menu = api.app.html.menu()
28 const onSelect = (indexes) => {
29 search.input.value = _tabs.get(indexes[0]).content.id
30 }
31 _tabs = Tabs(onSelect, {
32 append: h('div.navExtra', [ search, menu ])
33 })
34 _tabs.getCurrent = () => _tabs.get(_tabs.selected[0])
35
36 // # TODO: review - this works but is strange
37 initialTabs.forEach(p => api.app.sync.addPage(p))
38 _tabs.select(0)
39 return _tabs
40 }
41
42 return nest({
43 'app.html.tabs': tabs
44 })
45}
46
47

Built with git-ssb-web