Message bubble: Larger stickers; handle non-square aspect ratios
* Sticker picker: Handle non-square stickers * Message bubble: Larger stickers; handle non-square aspect ratios
This commit is contained in:
parent
84ea41958c
commit
744d1b5295
5 changed files with 100 additions and 10 deletions
|
@ -5213,7 +5213,7 @@ button.module-image__border-overlay:focus {
|
||||||
&__image,
|
&__image,
|
||||||
&__placeholder {
|
&__placeholder {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__placeholder {
|
&__placeholder {
|
||||||
|
|
|
@ -60,10 +60,10 @@ export class ImageGrid extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachments.length === 1 || !areAllAttachmentsVisual(attachments)) {
|
if (attachments.length === 1 || !areAllAttachmentsVisual(attachments)) {
|
||||||
const { height, width } = getImageDimensions(attachments[0]);
|
const { height, width } = getImageDimensions(
|
||||||
|
attachments[0],
|
||||||
const finalHeight = isSticker ? stickerSize : height;
|
isSticker ? stickerSize : undefined
|
||||||
const finalWidth = isSticker ? stickerSize : width;
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -85,8 +85,8 @@ export class ImageGrid extends React.Component<Props> {
|
||||||
curveBottomRight={curveBottomRight}
|
curveBottomRight={curveBottomRight}
|
||||||
attachment={attachments[0]}
|
attachment={attachments[0]}
|
||||||
playIconOverlay={isVideoAttachment(attachments[0])}
|
playIconOverlay={isVideoAttachment(attachments[0])}
|
||||||
height={finalHeight}
|
height={height}
|
||||||
width={finalWidth}
|
width={width}
|
||||||
url={getUrl(attachments[0])}
|
url={getUrl(attachments[0])}
|
||||||
tabIndex={tabIndex}
|
tabIndex={tabIndex}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
|
|
@ -997,6 +997,92 @@ First set is in a 1:1 conversation, second set is in a group.
|
||||||
</util.ConversationContext>
|
</util.ConversationContext>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Sticker with non-square aspect ratio
|
||||||
|
|
||||||
|
First set is in a 1:1 conversation, second set is in a group.
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
<util.ConversationContext theme={util.theme} ios={util.ios} mode={util.mode}>
|
||||||
|
<div className="module-message-container">
|
||||||
|
<Message
|
||||||
|
authorColor="green"
|
||||||
|
direction="incoming"
|
||||||
|
isSticker={true}
|
||||||
|
timestamp={Date.now()}
|
||||||
|
i18n={util.i18n}
|
||||||
|
attachments={[
|
||||||
|
{
|
||||||
|
url: util.landscapePurpleObjectUrl,
|
||||||
|
contentType: 'image/png',
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
showVisualAttachment={() => console.log('showVisualAttachment')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="module-message-container">
|
||||||
|
<Message
|
||||||
|
authorColor="green"
|
||||||
|
direction="outgoing"
|
||||||
|
isSticker={true}
|
||||||
|
status="sent"
|
||||||
|
timestamp={Date.now()}
|
||||||
|
i18n={util.i18n}
|
||||||
|
attachments={[
|
||||||
|
{
|
||||||
|
url: util.landscapePurpleObjectUrl,
|
||||||
|
contentType: 'image/png',
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
showVisualAttachment={() => console.log('showVisualAttachment')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="module-message-container">
|
||||||
|
<Message
|
||||||
|
authorColor="green"
|
||||||
|
direction="incoming"
|
||||||
|
isSticker={true}
|
||||||
|
authorName="Mr. Sticker"
|
||||||
|
conversationType="group"
|
||||||
|
timestamp={Date.now()}
|
||||||
|
i18n={util.i18n}
|
||||||
|
attachments={[
|
||||||
|
{
|
||||||
|
url: util.landscapePurpleObjectUrl,
|
||||||
|
contentType: 'image/png',
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
showVisualAttachment={() => console.log('showVisualAttachment')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="module-message-container">
|
||||||
|
<Message
|
||||||
|
authorColor="green"
|
||||||
|
direction="outgoing"
|
||||||
|
isSticker={true}
|
||||||
|
conversationType="group"
|
||||||
|
status="sent"
|
||||||
|
timestamp={Date.now()}
|
||||||
|
i18n={util.i18n}
|
||||||
|
attachments={[
|
||||||
|
{
|
||||||
|
url: util.landscapePurpleObjectUrl,
|
||||||
|
contentType: 'image/png',
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
showVisualAttachment={() => console.log('showVisualAttachment')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</util.ConversationContext>
|
||||||
|
```
|
||||||
|
|
||||||
#### Sticker with pending image
|
#### Sticker with pending image
|
||||||
|
|
||||||
A sticker with no attachments (what our selectors produce for a pending sticker) is not displayed at all.
|
A sticker with no attachments (what our selectors produce for a pending sticker) is not displayed at all.
|
||||||
|
|
|
@ -39,7 +39,7 @@ interface Trigger {
|
||||||
|
|
||||||
// Same as MIN_WIDTH in ImageGrid.tsx
|
// Same as MIN_WIDTH in ImageGrid.tsx
|
||||||
const MINIMUM_LINK_PREVIEW_IMAGE_WIDTH = 200;
|
const MINIMUM_LINK_PREVIEW_IMAGE_WIDTH = 200;
|
||||||
const STICKER_SIZE = 128;
|
const STICKER_SIZE = 200;
|
||||||
const SELECTED_TIMEOUT = 1000;
|
const SELECTED_TIMEOUT = 1000;
|
||||||
|
|
||||||
interface LinkPreviewType {
|
interface LinkPreviewType {
|
||||||
|
|
|
@ -166,7 +166,10 @@ type DimensionsType = {
|
||||||
width: number;
|
width: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getImageDimensions(attachment: AttachmentType): DimensionsType {
|
export function getImageDimensions(
|
||||||
|
attachment: AttachmentType,
|
||||||
|
forcedWidth?: number
|
||||||
|
): DimensionsType {
|
||||||
const { height, width } = attachment;
|
const { height, width } = attachment;
|
||||||
if (!height || !width) {
|
if (!height || !width) {
|
||||||
return {
|
return {
|
||||||
|
@ -176,7 +179,8 @@ export function getImageDimensions(attachment: AttachmentType): DimensionsType {
|
||||||
}
|
}
|
||||||
|
|
||||||
const aspectRatio = height / width;
|
const aspectRatio = height / width;
|
||||||
const targetWidth = Math.max(Math.min(MAX_WIDTH, width), MIN_WIDTH);
|
const targetWidth =
|
||||||
|
forcedWidth || Math.max(Math.min(MAX_WIDTH, width), MIN_WIDTH);
|
||||||
const candidateHeight = Math.round(targetWidth * aspectRatio);
|
const candidateHeight = Math.round(targetWidth * aspectRatio);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue