git ssb

2+

mixmix / ticktack



Commit 0d85d682b95d0df9f77c9c798d1070cca80470e3

style filter bar a little

mix irving committed on 6/2/2018, 12:01:19 PM
Parent: 5831f345af34aebcc413b1b452dadcbf6244b419

Files changed

app/html/topNav/topNavBlog.jschanged
app/html/topNav/topNavBlog.mcsschanged
app/page/blogIndex.jschanged
app/page/blogIndex.mcsschanged
app/html/topNav/topNavBlog.jsView
@@ -14,30 +14,9 @@
1414 const goTo = (loc) => () => api.history.sync.push(loc)
1515
1616 if (!['blogIndex', 'blogSearch'].includes(location.page)) return
1717
18- const activeFilter = location.hasOwnProperty('filter') ? location.filter : "All"
19-
20- var filters = () => {
21- return h('Filters', [
22- h('span -filter', {
23- className: 'All' === activeFilter ? '-active' : '',
24- 'ev-click': goTo({ page: location.page, filter: 'All' })
25- }, 'All'),
26- h('span', '|'),
27- h('span -filter', {
28- className: 'Subscriptions' === activeFilter ? '-active' : '',
29- 'ev-click': goTo({ page: location.page, filter: 'Subscriptions' })
30- }, 'Subscriptions'),
31- h('span', '|'),
32- h('span -filter', {
33- className: 'Friends' === activeFilter ? '-active' : '',
34- 'ev-click': goTo({ page: location.page, filter: 'Friends' })
35- }, 'Friends')
36- ])
37- }
38-
39- return [h('TopNav -blog', [
18+ return h('TopNav -blog', [
4019 h('div.left', [
4120 h('div', {
4221 className: location.page === 'blogIndex' ? '-active' : '',
4322 'ev-click': goTo({ page: 'blogIndex' })
@@ -49,9 +28,7 @@
4928 ]),
5029 h('div.right', [
5130 h('Button -strong', { 'ev-click': () => api.history.sync.push({ page: 'blogNew' }) }, strings.blogNew.actions.writeBlog)
5231 ])
53- ]),
54- filters
55- ]
32+ ])
5633 })
5734 }
app/html/topNav/topNavBlog.mcssView
@@ -10,23 +10,4 @@
1010 div.right {
1111 }
1212 }
1313
14-Filters {
15- $backgroundPrimary
16- padding: 0.5rem 2rem
17- span {
18- $colorFontSubtle
19- padding: 10px
20-
21- -active {
22- $colorFontBasic
23- border-bottom: 2px solid #222
24- }
25-
26- -filter {
27- cursor: pointer
28- }
29- }
30-
31-}
32-
app/page/blogIndex.jsView
@@ -1,6 +1,6 @@
11 const nest = require('depnest')
2-const { h, Array: MutantArray, resolve, when, computed } = require('mutant')
2+const { h, Array: MutantArray, resolve, computed } = require('mutant')
33 const Scroller = require('mutant-scroll')
44 const pull = require('pull-stream')
55
66 const Next = require('pull-next')
@@ -28,33 +28,55 @@
2828 exports.create = (api) => {
2929 var blogsCache = MutantArray()
3030
3131 return nest('app.page.blogIndex', function (location) {
32- // location here can expected to be: { page: 'blogIndex'}
32+ // location here can expected to be: { page: 'blogIndex', filter: 'All' }
33+ const { page, filter = 'All' } = location
3334
3435 var strings = api.translations.sync.strings()
3536 blogsCache.clear()
3637
3738 var blogs = Scroller({
3839 classList: ['content'],
39- prepend: api.app.html.topNav(location),
40- streamToTop: Source({ reverse: false, live: true, old: false, limit: 20 }, api, location),
41- streamToBottom: Source({ reverse: true, live: false, limit: 20 }, api, location),
40+ prepend: [
41+ api.app.html.topNav(location),
42+ Filters()
43+ ],
44+ streamToTop: Source({ reverse: false, live: true, old: false, limit: 20 }, api, filter),
45+ streamToBottom: Source({ reverse: true, live: false, limit: 20 }, api, filter),
4246 updateTop: update,
4347 updateBottom: update,
4448 store: blogsCache,
4549 render
4650 })
4751
52+ function Filters () {
53+ const goTo = (loc) => () => api.history.sync.push(loc)
54+ return h('Filters', [
55+ h('span -filter', {
56+ className: filter === 'All' ? '-active' : '',
57+ 'ev-click': goTo({ page, filter: 'All' })
58+ }, 'All'),
59+ h('span', '|'),
60+ h('span -filter', {
61+ className: filter === 'Subscriptions' ? '-active' : '',
62+ 'ev-click': goTo({ page, filter: 'Subscriptions' })
63+ }, 'Subscriptions'),
64+ h('span', '|'),
65+ h('span -filter', {
66+ className: filter === 'Friends' ? '-active' : '',
67+ 'ev-click': goTo({ page, filter: 'Friends' })
68+ }, 'Friends')
69+ ])
70+ }
4871
49-
5072 return h('Page -blogIndex', { title: strings.home }, [
5173 api.app.html.sideNav(location),
5274 blogs
5375 ])
5476 })
5577
56- function Source(opts, api, location) {
78+ function Source (opts, api, filter) {
5779 const commonOpts = {
5880 query: [{
5981 $filter: {
6082 value: {
@@ -68,29 +90,26 @@
6890 }
6991
7092 const myId = api.keys.sync.id()
7193 const { followers } = api.contact.obs
72- const activeFilter = location.hasOwnProperty('filter') ? location.filter : "All"
7394
7495 const filterbyFriends = (msg) => {
75- if (activeFilter !== 'Friends') return true
96+ if (filter !== 'Friends') return true
7697
7798 const feed = msg.value.author
7899 const theirFollowers = followers(feed)
79100 const youFollowThem = computed(theirFollowers, followers => followers.includes(myId))
80- const r = resolve(youFollowThem)
81101
82- return r
102+ return resolve(youFollowThem)
83103 }
84104
85105 const filterBySubscription = (msg) => {
86- if (activeFilter !== 'Subscriptions') return true
106+ if (filter !== 'Subscriptions') return true
87107
88108 if (!msg.value.content.hasOwnProperty('channel')) {
89109 return false
90110 }
91111
92- const isSubscribedTo = api.channel.obs.isSubscribedTo
93112 const channel = msg.value.content.channel
94113
95114 return resolve(api.channel.obs.isSubscribedTo(channel))
96115 }
@@ -107,9 +126,9 @@
107126 pull.filter(msg => !api.message.sync.isBlocked(msg)) // this is already in feed.pull.type
108127 )
109128 }
110129
111- function update(soFar, newBlog) {
130+ function update (soFar, newBlog) {
112131 soFar.transaction(() => {
113132 var object = newBlog // Value(newBlog)
114133
115134 const index = indexOf(soFar, (blog) => newBlog.key === resolve(blog).key)
@@ -125,17 +144,17 @@
125144 }
126145 })
127146 }
128147
129- function render(blog) {
148+ function render (blog) {
130149 const { recps, channel } = blog.value.content
131150 var onClick
132151 if (channel && !recps) { onClick = (ev) => api.history.sync.push(Object.assign({}, blog, { page: 'blogShow' })) }
133152 return api.app.html.blogCard(blog, { onClick })
134153 }
135154 }
136155
137-function indexOf(array, fn) {
156+function indexOf (array, fn) {
138157 for (var i = 0; i < array.getLength(); i++) {
139158 if (fn(array.get(i))) {
140159 return i
141160 }
@@ -144,9 +163,9 @@
144163 }
145164
146165 // this is needed because muxrpc doesn't do back-pressure yet
147166 // this is a modified pull-next-step for ssb-query
148-function StepperStream(createStream, _opts) {
167+function StepperStream (createStream, _opts) {
149168 var opts = clone(_opts)
150169 var last = null
151170 var count = -1
152171
app/page/blogIndex.mcssView
@@ -24,4 +24,32 @@
2424 }
2525 }
2626 }
2727
28+Filters {
29+ background-color: #f1f1f1
30+
31+ font-size: .8rem
32+ text-transform: uppercase
33+ letter-spacing: 1.4px
34+
35+ padding: .5rem 0 .5rem .5rem
36+
37+ display: grid
38+ grid-template-columns: 4rem 0rem 10rem 0rem 7rem
39+ justify-items: center
40+
41+ span {
42+ $colorFontSubtle
43+ /* padding: 10px */
44+
45+ -active {
46+ $colorFontBasic
47+ font-weight: 600
48+ }
49+
50+ -filter {
51+ cursor: pointer
52+ }
53+ }
54+}
55+

Built with git-ssb-web