Fix UI for GIFs in groups
This commit is contained in:
parent
a7799a74c1
commit
6c56d5a5f1
6 changed files with 137 additions and 76 deletions
|
@ -20,6 +20,8 @@ export type Props = {
|
|||
|
||||
height?: number;
|
||||
width?: number;
|
||||
cropWidth?: number;
|
||||
cropHeight?: number;
|
||||
tabIndex?: number;
|
||||
|
||||
overlayText?: string;
|
||||
|
@ -158,6 +160,8 @@ export class Image extends React.Component<Props> {
|
|||
theme,
|
||||
url,
|
||||
width = 0,
|
||||
cropWidth = 0,
|
||||
cropHeight = 0,
|
||||
} = this.props;
|
||||
|
||||
const { caption, pending } = attachment || { caption: null, pending: true };
|
||||
|
@ -204,8 +208,10 @@ export class Image extends React.Component<Props> {
|
|||
curveTopLeft ? 'module-image--curved-top-left' : null,
|
||||
curveTopRight ? 'module-image--curved-top-right' : null,
|
||||
smallCurveTopLeft ? 'module-image--small-curved-top-left' : null,
|
||||
softCorners ? 'module-image--soft-corners' : null
|
||||
softCorners ? 'module-image--soft-corners' : null,
|
||||
cropWidth || cropHeight ? 'module-image--cropped' : null
|
||||
)}
|
||||
style={{ width: width - cropWidth, height: height - cropHeight }}
|
||||
>
|
||||
{pending ? (
|
||||
this.renderPending()
|
||||
|
|
|
@ -34,6 +34,8 @@ export type Props = {
|
|||
onClick?: (attachment: AttachmentType) => void;
|
||||
};
|
||||
|
||||
const GAP = 1;
|
||||
|
||||
export const ImageGrid = ({
|
||||
attachments,
|
||||
bottomOverlay,
|
||||
|
@ -113,8 +115,9 @@ export const ImageGrid = ({
|
|||
curveTopLeft={curveTopLeft}
|
||||
curveBottomLeft={curveBottomLeft}
|
||||
playIconOverlay={isVideoAttachment(attachments[0])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
cropWidth={GAP}
|
||||
url={getThumbnailUrl(attachments[0])}
|
||||
onClick={onClick}
|
||||
onError={onError}
|
||||
|
@ -129,8 +132,8 @@ export const ImageGrid = ({
|
|||
curveTopRight={curveTopRight}
|
||||
curveBottomRight={curveBottomRight}
|
||||
playIconOverlay={isVideoAttachment(attachments[1])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
attachment={attachments[1]}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
onClick={onClick}
|
||||
|
@ -155,7 +158,8 @@ export const ImageGrid = ({
|
|||
attachment={attachments[0]}
|
||||
playIconOverlay={isVideoAttachment(attachments[0])}
|
||||
height={200}
|
||||
width={199}
|
||||
width={200}
|
||||
cropWidth={GAP}
|
||||
url={getUrl(attachments[0])}
|
||||
onClick={onClick}
|
||||
onError={onError}
|
||||
|
@ -167,8 +171,9 @@ export const ImageGrid = ({
|
|||
theme={theme}
|
||||
blurHash={attachments[1].blurHash}
|
||||
curveTopRight={curveTopRight}
|
||||
height={99}
|
||||
width={99}
|
||||
height={100}
|
||||
width={100}
|
||||
cropHeight={GAP}
|
||||
attachment={attachments[1]}
|
||||
playIconOverlay={isVideoAttachment(attachments[1])}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
|
@ -183,8 +188,8 @@ export const ImageGrid = ({
|
|||
bottomOverlay={withBottomOverlay}
|
||||
noBorder={false}
|
||||
curveBottomRight={curveBottomRight}
|
||||
height={99}
|
||||
width={99}
|
||||
height={100}
|
||||
width={100}
|
||||
attachment={attachments[2]}
|
||||
playIconOverlay={isVideoAttachment(attachments[2])}
|
||||
url={getThumbnailUrl(attachments[2])}
|
||||
|
@ -210,8 +215,10 @@ export const ImageGrid = ({
|
|||
noBorder={false}
|
||||
attachment={attachments[0]}
|
||||
playIconOverlay={isVideoAttachment(attachments[0])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
cropHeight={GAP}
|
||||
cropWidth={GAP}
|
||||
url={getThumbnailUrl(attachments[0])}
|
||||
onClick={onClick}
|
||||
onError={onError}
|
||||
|
@ -224,8 +231,9 @@ export const ImageGrid = ({
|
|||
curveTopRight={curveTopRight}
|
||||
playIconOverlay={isVideoAttachment(attachments[1])}
|
||||
noBorder={false}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
cropHeight={GAP}
|
||||
attachment={attachments[1]}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
onClick={onClick}
|
||||
|
@ -242,8 +250,9 @@ export const ImageGrid = ({
|
|||
noBorder={false}
|
||||
curveBottomLeft={curveBottomLeft}
|
||||
playIconOverlay={isVideoAttachment(attachments[2])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
cropWidth={GAP}
|
||||
attachment={attachments[2]}
|
||||
url={getThumbnailUrl(attachments[2])}
|
||||
onClick={onClick}
|
||||
|
@ -258,8 +267,8 @@ export const ImageGrid = ({
|
|||
noBorder={false}
|
||||
curveBottomRight={curveBottomRight}
|
||||
playIconOverlay={isVideoAttachment(attachments[3])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
attachment={attachments[3]}
|
||||
url={getThumbnailUrl(attachments[3])}
|
||||
onClick={onClick}
|
||||
|
@ -288,8 +297,9 @@ export const ImageGrid = ({
|
|||
curveTopLeft={curveTopLeft}
|
||||
attachment={attachments[0]}
|
||||
playIconOverlay={isVideoAttachment(attachments[0])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
cropWidth={GAP}
|
||||
url={getThumbnailUrl(attachments[0])}
|
||||
onClick={onClick}
|
||||
onError={onError}
|
||||
|
@ -301,8 +311,8 @@ export const ImageGrid = ({
|
|||
blurHash={attachments[1].blurHash}
|
||||
curveTopRight={curveTopRight}
|
||||
playIconOverlay={isVideoAttachment(attachments[1])}
|
||||
height={149}
|
||||
width={149}
|
||||
height={150}
|
||||
width={150}
|
||||
attachment={attachments[1]}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
onClick={onClick}
|
||||
|
@ -319,8 +329,9 @@ export const ImageGrid = ({
|
|||
noBorder={isSticker}
|
||||
curveBottomLeft={curveBottomLeft}
|
||||
playIconOverlay={isVideoAttachment(attachments[2])}
|
||||
height={99}
|
||||
width={99}
|
||||
height={100}
|
||||
width={100}
|
||||
cropWidth={GAP}
|
||||
attachment={attachments[2]}
|
||||
url={getThumbnailUrl(attachments[2])}
|
||||
onClick={onClick}
|
||||
|
@ -334,8 +345,9 @@ export const ImageGrid = ({
|
|||
bottomOverlay={withBottomOverlay}
|
||||
noBorder={isSticker}
|
||||
playIconOverlay={isVideoAttachment(attachments[3])}
|
||||
height={99}
|
||||
width={98}
|
||||
height={100}
|
||||
width={100}
|
||||
cropWidth={GAP}
|
||||
attachment={attachments[3]}
|
||||
url={getThumbnailUrl(attachments[3])}
|
||||
onClick={onClick}
|
||||
|
@ -350,8 +362,8 @@ export const ImageGrid = ({
|
|||
noBorder={isSticker}
|
||||
curveBottomRight={curveBottomRight}
|
||||
playIconOverlay={isVideoAttachment(attachments[4])}
|
||||
height={99}
|
||||
width={99}
|
||||
height={100}
|
||||
width={100}
|
||||
darkOverlay={moreMessagesOverlay}
|
||||
overlayText={moreMessagesOverlayText}
|
||||
attachment={attachments[4]}
|
||||
|
|
|
@ -720,43 +720,52 @@ story.add('Image', () => {
|
|||
return renderBothDirections(props);
|
||||
});
|
||||
|
||||
story.add('Multiple Images', () => {
|
||||
const props = createProps({
|
||||
attachments: [
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
],
|
||||
status: 'sent',
|
||||
});
|
||||
for (let i = 2; i <= 5; i += 1) {
|
||||
story.add(`Multiple Images x${i}`, () => {
|
||||
const props = createProps({
|
||||
attachments: [
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
{
|
||||
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
||||
fileName: 'tina-rolf-269345-unsplash.jpg',
|
||||
contentType: IMAGE_JPEG,
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
].slice(0, i),
|
||||
status: 'sent',
|
||||
});
|
||||
|
||||
return renderBothDirections(props);
|
||||
});
|
||||
return renderBothDirections(props);
|
||||
});
|
||||
}
|
||||
|
||||
story.add('Image with Caption', () => {
|
||||
const props = createProps({
|
||||
|
@ -794,6 +803,25 @@ story.add('GIF', () => {
|
|||
return renderBothDirections(props);
|
||||
});
|
||||
|
||||
story.add('GIF in a group', () => {
|
||||
const props = createProps({
|
||||
attachments: [
|
||||
{
|
||||
contentType: VIDEO_MP4,
|
||||
flags: SignalService.AttachmentPointer.Flags.GIF,
|
||||
fileName: 'cat-gif.mp4',
|
||||
url: '/fixtures/cat-gif.mp4',
|
||||
width: 400,
|
||||
height: 332,
|
||||
},
|
||||
],
|
||||
conversationType: 'group',
|
||||
status: 'sent',
|
||||
});
|
||||
|
||||
return renderBothDirections(props);
|
||||
});
|
||||
|
||||
story.add('Not Downloaded GIF', () => {
|
||||
const props = createProps({
|
||||
attachments: [
|
||||
|
|
|
@ -1662,8 +1662,8 @@ export class Message extends React.Component<Props, State> {
|
|||
|
||||
if (attachments && attachments.length) {
|
||||
if (isGIF(attachments)) {
|
||||
// Message container border + image border
|
||||
return GIF_SIZE + 4;
|
||||
// Message container border
|
||||
return GIF_SIZE + 2;
|
||||
}
|
||||
|
||||
if (isSticker) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue