diff --git a/fixtures/1000x50-green.jpeg b/fixtures/1000x50-green.jpeg new file mode 100644 index 0000000000..37121f4ebd Binary files /dev/null and b/fixtures/1000x50-green.jpeg differ diff --git a/fixtures/200x50-purple.png b/fixtures/200x50-purple.png new file mode 100644 index 0000000000..083e1e47ef Binary files /dev/null and b/fixtures/200x50-purple.png differ diff --git a/fixtures/20x200-yellow.png b/fixtures/20x200-yellow.png new file mode 100644 index 0000000000..f3ff95271d Binary files /dev/null and b/fixtures/20x200-yellow.png differ diff --git a/fixtures/300x1-red.jpeg b/fixtures/300x1-red.jpeg new file mode 100644 index 0000000000..2bb34c2e78 Binary files /dev/null and b/fixtures/300x1-red.jpeg differ diff --git a/fixtures/50x1000-teal.jpeg b/fixtures/50x1000-teal.jpeg new file mode 100644 index 0000000000..e809323c27 Binary files /dev/null and b/fixtures/50x1000-teal.jpeg differ diff --git a/styleguide.config.js b/styleguide.config.js index 7c2eea7d6b..ea2955031a 100644 --- a/styleguide.config.js +++ b/styleguide.config.js @@ -163,7 +163,7 @@ module.exports = { }, { // To test handling of attachments, we need arraybuffers in memory - test: /\.(gif|mp3|mp4|txt)$/, + test: /\.(gif|mp3|mp4|txt|jpg|jpeg|png)$/, loader: 'arraybuffer-loader', }, ], diff --git a/ts/components/conversation/Message.md b/ts/components/conversation/Message.md index 262ec7db4d..aeaa9e119e 100644 --- a/ts/components/conversation/Message.md +++ b/ts/components/conversation/Message.md @@ -120,6 +120,125 @@ const View = Whisper.MessageView; ``` +#### Image with portrait aspect ratio + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + sent_at: Date.now() - 18000000, + attachments: [{ + data: util.portraitYellow, + fileName: 'portraitYellow.png', + contentType: 'image/png', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550003', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + + +#### Image with portrait aspect ratio and caption + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + body: 'This is an odd yellow bar. Cool, huh?', + sent_at: Date.now() - 18000000, + attachments: [{ + data: util.portraitYellow, + fileName: 'portraitYellow.png', + contentType: 'image/png', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550003', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + +#### Image with landscape aspect ratio + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + sent_at: Date.now() - 18000000, + attachments: [{ + data: util.landscapePurple, + fileName: 'landscapePurple.jpg', + contentType: 'image/jpeg', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550003', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + +#### Image with landscape aspect ratio and caption + +```jsx +const outgoing = new Whisper.Message({ + type: 'outgoing', + body: "An interesting horizontal bar. It's art.", + sent_at: Date.now() - 18000000, + attachments: [{ + data: util.landscapePurple, + fileName: 'landscapePurple.jpg', + contentType: 'image/jpeg', + }], +}); +const incoming = new Whisper.Message(Object.assign({}, outgoing.attributes, { + source: '+12025550003', + type: 'incoming', +})); +const View = Whisper.MessageView; + + + + +``` + #### Video with caption ```jsx diff --git a/ts/styleguide/StyleGuideUtil.ts b/ts/styleguide/StyleGuideUtil.ts index 7b0dfd99d6..abd6948225 100644 --- a/ts/styleguide/StyleGuideUtil.ts +++ b/ts/styleguide/StyleGuideUtil.ts @@ -41,6 +41,23 @@ const txtObjectUrl = makeObjectUrl(txt, 'text/plain'); import mp4 from '../../fixtures/pixabay-Soap-Bubble-7141.mp4'; const mp4ObjectUrl = makeObjectUrl(mp4, 'video/mp4'); +// @ts-ignore +import landscapeGreen from '../../fixtures/1000x50-green.jpeg'; +const landscapeGreenObjectUrl = makeObjectUrl(landscapeGreen, 'image/jpeg'); +// @ts-ignore +import landscapePurple from '../../fixtures/200x50-purple.png'; +const landscapePurpleObjectUrl = makeObjectUrl(landscapePurple, 'image/png'); +// @ts-ignore +import portraitYellow from '../../fixtures/20x200-yellow.png'; +const portraitYellowObjectUrl = makeObjectUrl(portraitYellow, 'image/png'); +// @ts-ignore +import landscapeRed from '../../fixtures/300x1-red.jpeg'; +const landscapeRedObjectUrl = makeObjectUrl(landscapeRed, 'image/png'); +// @ts-ignore +import portraitTeal from '../../fixtures/50x1000-teal.jpeg'; +const portraitTealObjectUrl = makeObjectUrl(portraitTeal, 'image/png'); + + function makeObjectUrl(data: ArrayBuffer, contentType: string): string { const blob = new Blob([data], { type: contentType, @@ -59,6 +76,16 @@ export { mp4ObjectUrl, txt, txtObjectUrl, + landscapeGreen, + landscapeGreenObjectUrl, + landscapePurple, + landscapePurpleObjectUrl, + portraitYellow, + portraitYellowObjectUrl, + landscapeRed, + landscapeRedObjectUrl, + portraitTeal, + portraitTealObjectUrl, ourNumber, };