Commit 755b0f1ae26a1af4371659e3f3a45b9cf6c690c0
style private, message confirm box, and mention suggestions
Matt McKegg committed on 11/1/2016, 1:38:05 AMParent: c3bad31f482772bb2f1cb0a4e5b4f99071a9a625
Files changed
modules/message.js | changed |
modules/private.js | changed |
modules/message-confirm.js | added |
styles/message.mcss | changed |
styles/patchbay-tweaks.css | changed |
styles/message-confirm.mcss | added |
modules/message.js | ||
---|---|---|
@@ -1,5 +1,6 @@ | ||
1 | 1 | var h = require('../lib/h') |
2 | +var when = require('@mmckegg/mutant/when') | |
2 | 3 | |
3 | 4 | var plugs = require('patchbay/plugs') |
4 | 5 | var message_content = plugs.first(exports.message_content = []) |
5 | 6 | var message_content_mini = plugs.first(exports.message_content_mini = []) |
@@ -68,14 +69,14 @@ | ||
68 | 69 | ]), |
69 | 70 | h('div.meta', message_meta(msg)) |
70 | 71 | ]), |
71 | 72 | h('section', [el]), |
72 | - h('footer', [ | |
73 | + when(msg.key, h('footer', [ | |
73 | 74 | h('div.actions', [ |
74 | 75 | message_action(msg), |
75 | 76 | h('a', {href: '#' + msg.key}, 'Reply') |
76 | 77 | ]) |
77 | - ]) | |
78 | + ])) | |
78 | 79 | ]) |
79 | 80 | |
80 | 81 | // ); hyperscript does not seem to set attributes correctly. |
81 | 82 | element.setAttribute('tabindex', '0') |
modules/private.js | ||
---|---|---|
@@ -7,8 +7,9 @@ | ||
7 | 7 | var message_unbox = plugs.first(exports.message_unbox = []) |
8 | 8 | var get_id = plugs.first(exports.get_id = []) |
9 | 9 | var avatar_image_link = plugs.first(exports.avatar_image_link = []) |
10 | 10 | var update_cache = plugs.first(exports.update_cache = []) |
11 | +var h = require('../lib/h') | |
11 | 12 | |
12 | 13 | exports.screen_view = function (path, sbot) { |
13 | 14 | if (path === '/private') { |
14 | 15 | var id = get_id() |
@@ -43,12 +44,14 @@ | ||
43 | 44 | } |
44 | 45 | } |
45 | 46 | |
46 | 47 | exports.message_meta = function (msg) { |
47 | - if(msg.value.content.recps || msg.value.private) { | |
48 | - return h('span.row', 'PRIVATE', map(msg.value.content.recps, function (id) { | |
49 | - return avatar_image_link('string' == typeof id ? id : id.link, 'thumbnail') | |
50 | - })) | |
48 | + if (msg.value.content.recps || msg.value.private) { | |
49 | + return h('span.private', [ | |
50 | + map(msg.value.content.recps, function (id) { | |
51 | + return avatar_image_link(typeof id === 'string' ? id : id.link, 'thumbnail') | |
52 | + }) | |
53 | + ]) | |
51 | 54 | } |
52 | 55 | } |
53 | 56 | |
54 | 57 | function unbox () { |
modules/message-confirm.js | ||
---|---|---|
@@ -1,0 +1,51 @@ | ||
1 | +var lightbox = require('hyperlightbox') | |
2 | +var h = require('../lib/h') | |
3 | +var plugs = require('patchbay/plugs') | |
4 | +var get_id = plugs.first(exports.get_id = []) | |
5 | +var publish = plugs.first(exports.sbot_publish = []) | |
6 | +var message_render = plugs.first(exports.message_render = []) | |
7 | + | |
8 | +exports.message_confirm = function (content, cb) { | |
9 | + cb = cb || function () {} | |
10 | + | |
11 | + var lb = lightbox() | |
12 | + document.body.appendChild(lb) | |
13 | + | |
14 | + var msg = { | |
15 | + value: { | |
16 | + author: get_id(), | |
17 | + previous: null, | |
18 | + sequence: null, | |
19 | + timestamp: Date.now(), | |
20 | + content: content | |
21 | + } | |
22 | + } | |
23 | + | |
24 | + var okay = h('button', { | |
25 | + 'ev-click': function () { | |
26 | + lb.remove() | |
27 | + publish(content, cb) | |
28 | + }, | |
29 | + 'ev-keydown': function (ev) { | |
30 | + if (ev.keyCode === 27) cancel.click() // escape | |
31 | + } | |
32 | + }, [ | |
33 | + 'okay' | |
34 | + ]) | |
35 | + | |
36 | + var cancel = h('button', {'ev-click': function () { | |
37 | + lb.remove() | |
38 | + cb(null) | |
39 | + }}, [ | |
40 | + 'Cancel' | |
41 | + ]) | |
42 | + | |
43 | + lb.show(h('MessageConfirm', [ | |
44 | + h('section', [ | |
45 | + message_render(msg) | |
46 | + ]), | |
47 | + h('footer', [okay, cancel]) | |
48 | + ])) | |
49 | + | |
50 | + okay.focus() | |
51 | +} |
styles/message.mcss | ||
---|---|---|
@@ -63,8 +63,40 @@ | ||
63 | 63 | border-radius: 10px; |
64 | 64 | display: inline-block; |
65 | 65 | vertical-align: top; |
66 | 66 | } |
67 | + | |
68 | + span.private { | |
69 | + display: inline-block; | |
70 | + margin: -3px -3px -3px 4px; | |
71 | + border: 4px solid #525050; | |
72 | + position: relative; | |
73 | + | |
74 | + a { | |
75 | + display: inline-block | |
76 | + | |
77 | + img { | |
78 | + margin: 0 | |
79 | + vertical-align: bottom | |
80 | + border: none | |
81 | + } | |
82 | + } | |
83 | + | |
84 | + :after { | |
85 | + content: 'private'; | |
86 | + position: absolute; | |
87 | + background: #525050; | |
88 | + bottom: 0; | |
89 | + left: -1px; | |
90 | + font-size: 10px; | |
91 | + padding: 2px 4px 0 2px; | |
92 | + border-top-right-radius: 5px; | |
93 | + color: white; | |
94 | + font-weight: bold; | |
95 | + pointer-events: none; | |
96 | + white-space: nowrap | |
97 | + } | |
98 | + } | |
67 | 99 | } |
68 | 100 | } |
69 | 101 | |
70 | 102 | section { |
styles/patchbay-tweaks.css | ||
---|---|---|
@@ -27,4 +27,32 @@ | ||
27 | 27 | |
28 | 28 | div.compose textarea { |
29 | 29 | transition: height 0.1s |
30 | 30 | } |
31 | + | |
32 | +div.lightbox { | |
33 | + box-shadow: #5f5f5f 1px 2px 100px; | |
34 | + bottom: inherit !important; | |
35 | + overflow: hidden !important; | |
36 | +} | |
37 | + | |
38 | +div.suggest-box { | |
39 | + background: #333; | |
40 | +} | |
41 | + | |
42 | +div.suggest-box ul { | |
43 | + left: 390px; | |
44 | + top: 87px; | |
45 | + position: fixed; | |
46 | + padding: 5px; | |
47 | + border-radius: 3px; | |
48 | + background: #fdfdfd; | |
49 | + border: 1px solid #CCC; | |
50 | +} | |
51 | + | |
52 | +div.suggest-box li { | |
53 | + padding: 3px; | |
54 | +} | |
55 | + | |
56 | +div.suggest-box strong { | |
57 | + font-weight: normal; | |
58 | +} |
styles/message-confirm.mcss | ||
---|---|---|
@@ -1,0 +1,18 @@ | ||
1 | +MessageConfirm { | |
2 | + section { | |
3 | + max-height: 80vh; | |
4 | + overflow: auto; | |
5 | + margin: -20px; | |
6 | + padding: 20px; | |
7 | + margin-bottom: 0; | |
8 | + } | |
9 | + footer { | |
10 | + text-align: right; | |
11 | + background: #e2e2e2; | |
12 | + margin: 0px -20px -20px; | |
13 | + padding: 5px; | |
14 | + border-top: 1px solid #d6d6d6; | |
15 | + position: relative; | |
16 | + box-shadow: 0 0 6px rgba(51, 51, 51, 0.47); | |
17 | + } | |
18 | +} |
Built with git-ssb-web