git ssb

16+

Dominic / patchbay



Commit e2eeffaea66a7eb969eaeda4f2703aeaf528a364

more about message styles

Michael Williams committed on 12/23/2016, 7:27:16 AM
Parent: 3fef46e8bded9b6d561b445d5f1aaff609bb392a

Files changed

modules_basic/about.jschanged
modules_basic/about.mcssadded
modules_basic/about.jsView
@@ -1,75 +1,88 @@
1 +var fs = require('fs')
2 +var Path = require('path')
13 var h = require('../h')
4 +var when = require('@mmckegg/mutant/when')
25
36 exports.needs = {
4- blob_url: 'first'
7 + blob_url: 'first',
8 + markdown: 'first'
59 }
610
711 exports.gives = {
812 mcss: true,
913 message_content: true
1014 }
1115
12-var mcss = `
13- About {
14- display: flex
15- flex-wrap: wrap
16-
17- header {
18- margin-right: .4rem
19- }
20- }
21-`
22-
2316 exports.create = function (api) {
24- return {
17 + return {
2518 message_content,
26- mcss: function () { return mcss }
19 + mcss: () => fs.readFileSync(Path.join(__dirname, 'about.mcss'), 'utf8')
2720 }
2821
2922 function message_content (msg) {
30- if(msg.value.content.type !== 'about') return
23 + if (msg.value.content.type !== 'about') return
3124
32- var { value } = msg
33- var { content: about, author: authorId } = value
25 + var { content: about, author: authorId } = msg.value
3426 var { about: aboutId, name, image, description } = about
3527 // TODO does about default to the message author?
3628 // var { about: aboutId = authorId, name, image, description } = about
3729
3830 return h('About', [
39- verb({ aboutId, authorId: msg.value.author }),
40- profile({ aboutId, name, image, description })
31 + Name({ aboutId, authorId, name }),
32 + Image({ aboutId, authorId, image }),
33 + Description({ aboutId, authorId, description })
4134 ])
4235 }
4336
44- function profile ({ aboutId, name, image, description }) {
45- return h('div', [
46- name
47- ? h('a', {href:'#'+aboutId}, name)
48- : null,
49- image
50- ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)}))
51- : null,
52- description || null
37 + function Name ({ aboutId, authorId, name }) {
38 + if (!name) return null
39 + return h('section -name', [
40 + h('header', ['refers to ', when(authorId === aboutId, 'self', targetLink(aboutId)), ' as ']),
41 + h('section', nameLink(aboutId, name))
5342 ])
5443 }
55-}
5644
45 + function Image ({ aboutId, authorId, image }) {
46 + if (!image) return null
47 + return h('section -image', [
48 + h('header', ['portrays ', when(authorId === aboutId, 'self', targetLink(aboutId)), ' as ']),
49 + h('section', imageLink(aboutId, h('img', { src: api.blob_url(image) })))
50 + ])
51 + }
5752
58-function verb ({ aboutId, authorId }) {
59- var content = authorId === aboutId
60- ? 'self-identifies as'
61- : ['identifies ', idLink(aboutId), ' as']
53 + function Description ({ aboutId, authorId, description }) {
54 + if (!description) return null
55 + return h('section -description', [
56 + h('header', ['describes ', when(authorId === aboutId, 'self', targetLink(aboutId)), ' as ']),
57 + h('section', api.markdown(description))
58 + ])
59 + }
60 +}
6261
63- return h('header', content)
62 +function targetLink (aboutId) {
63 + if (!aboutId) return null
64 + const content = aboutId.slice(0, 9) + '...'
65 + return h(
66 + 'a -target',
67 + { href: `#${aboutId}` },
68 + content
69 + )
6470 }
6571
66-function idLink (id) {
67- if (!id) return null
68-
69- return h('a', {href:'#'+id}, id.slice(0,9) + '...')
72 +function nameLink (aboutId, name) {
73 + if (!aboutId) return null
74 + return h(
75 + 'a -name',
76 + { href: `#${aboutId}` },
77 + name
78 + )
7079 }
7180
72-function asLink (ln) {
73- return typeof ln === 'string' ? ln : ln.link
81 +function imageLink (aboutId, img) {
82 + if (!aboutId) return null
83 + return h(
84 + 'a -image',
85 + { href: `#${aboutId}` },
86 + img
87 + )
7488 }
75-
modules_basic/about.mcssView
@@ -1,0 +1,49 @@
1 +About {
2 + display: flex
3 + flex-wrap: wrap
4 +
5 + section {
6 + a {
7 + -target {
8 + color: green
9 + }
10 + -name {
11 +
12 + }
13 + -image {
14 +
15 + }
16 + }
17 +
18 + -name {
19 + header {
20 +
21 + }
22 +
23 + section {
24 +
25 + }
26 + }
27 +
28 + -image {
29 + header {
30 +
31 + }
32 +
33 + section {
34 +
35 + }
36 + }
37 +
38 + -description {
39 + header {
40 +
41 + }
42 +
43 + section {
44 + padding-left: 1em;
45 + padding-right: 1em;
46 + }
47 + }
48 + }
49 +}

Built with git-ssb-web