git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 798364845d2d6269f19671d5e283dea786a1d408

add nav buttons for feed, private, profile

Matt McKegg committed on 10/27/2016, 2:15:29 PM
Parent: 10773220511573c2fa137507eb04e742a2a47fbe

Files changed

main-window.jschanged
main-window.jsView
@@ -38,9 +38,12 @@
3838 }
3939 })
4040
4141 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+ }
4346 }
4447
4548 var mainElement = h('div.main', [
4649 rootElement
@@ -59,9 +62,31 @@
5962 'ev-click': goForward,
6063 classList: [ when(canGoForward, '-active') ]
6164 }, '>')
6265 ]),
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+ ])
6489 ]),
6590 mainElement
6691 ])
6792
@@ -99,8 +124,14 @@
99124 currentView.set(newView)
100125 currentView().scrollTop = 0
101126 }
102127 }
128+
129+ function selected (view) {
130+ return computed([currentView, view], (currentView, view) => {
131+ return currentView && currentView[0] === view
132+ })
133+ }
103134 }
104135
105136 function isSame (a, b) {
106137 if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {

Built with git-ssb-web