git ssb

16+

Dominic / patchbay



Commit f3abfca785a8f7b93cc0240027581e4dbe4385d9

refactor preview message to use Message

mix irving committed on 1/4/2017, 9:49:16 PM
Parent: 41ed6a5aa572f6de601bab35fc108a955657c074

Files changed

modules_basic/message.jschanged
modules_core/message-confirm.jschanged
modules_core/message-confirm.mcssadded
style.csschanged
modules_basic/message.jsView
@@ -26,9 +26,9 @@
2626 message_render,
2727 mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
2828 }
2929
30- function message_render (msg, sbot) {
30 + function message_render (msg) {
3131 var content = api.message_content_mini(msg)
3232 if (content) return mini(msg, content)
3333
3434 content = api.message_content(msg)
@@ -83,4 +83,5 @@
8383
8484 function message_content_mini_fallback(msg) {
8585 return h('code', msg.value.content.type)
8686 }
87 +
modules_core/message-confirm.jsView
@@ -1,27 +1,33 @@
1-var lightbox = require('hyperlightbox')
2-var h = require('hyperscript')
3-var u = require('../util')
4-var self_id = require('../keys').id
1 +const fs = require('fs')
2 +const lightbox = require('hyperlightbox')
3 +const h = require('../h')
4 +const u = require('../util')
5 +const self_id = require('../keys').id
56 //publish or add
67
7-var plugs = require('../plugs')
8 +const plugs = require('../plugs')
89
910 exports.needs = {
10- publish: 'first', message_content: 'first', avatar: 'first',
11 + publish: 'first',
12 + message_render: 'first',
13 + avatar: 'first',
1114 message_meta: 'map'
1215 }
1316
14-exports.gives = 'message_confirm'
17 +exports.gives = {
18 + message_confirm: 'true',
19 + mcss: 'true'
20 +}
1521
16-//var publish = plugs.first(exports.sbot_publish = [])
17-//var message_content = plugs.first(exports.message_content = [])
18-//var avatar = plugs.first(exports.avatar = [])
19-//var message_meta = plugs.map(exports.message_meta = [])
20-//
2122 exports.create = function (api) {
22- return function (content, cb) {
23 + return {
24 + message_confirm,
25 + mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
26 + }
2327
28 + function message_confirm (content, cb) {
29 +
2430 cb = cb || function () {}
2531
2632 var lb = lightbox()
2733 document.body.appendChild(lb)
@@ -36,32 +42,33 @@
3642 content: content
3743 }
3844 }
3945
40- var okay = h('button', 'okay', {onclick: function () {
41- lb.remove()
42- api.publish(content, cb)
43- }})
46 + var okay = h('button', {
47 + 'ev-click': () => {
48 + lb.remove()
49 + api.publish(content, cb)
50 + }},
51 + 'okay'
52 + )
4453
45- var cancel = h('button', 'Cancel', {onclick: function () {
46- lb.remove()
47- cb(null)
48- }})
54 + var cancel = h('button', {
55 + 'ev-click': () => {
56 + lb.remove()
57 + cb(null)
58 + }},
59 + 'Cancel'
60 + )
4961
5062 okay.addEventListener('keydown', function (ev) {
5163 if(ev.keyCode === 27) cancel.click() //escape
5264 })
5365
54- lb.show(h('div.column.message-confirm',
55- h('div.message',
56- h('div.title.row',
57- h('div.avatar', api.avatar(msg.value.author, 'thumbnail')),
58- h('div.message_meta.row', api.message_meta(msg))
59- ),
60- h('div.message_content', api.message_content(msg)
61- || h('pre', JSON.stringify(msg, null, 2)))
62- ),
63- h('div.row.message-confirm__controls', okay, cancel)
66 + lb.show(h('MessageConfirm', [
67 + h('header -preview_description', h('h1', 'Preview')),
68 + h('section -message_preview', api.message_render(msg)),
69 + h('section -actions', [okay, cancel])
70 + ]
6471 ))
6572
6673 okay.focus()
6774 }
modules_core/message-confirm.mcssView
@@ -1,0 +1,36 @@
1 +MessageConfirm {
2 + section {
3 + -preview_description {
4 + }
5 +
6 + -message_preview {
7 + background-color: white
8 +
9 + div {
10 + border: none
11 + header.author {
12 + div {
13 + section {
14 + -timestamp {
15 + display: none
16 + }
17 + }
18 + }
19 + }
20 + section.action {
21 + display: none
22 + }
23 + }
24 + }
25 +
26 + -actions {
27 + margin-top: 1rem
28 + display: flex
29 + justify-content: flex-end
30 +
31 + button {
32 + margin: 0 0 0 1rem
33 + }
34 + }
35 +}
36 +
style.cssView
@@ -338,18 +338,17 @@
338338 /* lightbox - used in message-confirm */
339339
340340 .lightbox {
341341 overflow: auto;
342- padding: 1.5em;
343- margin-top: 3em;
344- margin-bottom: 3em;
345- width: 600px;
342 + width: 650px;
343 + padding: 25px;
344 + margin: 3em 0;
345 +
346 + z-index: 2;
347 +
346348 background: #f5f5f5;
347- margin-left: auto;
348- margin-right: auto;
349349 border: 1px solid #eee;
350350 border-radius: .2em;
351- z-index: 2;
352351 }
353352
354353 /* searchprompt */
355354

Built with git-ssb-web