Commit 55f65b5f081677702c9c21215926ac33bbda7272
blog card styling
mix irving committed on 10/16/2017, 3:31:22 AMParent: 30cc7a8935378d1ee6fddd76239383d8da592a47
Files changed
app/html/blog-card.js | changed |
app/html/blog-card.mcss | changed |
app/index.js | changed |
styles/button.mcss | changed |
styles/mixins.js | changed |
app/html/blog-card.js | ||
---|---|---|
@@ -91,41 +91,40 @@ | ||
91 | 91 | const onClick = opts.onClick || function () { api.history.sync.push(thread) } |
92 | 92 | const id = `${thread.key.replace(/[^a-z0-9]/gi, '')}` //-${JSON.stringify(opts)}` |
93 | 93 | // id is only here to help morphdom morph accurately |
94 | 94 | |
95 | - var img = marksum.image(thread.value.content.text) | |
96 | - var m = /\!\[[^]+\]\(([^\)]+)\)/.exec(img) | |
95 | + const { content, author, timestamp } = thread.value | |
97 | 96 | |
97 | + var img = h('Thumbnail') | |
98 | + var m = /\!\[[^]+\]\(([^\)]+)\)/.exec(marksum.image(content.text)) | |
98 | 99 | if(m) { |
99 | 100 | //Hey this works! fit an image into a specific size (see thread-card.mcss) |
100 | 101 | //centered, and scaled to fit the square (works with both landscape and portrait!) |
101 | 102 | //This is functional css not opinionated css, so all embedded. |
102 | - img = h('Thumbnail') | |
103 | 103 | img.style = 'background-image: url("'+api.blob.sync.url(m[1])+'"); background-position:center; background-size: cover;' |
104 | 104 | } |
105 | - else img = '' | |
106 | - var title = render(marksum.title(thread.value.content.text)) | |
107 | - var summary = render(marksum.summary(thread.value.content.text)) | |
108 | 105 | |
109 | - var className = thread.unread ? '-unread': '' | |
106 | + const title = render(marksum.title(content.text)) | |
107 | + const summary = render(marksum.summary(content.text)) | |
108 | + | |
109 | + const className = thread.unread ? '-unread': '' | |
110 | + | |
110 | 111 | return h('BlogCard', { id, className }, [ |
111 | 112 | h('div.context', [ |
112 | - api.about.html.avatar(thread.value.author), | |
113 | - ' ', | |
114 | - api.about.obs.name(thread.value.author), | |
115 | - ' ', | |
116 | - humanTime(new Date(thread.value.timestamp)), | |
117 | - ' ', | |
118 | - thread.value.content.channel ? '#'+thread.value.content.channel : null | |
113 | + api.about.html.avatar(author), | |
114 | + h('div.name', api.about.obs.name(author)), | |
115 | + h('div.timeago', humanTime(new Date(timestamp))), | |
119 | 116 | ]), |
120 | 117 | h('div.content', {'ev-click': onClick}, [ |
121 | 118 | img, |
122 | - h('Text', [ | |
119 | + h('div.text', [ | |
123 | 120 | h('h2', {innerHTML: title}), |
124 | - h('Summary', {innerHTML: summary}) | |
121 | + content.channel | |
122 | + ? h('Button -channel', '#'+content.channel) | |
123 | + : '', | |
124 | + h('div.summary', {innerHTML: summary}) | |
125 | 125 | ]) |
126 | 126 | ]) |
127 | 127 | ]) |
128 | 128 | }) |
129 | 129 | } |
130 | 130 | |
131 | - |
app/html/blog-card.mcss | ||
---|---|---|
@@ -1,54 +1,66 @@ | ||
1 | 1 | BlogCard { |
2 | + padding: 1rem | |
3 | + background-color: #fff | |
4 | + margin-bottom: .5rem | |
5 | + | |
6 | + border: 1px solid #fff | |
7 | + transition: all .5s ease | |
8 | + | |
9 | + :hover { | |
10 | + border: 1px solid #999 | |
11 | + } | |
12 | + | |
2 | 13 | display: flex |
3 | -// align-items: center | |
4 | 14 | flex-direction: column |
5 | - margin-bottom: .5rem | |
6 | 15 | |
7 | 16 | div.context { |
17 | + font-size: .8rem | |
18 | + margin-bottom: 1rem | |
19 | + | |
8 | 20 | display: flex |
9 | - margin-right: 1rem | |
10 | - font-weight: inherit | |
21 | + align-items: center | |
22 | + | |
23 | + div.Link { | |
24 | + height: 2rem | |
25 | + img.Avatar { | |
26 | + width: 2rem | |
27 | + height: 2rem | |
28 | + } | |
29 | + } | |
30 | + | |
31 | + div.name { | |
32 | + margin-right: 1rem | |
33 | + } | |
34 | + div.timeago { | |
35 | + $colorSubtle | |
36 | + } | |
11 | 37 | } |
12 | 38 | |
13 | 39 | div.content { |
14 | 40 | display: flex |
15 | 41 | flex-direction: row |
16 | 42 | flex-grow: 1 |
17 | 43 | |
18 | 44 | cursor: pointer |
19 | - padding: 1rem | |
20 | - border: 1px solid #ddd | |
21 | - border-radius: 2px | |
22 | 45 | |
23 | - transition: all .5s ease | |
24 | 46 | |
25 | - :hover { | |
26 | - background-color: #fff | |
27 | - border: 1px solid #fff | |
47 | + div.Thumbnail { | |
48 | + margin-right: 1rem | |
28 | 49 | } |
50 | + | |
29 | 51 | div.text { |
30 | - flow-direction: column | |
31 | - } | |
32 | - | |
33 | - div.subject { | |
34 | - font-size: 1.2rem | |
35 | - margin-bottom: .3rem | |
36 | - | |
37 | - $markdownLarge | |
38 | - } | |
39 | - div.reply { | |
40 | - color: #444 | |
41 | - | |
42 | 52 | display: flex |
43 | - align-items: center | |
53 | + flex-wrap: wrap | |
44 | 54 | |
45 | - i.fa-caret-left { | |
46 | - margin-left: .7rem | |
47 | - margin-right: .5rem | |
55 | + h2 { | |
56 | + $markdownLarge | |
57 | + margin: 0 .5rem 0 0 | |
48 | 58 | } |
49 | - | |
50 | - $markdownSmall | |
59 | + div.Button.-channel {} | |
60 | + div.summary { | |
61 | + flex-basis: 100% | |
62 | + } | |
51 | 63 | } |
52 | 64 | } |
53 | 65 | |
54 | 66 | -unread { |
@@ -62,10 +74,11 @@ | ||
62 | 74 | } |
63 | 75 | } |
64 | 76 | |
65 | 77 | Thumbnail { |
66 | - border-radius: 5px | |
67 | - min-width: 100px | |
68 | - min-height: 100px | |
69 | - width: 100px | |
70 | - height: 100px | |
78 | + border-radius: .5rem | |
79 | + min-width: 8rem | |
80 | + min-height: 6rem | |
81 | + width: 8rem | |
82 | + height: 6rem | |
71 | 83 | } |
84 | + |
app/index.js | ||
---|---|---|
@@ -7,9 +7,9 @@ | ||
7 | 7 | context: require('./html/context'), |
8 | 8 | header: require('./html/header'), |
9 | 9 | thread: require('./html/thread'), |
10 | 10 | link: require('./html/link'), |
11 | - blogCard: require('./html/thread-card'), | |
11 | + blogCard: require('./html/blog-card'), | |
12 | 12 | }, |
13 | 13 | page: { |
14 | 14 | blogIndex: require('./page/blogIndex'), |
15 | 15 | blogNew: require('./page/blogNew'), |
styles/button.mcss | ||
---|---|---|
@@ -1,17 +1,21 @@ | ||
1 | 1 | Button { |
2 | 2 | font-family: arial |
3 | - text-align: center | |
4 | 3 | background-color: #fff |
5 | 4 | |
6 | 5 | min-width: 6rem |
6 | + height: 1.2rem | |
7 | 7 | padding: .2rem 1rem |
8 | 8 | |
9 | 9 | border: 1px #b9b9b9 solid |
10 | 10 | border-radius: 10rem |
11 | 11 | |
12 | 12 | cursor: pointer |
13 | 13 | |
14 | + display: flex | |
15 | + justify-content: center | |
16 | + align-items: center | |
17 | + | |
14 | 18 | -subtle { |
15 | 19 | color: initial |
16 | 20 | :hover { |
17 | 21 | color: #222 |
styles/mixins.js | ||
---|---|---|
@@ -49,9 +49,9 @@ | ||
49 | 49 | color: #fff |
50 | 50 | } |
51 | 51 | |
52 | 52 | $colorSubtle { |
53 | - color: #222 | |
53 | + color: #999 | |
54 | 54 | } |
55 | 55 | |
56 | 56 | $backgroundPrimary { |
57 | 57 | background-color: #f5f6f7 |
@@ -87,26 +87,42 @@ | ||
87 | 87 | (img.emoji) { |
88 | 88 | height: .9rem |
89 | 89 | } |
90 | 90 | } |
91 | + h1, h2, h3, h4, h5, h6, p { | |
92 | + font-size: .9rem | |
93 | + font-weight: 300 | |
94 | + margin: 0 | |
95 | + } | |
96 | + (img.emoji) { | |
97 | + height: .9rem | |
98 | + } | |
91 | 99 | } |
92 | 100 | |
93 | 101 | $markdownLarge { |
94 | 102 | div.Markdown { |
95 | 103 | h1, h2, h3, h4, h5, h6, p { |
96 | - font-size: 1.2rem | |
104 | + font-size: 1.5rem | |
97 | 105 | font-weight: 300 |
98 | 106 | margin: 0 |
99 | 107 | } |
100 | 108 | } |
109 | + h1, h2, h3, h4, h5, h6, p { | |
110 | + font-size: 1.5rem | |
111 | + font-weight: 300 | |
112 | + margin: 0 | |
113 | + } | |
101 | 114 | } |
102 | 115 | |
103 | 116 | $markdownBold { |
104 | 117 | div.Markdown { |
105 | 118 | h1, h2, h3, h4, h5, h6, p { |
106 | 119 | font-weight: bold |
107 | 120 | } |
108 | 121 | } |
122 | + h1, h2, h3, h4, h5, h6, p { | |
123 | + font-weight: bold | |
124 | + } | |
109 | 125 | } |
110 | 126 | |
111 | 127 | $borderSubtle { |
112 | 128 | border: 1px solid #b9b9b9 |
Built with git-ssb-web