diff --git a/background.html b/background.html index 0b5fa5cbd..58e1b1946 100644 --- a/background.html +++ b/background.html @@ -277,10 +277,12 @@ {{ profileName }} {{ /profileName }} -
-

- {{ #message }}{{ message }}{{ /message }} -

+
+
+

+ {{ #message }}

{{ message }}
{{ /message }} +

+
diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index 570d78d25..2fbcc7e1c 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -69,7 +69,7 @@ ]; Whisper.AttachmentView = Backbone.View.extend({ - tagName: 'span', + tagName: 'div', className() { if (this.isImage()) { return 'attachment'; diff --git a/js/views/message_view.js b/js/views/message_view.js index 59f0e54d8..445a04de4 100644 --- a/js/views/message_view.js +++ b/js/views/message_view.js @@ -355,6 +355,24 @@ this.timerView.setElement(this.$('.timer')); this.timerView.update(); }, + isImageWithoutCaption: function() { + var attachments = this.model.get('attachments'); + var body = this.model.get('body'); + if (!attachments || attachments.length === 0) { + return false; + } + + if (body && body.trim()) { + return false; + } + + var first = attachments[0]; + if (first.contentType.startsWith('image/') && first.contentType !== 'image/tiff') { + return true; + } + + return false; + }, render: function() { var contact = this.model.isIncoming() ? this.model.getContact() : null; this.$el.html( @@ -364,6 +382,7 @@ sender: (contact && contact.getTitle()) || '', avatar: (contact && contact.getAvatar()), profileName: (contact && contact.getProfileName()), + innerBubbleClasses: this.isImageWithoutCaption() ? '' : 'with-tail', }, this.render_partials()) ); this.timeStampView.setElement(this.$('.timestamp')); diff --git a/stylesheets/_conversation.scss b/stylesheets/_conversation.scss index 6a0c6976b..89f36953d 100644 --- a/stylesheets/_conversation.scss +++ b/stylesheets/_conversation.scss @@ -451,6 +451,7 @@ span.status { } .body { + margin-top: 0.5em; white-space: pre-wrap; a { @@ -591,6 +592,7 @@ span.status { position: relative; padding: 5px; padding-right: 10px; + padding-bottom: 0px; cursor: pointer; diff --git a/stylesheets/_ios.scss b/stylesheets/_ios.scss index 341d4f38d..a9ab48b96 100644 --- a/stylesheets/_ios.scss +++ b/stylesheets/_ios.scss @@ -109,11 +109,33 @@ $ios-border-color: rgba(0,0,0,0.1); .attachments .bubbled { border-radius: 15px; - margin-bottom: 0.25em; padding: 10px; + padding-top: 0px; + padding-bottom: 5px; position: relative; + } + + .inner-bubble { + border-radius: 15px; + margin-bottom: 5px; + + .body { + margin-top: 0; + display: inline-block; + padding: 10px; + position: relative; + word-break: break-word; + } + + .attachments img { + border-radius: 15px; + } + } + + .inner-bubble.with-tail { + position: relative; &:before, &:after { content: ''; @@ -135,51 +157,27 @@ $ios-border-color: rgba(0,0,0,0.1); bottom: -3px; background: #eee; } - } - .bubble { - .content { - margin-bottom: 5px; - .body { - display: inline-block; - padding: 10px; - position: relative; - word-break: break-word; - - &:before, &:after { - content: ''; - display: block; - border-radius: 20px; - position: absolute; - width: 10px; - } - &:before { - right: -1px; - bottom: -3px; - height: 10px; - border-radius: 20px; - background: $blue; - } - &:after { - height: 11px; - right: -6px; - bottom: -3px; - background: #eee; - } - } - } - .content, .attachments img { - border-radius: 15px; - } .attachments img { - background-color: white; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; } - .meta { - clear: both; + } + + .meta { + clear: both; + } + + .outgoing .inner-bubble.with-tail { + background-color: $blue; + max-width: 100%; + &, .body, a { + @include invert-text-color; } + float: right; } - .incoming .bubbled { + .incoming .inner-bubble.with-tail { background-color: white; color: black; float: left; @@ -194,31 +192,6 @@ $ios-border-color: rgba(0,0,0,0.1); } } - .incoming .content { - background-color: white; - color: black; - float: left; - .body { - &:before { - left: -1px; - background-color: white; - } - &:after { - left: -6px; - } - } - } - .outgoing { - .content, .attachments .bubbled { - background-color: $blue; - max-width: 100%; - &, .body, a { - @include invert-text-color; - } - float: right; - } - } - .outgoing .attachments .fileView .icon { @include color-svg('../images/file.svg', white); &.audio { @@ -236,7 +209,6 @@ $ios-border-color: rgba(0,0,0,0.1); a { border-radius: 15px; } - margin-bottom: 1px; } .hourglass { @include hourglass(#999); diff --git a/test/index.html b/test/index.html index b922f8955..0b92f4d65 100644 --- a/test/index.html +++ b/test/index.html @@ -206,14 +206,22 @@ diff --git a/test/styleguide/legacy_templates.js b/test/styleguide/legacy_templates.js index 7710ba98d..04fc8df60 100644 --- a/test/styleguide/legacy_templates.js +++ b/test/styleguide/legacy_templates.js @@ -32,10 +32,12 @@ window.Whisper.View.Templates = { {{ profileName }} {{ /profileName }}
-
-

- {{ #message }}{{ message }}{{ /message }} -

+
+
+

+ {{ #message }}

{{ message }}
{{ /message }} +

+
diff --git a/ts/components/conversation/Message.md b/ts/components/conversation/Message.md index ed26747b9..ccd2c3db0 100644 --- a/ts/components/conversation/Message.md +++ b/ts/components/conversation/Message.md @@ -1,5 +1,5 @@ -Placeholder: +Placeholder component: ```jsx @@ -7,9 +7,36 @@ Placeholder: ``` -## With an attachment +## MessageView (Backbone) -### Image +### Plain messages + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + body: 'How are you doing this fine day?', + sent_at: Date.now() - 18000, +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550100', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + +### With an attachment + +#### Image ```jsx const outgoing = new Whisper.Message({ @@ -39,12 +66,70 @@ const View = Whisper.MessageView; ``` -### Video +#### Image, no caption + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + sent_at: Date.now() - 18000000, + attachments: [{ + data: util.gif, + fileName: 'pi.gif', + contentType: 'image/gif', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550100', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + +#### Video + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + body: "Beautiful, isn't it?", + sent_at: Date.now() - 10000, + attachments: [{ + data: util.mp4, + fileName: 'freezing_bubble.mp4', + contentType: 'video/mp4', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550100', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + +#### Video, no caption ```jsx const outgoing = new Whisper.Message({ type: 'outgoing', - body: "Beatiful, isn't it?", sent_at: Date.now() - 10000, attachments: [{ data: util.mp4, @@ -69,7 +154,7 @@ const View = Whisper.MessageView; ``` -### Audio +#### Audio ```jsx const outgoing = new Whisper.Message({ @@ -99,12 +184,40 @@ const View = Whisper.MessageView; ``` -### Voice message +#### Audio, no caption + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + sent_at: Date.now() - 15000, + attachments: [{ + data: util.mp3, + fileName: 'agnus_dei.mp3', + contentType: 'audio/mp3', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550100', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + +#### Voice message ```jsx const outgoing = new Whisper.Message({ type: 'outgoing', - body: 'This is a nice song', sent_at: Date.now() - 15000, attachments: [{ flags: textsecure.protobuf.AttachmentPointer.Flags.VOICE_MESSAGE, @@ -130,7 +243,7 @@ const View = Whisper.MessageView; ``` -### Other file type +#### Other file type ```jsx const outgoing = new Whisper.Message({ @@ -159,3 +272,32 @@ const View = Whisper.MessageView; /> ``` + +#### Other file type, no caption + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + sent_at: Date.now() - 15000, + attachments: [{ + data: util.txt, + fileName: 'lorum_ipsum.txt', + contentType: 'text/plain', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550100', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 2683d88c7..87eb3147a 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -4,7 +4,7 @@ import React from 'react'; /** * A placeholder Message component for now, giving the structure of a plain message with * none of the dynamic functionality. This page will be used to build up our corpus of - * permutations before start moving all message functionality to React. + * permutations before we start moving all message functionality to React. */ export class Message extends React.Component<{}, {}> { public render() { @@ -13,12 +13,14 @@ export class Message extends React.Component<{}, {}> {
-
-

- - Hi there. How are you doing? Feeling pretty good? Awesome. - -

+
+
+

+ + Hi there. How are you doing? Feeling pretty good? Awesome. + +

+