Commit 88e355bf1c958e3361645fd8f0682f252a313b68
Merge pull request #624 from ssbc/5MB_cap
implement attachment block for files >5MBmix irving authored on 9/15/2017, 2:14:53 AM
GitHub committed on 9/15/2017, 2:14:53 AM
Parent: 2275ef9b617f2f59954bbd3007e579f19adc48cb
Parent: 477c9853277d89b00196c453547b293ae7ef6c0d
Files changed
main-window.js | changed |
modules/message/html/compose.js | changed |
package.json | changed |
styles/light/compose.mcss | changed |
main-window.js | ||
---|---|---|
@@ -72,9 +72,10 @@ | ||
72 | 72 | Array.from(document.head.children) |
73 | 73 | .filter(c => c.tagName == 'STYLE') |
74 | 74 | .forEach(c => c.innerText = '') |
75 | 75 | |
76 | - const theme = require('./styles')[name] | |
76 | + var theme = require('./styles')[name] | |
77 | + if (!theme) theme = require('./styles')['light'] | |
77 | 78 | insertCss(theme) |
78 | 79 | }) |
79 | 80 | |
80 | 81 | var container = h(`MainWindow -${process.platform}`, [ |
modules/message/html/compose.js | ||
---|---|---|
@@ -52,9 +52,28 @@ | ||
52 | 52 | disabled: publishing, |
53 | 53 | placeholder |
54 | 54 | }) |
55 | 55 | |
56 | + var warningMessage = Value(null) | |
57 | + var warning = h('section.warning', | |
58 | + { className: when(warningMessage, '-open', '-closed') }, | |
59 | + [ | |
60 | + h('div.warning', warningMessage), | |
61 | + h('div.close', { 'ev-click': () => warningMessage.set(null) }, 'x') | |
62 | + ] | |
63 | + ) | |
56 | 64 | var fileInput = api.blob.html.input(file => { |
65 | + const megabytes = file.size / 1024 / 1024 | |
66 | + if (megabytes >= 5) { | |
67 | + const rounded = Math.floor(megabytes*100)/100 | |
68 | + warningMessage.set([ | |
69 | + h('i.fa.fa-exclamation-triangle'), | |
70 | + h('strong', file.name), | |
71 | + ` is ${rounded}MB - the current limit is 5MB` | |
72 | + ]) | |
73 | + return | |
74 | + } | |
75 | + | |
57 | 76 | files.push(file) |
58 | 77 | filesById[file.link] = file |
59 | 78 | |
60 | 79 | var embed = file.type.indexOf('image/') === 0 ? '!' : '' |
@@ -89,8 +108,9 @@ | ||
89 | 108 | when(expanded, '-expanded', '-contracted') |
90 | 109 | ] |
91 | 110 | }, [ |
92 | 111 | textArea, |
112 | + warning, | |
93 | 113 | actions |
94 | 114 | ]) |
95 | 115 | |
96 | 116 | addSuggest(textArea, (inputText, cb) => { |
package.json | ||
---|---|---|
@@ -29,9 +29,9 @@ | ||
29 | 29 | "hashlru": "^2.2.0", |
30 | 30 | "insert-css": "~2.0.0", |
31 | 31 | "level": "~1.7.0", |
32 | 32 | "lrucache": "^1.0.2", |
33 | - "micro-css": "^2.0.0", | |
33 | + "micro-css": "^2.0.1", | |
34 | 34 | "mime-types": "^2.1.15", |
35 | 35 | "moment": "^2.18.1", |
36 | 36 | "mutant": "^3.21.2", |
37 | 37 | "mutant-pull-reduce": "^1.1.0", |
styles/light/compose.mcss | ||
---|---|---|
@@ -20,8 +20,35 @@ | ||
20 | 20 | background: #ebf7ee; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | + section.warning { | |
25 | + color: #fff | |
26 | + font-size: 1.2rem | |
27 | + background-color: #ff00b6 | |
28 | + | |
29 | + height: 0 | |
30 | + padding: 0 .5rem | |
31 | + transition: all ease-in .1s | |
32 | + | |
33 | + display: flex | |
34 | + justify-content: space-between | |
35 | + | |
36 | + | |
37 | + -open { | |
38 | + padding: .5rem | |
39 | + height: initial | |
40 | + } | |
41 | + | |
42 | + i.fa { margin-right: .5rem } | |
43 | + div.warning { | |
44 | + strong { margin-right: .3rem } | |
45 | + } | |
46 | + div.close { | |
47 | + cursor: pointer | |
48 | + } | |
49 | + } | |
50 | + | |
24 | 51 | section.actions { |
25 | 52 | display: flex |
26 | 53 | flex-direction: row |
27 | 54 | align-items: baseline |
Built with git-ssb-web