Commit a407ea75e9c86c40b52db83e092f821ca8ab84df
refactor classes to support BEM css
Dominic Tarr committed on 6/24/2016, 9:45:31 PMParent: 27e92625a95571a37337ba2095d5d17499d43195
Files changed
modules/compose.js | changed |
modules/post.js | changed |
modules/private.js | changed |
modules/public.js | changed |
modules/tabs.js | changed |
modules/thread.js | changed |
modules/compose.js | ||
---|---|---|
@@ -62,10 +62,10 @@ | ||
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | var composer = |
66 | - h('div', h('div.column', ta, | |
67 | - accessories = h('div.row', | |
66 | + h('div.compose', h('div.column', ta, | |
67 | + accessories = h('div.row.compose__controls', | |
68 | 68 | //hidden until you focus the textarea |
69 | 69 | {style: {display: 'none'}}, |
70 | 70 | file_input(function (file) { |
71 | 71 | files.push(file) |
@@ -97,5 +97,4 @@ | ||
97 | 97 | return composer |
98 | 98 | |
99 | 99 | } |
100 | 100 | |
101 | - |
modules/private.js | ||
---|---|---|
@@ -26,26 +26,38 @@ | ||
26 | 26 | } |
27 | 27 | |
28 | 28 | exports.screen_view = function (path) { |
29 | 29 | if(path === '/private') { |
30 | - var content = h('div.column') | |
31 | 30 | var id = null |
32 | 31 | sbot_whoami(function (err, me) { |
33 | 32 | id = me.id |
34 | 33 | }) |
35 | 34 | |
36 | - var div = h('div.column', {style: {'overflow':'auto'}}, | |
37 | - message_compose({type: 'post', recps: [], private: true}, | |
35 | + var div = h('div.column.scroller', | |
36 | + {style: {'overflow':'auto'}}, | |
37 | + h('div.scroller__wrapper', | |
38 | + message_compose({type: 'post'}), //header | |
39 | + content | |
40 | + ) | |
41 | + ) | |
42 | + | |
43 | + var compose = message_compose( | |
44 | + {type: 'post', recps: [], private: true}, | |
38 | 45 | function (msg) { |
39 | 46 | msg.recps = [id].concat(msg.mentions).filter(function (e) { |
40 | 47 | return ref.isFeed('string' === typeof e ? e : e.link) |
41 | 48 | }) |
42 | 49 | if(!msg.recps.length) |
43 | 50 | throw new Error('cannot make private message without recipients - just mention them in the message') |
44 | 51 | return msg |
45 | - }), | |
46 | - content) | |
52 | + }) | |
47 | 53 | |
54 | + var content = h('div.column.scroller__content') | |
55 | + var div = h('div.column.scroller', | |
56 | + {style: {'overflow':'auto'}}, | |
57 | + h('div.scroller__wrapper', compose, content) | |
58 | + ) | |
59 | + | |
48 | 60 | pull( |
49 | 61 | sbot_log({old: false}), |
50 | 62 | unbox(), |
51 | 63 | Scroller(div, content, message_render, true, false) |
@@ -68,4 +80,12 @@ | ||
68 | 80 | return "PRIVATE" |
69 | 81 | } |
70 | 82 | |
71 | 83 | |
84 | + | |
85 | + | |
86 | + | |
87 | + | |
88 | + | |
89 | + | |
90 | + | |
91 | + |
modules/public.js | ||
---|---|---|
@@ -10,12 +10,16 @@ | ||
10 | 10 | var sbot_log = plugs.first(exports.sbot_log = []) |
11 | 11 | |
12 | 12 | exports.screen_view = function (path, sbot) { |
13 | 13 | if(path === '/public') { |
14 | - var content = h('div.column') | |
15 | - var div = h('div.column', | |
14 | + | |
15 | + var content = h('div.column.scroller__content') | |
16 | + var div = h('div.column.scroller', | |
16 | 17 | {style: {'overflow':'auto'}}, |
17 | - message_compose({type: 'post'}), content | |
18 | + h('div.scroller__wrapper', | |
19 | + message_compose({type: 'post'}), //header | |
20 | + content | |
21 | + ) | |
18 | 22 | ) |
19 | 23 | |
20 | 24 | pull( |
21 | 25 | sbot_log({old: false}), |
@@ -45,4 +49,7 @@ | ||
45 | 49 | |
46 | 50 | |
47 | 51 | |
48 | 52 | |
53 | + | |
54 | + | |
55 | + |
modules/tabs.js | ||
---|---|---|
@@ -14,22 +14,29 @@ | ||
14 | 14 | var screen_view = plugs.first(exports.screen_view = []) |
15 | 15 | |
16 | 16 | exports.message_render = [] |
17 | 17 | |
18 | - | |
19 | 18 | exports.app = function () { |
20 | 19 | var tabs = Tabs() |
21 | 20 | tabs.classList.add('screen') |
22 | 21 | |
23 | - var public = screen_view('/public') | |
24 | - if(public) tabs.add('public', public, true) | |
22 | + var saved | |
23 | + try { saved = JSON.parse(localStorage.openTabs) } | |
24 | + catch (_) { saved = ['/public', '/private'] } | |
25 | + | |
26 | +// var public = screen_view('/public') | |
27 | +// if(public) tabs.add('public', public, true) | |
28 | +// | |
29 | +// var private = screen_view('/private') | |
30 | +// if(private) tabs.add('private', private, true) | |
31 | +// | |
32 | + saved.forEach(function (path) { | |
33 | + var el = screen_view(path) | |
34 | + if(el) tabs.add(path, el, true) | |
35 | + }) | |
25 | 36 | |
26 | - var private = screen_view('/private') | |
27 | - if(private) tabs.add('private', private, true) | |
37 | + tabs.select(saved[0] || '/public') | |
28 | 38 | |
29 | - tabs.select('public') | |
30 | - | |
31 | - | |
32 | 39 | tabs.onclick = function (ev) { |
33 | 40 | var link = ancestor(ev.target) |
34 | 41 | if(!link) return |
35 | 42 | var path = link.hash.substring(1) |
@@ -38,20 +45,20 @@ | ||
38 | 45 | ev.stopPropagation() |
39 | 46 | |
40 | 47 | //open external links. |
41 | 48 | //this ought to be made into something more runcible |
42 | - if(/^https?/.test(link.href)) | |
43 | - return require('electron').shell.openExternal(link.href) | |
49 | +// if(/^https?/.test(link.href)) | |
50 | +// return require('electron').shell.openExternal(link.href) | |
44 | 51 | |
45 | 52 | if(tabs.has(path)) return tabs.select(path) |
46 | 53 | |
47 | 54 | var el = screen_view(path) |
48 | - if(el) tabs.add(path, el, !ev.ctrlKey) | |
49 | - | |
55 | + if(el) { | |
56 | + tabs.add(path, el, !ev.ctrlKey) | |
57 | + localStorage.openTabs = JSON.stringify(tabs.tabs) | |
58 | + } | |
50 | 59 | } |
51 | 60 | |
52 | 61 | return tabs |
53 | 62 | } |
54 | 63 | |
55 | 64 | |
56 | - | |
57 | - |
modules/thread.js | ||
---|---|---|
@@ -57,13 +57,15 @@ | ||
57 | 57 | root: id, |
58 | 58 | branch: id //mutated when thread is loaded. |
59 | 59 | } |
60 | 60 | |
61 | - var content = h('div') | |
62 | - var div = h('div.column', | |
61 | + var content = h('div.column.scroller__content') | |
62 | + var div = h('div.column.scroller', | |
63 | 63 | {style: {'overflow-y': 'auto'}}, |
64 | - content, | |
65 | - h('div.editor', message_compose(meta)) | |
64 | + h('div.scroller__wrapper', | |
65 | + content, | |
66 | + message_compose(meta) | |
67 | + ) | |
66 | 68 | ) |
67 | 69 | |
68 | 70 | pull( |
69 | 71 | sbot_links({ |
Built with git-ssb-web