git ssb

0+

mixmix / patchbay-scry



Commit 6071577daff8cc01e7241b5799fb112902aec545

add font-awesome checkboxes, avatars

mixmix committed on 9/4/2018, 2:35:59 AM
Parent: 149ebf96217ad2dba9b20dc6778e70fec68e53cf

Files changed

plugs/app/page/scry-show.jschanged
plugs/app/page/scry-show.mcsschanged
views/show.jschanged
views/show.mcsschanged
views/show.test.jschanged
plugs/app/page/scry-show.jsView
@@ -8,9 +8,9 @@
88 'app.page.scryShow': true
99 })
1010
1111 exports.needs = nest({
12- // 'about.html.avatar': 'first',
12 + 'about.html.avatar': 'first',
1313 'about.obs.name': 'first',
1414 'keys.sync.id': 'first',
1515 'sbot.obs.connection': 'first'
1616 })
@@ -25,9 +25,10 @@
2525 Show({
2626 poll,
2727 myFeedId: api.keys.sync.id(),
2828 scuttle: Scuttle(api.sbot.obs.connection),
29- name: api.about.obs.name
29 + name: api.about.obs.name,
30 + avatar: api.about.html.avatar
3031 })
3132 ])
3233
3334 page.scroll = () => {} // stops keyboard shortcuts from breaking
plugs/app/page/scry-show.mcssView
@@ -13,6 +13,11 @@
1313 width: 100%
1414
1515 div.ScryShow {
1616 max-width: 80vw
17 +
18 + div.ScryShowResults {
19 + div.about {
20 + }
21 + }
1722 }
1823 }
views/show.jsView
@@ -1,23 +1,18 @@
11 const { h, Struct, computed, resolve } = require('mutant')
22 const pull = require('pull-stream')
33 const printTime = require('../lib/print-time')
44
5-const YES = '✔'
6-const EDIT_YES = '☑'
7-const EDIT_NO = '☐'
8-
95 module.exports = function ScryShow (opts) {
106 const {
117 poll,
128 myFeedId,
139 scuttle,
14- name = k => k.slice(0, 9)
15- // avatar = ''
10 + name = k => k.slice(0, 9),
11 + avatar = k => h('img'),
12 + testing = false
1613 } = opts
1714
18- console.log(opts)
19-
2015 const state = Struct(initialState())
2116 fetchState()
2217 watchForUpdates(fetchState)
2318
@@ -63,9 +58,9 @@
6358 function ScryShowResults () {
6459 return computed(state.now, ({ title, closesAt, times, rows }) => {
6560 const style = {
6661 display: 'grid',
67- 'grid-template-columns': `minmax(8rem, auto) repeat(${times.length}, 4rem)`
62 + 'grid-template-columns': `minmax(10rem, auto) repeat(${times.length}, 4rem)`
6863 }
6964
7065 return [
7166 h('ScryShowResults', { style }, [
@@ -78,11 +73,14 @@
7873
7974 function ScryShowRow ({ author, position }) {
8075 if (author !== myFeedId) {
8176 return [
82- h('div.name', name(author)),
77 + h('div.about', [
78 + avatar(author),
79 + name(author)
80 + ]),
8381 position.map(pos => pos
84- ? h('div.position.-yes', YES)
82 + ? h('div.position.-yes', tick())
8583 : h('div.position.-no')
8684 )
8785 ]
8886 }
@@ -92,13 +90,14 @@
9290 state.next.isEditing.set(isEditing)
9391 }
9492
9593 return [
96- h('div.name', [
94 + h('div.about', [
95 + avatar(author),
9796 name(author),
9897 h('i.fa.fa-pencil', { 'ev-click': toggleEditing })
9998 ]),
100- computed(state.next, ({ isEditing, position }) => {
99 + computed([state.next, state.now.position], ({ isEditing, position }, currentPosition) => {
101100 if (isEditing) {
102101 return position.map((pos, i) => {
103102 return h('div.position.-edit',
104103 {
@@ -107,15 +106,15 @@
107106 nextPosition[i] = !pos
108107 state.next.position.set(nextPosition)
109108 }
110109 },
111- pos ? EDIT_YES : EDIT_NO
110 + pos ? checkedBox() : uncheckedBox()
112111 )
113112 })
114113 }
115114
116- return position.map(pos => pos
117- ? h('div.position.-yes', '✔')
115 + return currentPosition.map(pos => pos
116 + ? h('div.position.-yes', tick())
118117 : h('div.position.-no')
119118 )
120119 })
121120 ]
@@ -176,8 +175,12 @@
176175 cb()
177176 })
178177 )
179178 }
179 +
180 + function tick () { return '✔' }
181 + function checkedBox () { return testing ? '☑' : h('i.fa.fa-check-square-o') }
182 + function uncheckedBox () { return testing ? '☐' : h('i.fa.fa-square-o') }
180183 }
181184
182185 function initialState () {
183186 return {
views/show.mcssView
@@ -45,19 +45,27 @@
4545 div.ScryShowTime {
4646 padding: 10px
4747 }
4848
49- div.name {
49 + div.about {
5050 font-size: 14px
5151 font-weight: 600
52- padding-left: 10px
52 + padding: 0 8px 0 5px
5353
54- display: flex
55- justify-content: space-between
54 + display: grid
55 + grid-template-columns: auto 1fr auto
56 + grid-gap: 7px
57 + align-content: center
5658 align-items: center
5759
60 + a { height: 30px }
61 + (img) {
62 + height: 30px
63 + width: 30px
64 + }
65 +
5866 i {
59- margin: 0 .5rem
67 + justify-self: flex-end
6068 cursor: pointer
6169 }
6270 }
6371
@@ -72,12 +80,13 @@
7280 background: hsla(312, 60%, 70%, 1)
7381 align-self: stretch
7482 }
7583 -edit {
84 + text-align: initial
85 + justify-self: center
7686 color: hsla(312, 60%, 70%, 1)
77- font-wight: 600
7887 cursor: pointer
79- align-self: stretch
88 + width: 20px
8089 }
8190 }
8291 }
8392
views/show.test.jsView
@@ -85,9 +85,10 @@
8585 const show = Show({
8686 poll,
8787 myFeedId: sbot.id,
8888 scuttle,
89- name
89 + name,
90 + testing: true
9091 })
9192
9293 document.body.appendChild(show)
9394

Built with git-ssb-web