git ssb

10+

Matt McKegg / patchwork



Commit a5f9e9c80b3948d0c40559bef2b6be37e82fcd6d

restyle about messages to match new styles

Matt McKegg committed on 4/24/2017, 12:17:46 AM
Parent: 1eeb75ac7d51c6e0d4d8fe2c7b58e690b3318305

Files changed

plugs/message/html/layout/default.jschanged
plugs/message/html/layout/mini.jschanged
styles/message.mcsschanged
plugs/message/html/layout/default.jsView
@@ -45,9 +45,12 @@
4545
4646 return h('div', {
4747 classList
4848 }, [
49- messageHeader(msg, replyInfo, opts.priority),
49 + messageHeader(msg, {
50 + replyInfo,
51 + priority: opts.priority
52 + }),
5053 h('section', [opts.content]),
5154 computed(msg.key, (key) => {
5255 if (ref.isMsg(key)) {
5356 return h('footer', [
@@ -68,9 +71,9 @@
6871 ])
6972
7073 // scoped
7174
72- function messageHeader (msg, replyInfo, priority) {
75 + function messageHeader (msg, {replyInfo, priority}) {
7376 var additionalMeta = []
7477 if (opts.priority >= 2) {
7578 additionalMeta.push(h('span.flag -new', {title: 'New Message'}))
7679 }
@@ -83,9 +86,10 @@
8386 h('div.name', [
8487 api.profile.html.person(msg.value.author)
8588 ]),
8689 h('div.meta', [
87- api.message.html.timestamp(msg), ' ', replyInfo
90 + api.message.html.timestamp(msg), ' ',
91 + replyInfo
8892 ])
8993 ])
9094 ]),
9195 h('div.meta', [
plugs/message/html/layout/mini.jsView
@@ -1,63 +1,112 @@
1-const {h, computed} = require('mutant')
2-const nest = require('depnest')
1 +const { h, map, computed } = require('mutant')
2 +var nest = require('depnest')
33 var ref = require('ssb-ref')
44
55 exports.needs = nest({
6 + 'profile.html.person': 'first',
7 + 'message.obs.backlinks': 'first',
8 + 'message.obs.name': 'first',
69 'message.html': {
10 + link: 'first',
11 + meta: 'map',
712 action: 'map',
8- backlinks: 'first',
9- author: 'first',
10- meta: 'map',
1113 timestamp: 'first'
1214 },
13- 'profile.html.person': 'first'
15 + 'about.html.image': 'first'
1416 })
1517
1618 exports.gives = nest('message.html.layout')
1719
18-exports.create = (api) => {
19- return nest('message.html.layout', mini)
20 +exports.create = function (api) {
21 + return nest('message.html.layout', layout)
2022
21- function mini (msg, opts) {
22- if (opts.layout !== 'mini') return
23 + function layout (msg, opts) {
24 + if (!(opts.layout === 'mini')) return
2325
24- var classList = []
25- var additionalMeta = []
26- var footer = []
26 + var backlinks = opts.backlinks ? api.message.obs.backlinks(msg.key) : []
27 + var classList = ['Message -mini']
28 + var replyInfo = null
2729
28- if (opts.showActions) {
29- // HACK: this is used for about messages, which really should have there own layout
30- footer.push(
31- computed(msg.key, (key) => {
32- if (ref.isMsg(key)) {
33- return h('footer', [
34- h('div.actions', [
35- api.message.html.action(msg)
36- ])
37- ])
38- }
39- })
40- )
30 + if (msg.value.content.root) {
31 + classList.push('-reply')
32 + var branch = msg.value.content.branch
33 + if (branch) {
34 + if (!opts.previousId || (opts.previousId && last(branch) && opts.previousId !== last(branch))) {
35 + replyInfo = h('span', ['in reply to ', api.message.html.link(last(branch))])
36 + }
37 + }
38 + } else if (msg.value.content.project) {
39 + replyInfo = h('span', ['on ', api.message.html.link(msg.value.content.project)])
4140 }
4241
43- if (opts.priority >= 2) {
42 + if (opts.priority === 2) {
4443 classList.push('-new')
45- additionalMeta.push(h('span.flag -new', {title: 'New Message'}))
4644 }
47- return h('Message -mini', {classList}, [
48- h('header', [
49- h('div.mini', [
50- api.profile.html.person(msg.value.author), ' ',
51- opts.miniContent
45 +
46 + return h('div', {
47 + classList
48 + }, [
49 + messageHeader(msg, {
50 + replyInfo,
51 + priority: opts.priority,
52 + miniContent: opts.miniContent
53 + }),
54 + h('section', [opts.content]),
55 + computed(msg.key, (key) => {
56 + if (ref.isMsg(key)) {
57 + return h('footer', [
58 + h('div.actions', [
59 + api.message.html.action(msg)
60 + ])
61 + ])
62 + }
63 + }),
64 + map(backlinks, backlink => {
65 + return h('a.backlink', {
66 + href: backlink,
67 + title: backlink
68 + }, [
69 + h('strong', 'Referenced from'), ' ', api.message.obs.name(backlink)
70 + ])
71 + })
72 + ])
73 +
74 + // scoped
75 +
76 + function messageHeader (msg, {replyInfo, priority, miniContent}) {
77 + var additionalMeta = []
78 + if (opts.priority >= 2) {
79 + additionalMeta.push(h('span.flag -new', {title: 'New Message'}))
80 + }
81 + return h('header', [
82 + h('div.main', [
83 + h('a.avatar', {href: `${msg.value.author}`}, [
84 + api.about.html.image(msg.value.author)
85 + ]),
86 + h('div.main', [
87 + h('div.name', [
88 + api.profile.html.person(msg.value.author)
89 + ]),
90 + h('div.meta', [
91 + miniContent, ' ',
92 + replyInfo
93 + ])
94 + ])
5295 ]),
53- h('div.meta', {}, [
96 + h('div.meta', [
5497 api.message.html.meta(msg),
55- api.message.html.timestamp(msg),
56- additionalMeta
98 + additionalMeta,
99 + h('strong', api.message.html.timestamp(msg))
57100 ])
58- ]),
59- h('section', [opts.content]),
60- footer
61- ])
101 + ])
102 + }
62103 }
63104 }
105 +
106 +function last (array) {
107 + if (Array.isArray(array)) {
108 + return array[array.length - 1]
109 + } else {
110 + return array
111 + }
112 +}
styles/message.mcssView
@@ -35,22 +35,20 @@
3535 -mini {
3636 header {
3737 font-size: 100%
3838 margin-bottom: 15px
39- div.meta {
40- a.likes {
41- margin-top: -5px
39 + div.main {
40 + a.avatar {
41 + img {
42 + width: 40px
43 + height: 40px
44 + }
4245 }
43- a {
44- display: inline-block
45- margin-left: 3px
46- }
4746 }
4847 }
4948 }
5049
5150 -reply {
52- font-size: 120%
5351 header {
5452 font-size: 100%
5553 div.meta {
5654 a.channel {
@@ -149,9 +147,9 @@
149147 }
150148
151149 span.private {
152150 display: inline-block;
153- margin: -3px -3px -3px 4px;
151 + margin: -3px -3px 3px 4px;
154152 border: 4px solid #525050;
155153 position: relative;
156154
157155 a {

Built with git-ssb-web