Commit 798364845d2d6269f19671d5e283dea786a1d408
add nav buttons for feed, private, profile
Matt McKegg committed on 10/27/2016, 2:15:29 PMParent: 10773220511573c2fa137507eb04e742a2a47fbe
Files changed
main-window.js | changed |
main-window.js | ||
---|---|---|
@@ -38,9 +38,12 @@ | ||
38 | 38 | } |
39 | 39 | }) |
40 | 40 | |
41 | 41 | window.onhashchange = function (ev) { |
42 | - setView(window.location.hash.substring(1)) | |
42 | + var path = window.location.hash.substring(1) | |
43 | + if (path) { | |
44 | + setView(path) | |
45 | + } | |
43 | 46 | } |
44 | 47 | |
45 | 48 | var mainElement = h('div.main', [ |
46 | 49 | rootElement |
@@ -59,9 +62,31 @@ | ||
59 | 62 | 'ev-click': goForward, |
60 | 63 | classList: [ when(canGoForward, '-active') ] |
61 | 64 | }, '>') |
62 | 65 | ]), |
63 | - h('span.appTitle', ['Patchwork']) | |
66 | + h('span.nav', [ | |
67 | + h('a', { | |
68 | + href: '#/public', | |
69 | + classList: [ | |
70 | + when(selected('/public'), '-selected') | |
71 | + ] | |
72 | + }, 'Feed'), | |
73 | + h('a', { | |
74 | + href: '#/private', | |
75 | + classList: [ | |
76 | + when(selected('/private'), '-selected') | |
77 | + ] | |
78 | + }, 'Private') | |
79 | + ]), | |
80 | + h('span.appTitle', ['Patchwork']), | |
81 | + h('span.nav', [ | |
82 | + h('a', { | |
83 | + href: `#${ssbClient.id}`, | |
84 | + classList: [ | |
85 | + when(selected(`${ssbClient.id}`), '-selected') | |
86 | + ] | |
87 | + }, 'Profile') | |
88 | + ]) | |
64 | 89 | ]), |
65 | 90 | mainElement |
66 | 91 | ]) |
67 | 92 | |
@@ -99,8 +124,14 @@ | ||
99 | 124 | currentView.set(newView) |
100 | 125 | currentView().scrollTop = 0 |
101 | 126 | } |
102 | 127 | } |
128 | + | |
129 | + function selected (view) { | |
130 | + return computed([currentView, view], (currentView, view) => { | |
131 | + return currentView && currentView[0] === view | |
132 | + }) | |
133 | + } | |
103 | 134 | } |
104 | 135 | |
105 | 136 | function isSame (a, b) { |
106 | 137 | if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) { |
Built with git-ssb-web