feat: converted quote image to styled components

remove border on quote if there is an attachment
pull/2757/head
William Grant 2 years ago
parent bf170e6e77
commit f0aeb59d54

@ -48,7 +48,7 @@ export const MessageQuote = (props: Props) => {
referencedMessageNotFound, referencedMessageNotFound,
} = quote; } = quote;
const quoteText = text || window.i18n('originalMessageNotFound'); const quoteText = text || null;
const quoteNotFound = referencedMessageNotFound || false; const quoteNotFound = referencedMessageNotFound || false;
const shortenedPubkey = PubKey.shorten(quoteAuthor); const shortenedPubkey = PubKey.shorten(quoteAuthor);

@ -11,6 +11,7 @@ import { QuoteGenericFile } from './QuoteGenericFile';
import { QuoteText } from './QuoteText'; import { QuoteText } from './QuoteText';
import { QuoteIconContainer } from './QuoteIconContainer'; import { QuoteIconContainer } from './QuoteIconContainer';
import styled from 'styled-components'; import styled from 'styled-components';
import { isEmpty } from 'lodash';
export type QuotePropsWithoutListener = { export type QuotePropsWithoutListener = {
attachment?: QuotedAttachmentType; attachment?: QuotedAttachmentType;
@ -54,6 +55,7 @@ function validateQuote(quote: QuotePropsWithoutListener): boolean {
} }
const StyledQuote = styled.div<{ const StyledQuote = styled.div<{
hasAttachment: boolean;
isIncoming: boolean; isIncoming: boolean;
onClick: ((e: MouseEvent<HTMLDivElement>) => void) | undefined; onClick: ((e: MouseEvent<HTMLDivElement>) => void) | undefined;
}>` }>`
@ -63,11 +65,11 @@ const StyledQuote = styled.div<{
flex-direction: row; flex-direction: row;
align-items: stretch; align-items: stretch;
overflow: hidden; overflow: hidden;
border-left: 4px solid ${props => !props.hasAttachment && 'border-left: 4px solid;'}
${props => border-color: ${props =>
props.isIncoming props.isIncoming
? 'var(--message-bubbles-received-text-color)' ? 'var(--message-bubbles-received-text-color)'
: 'var(--message-bubbles-sent-text-color)'}; : 'var(--message-bubbles-sent-text-color)'};
cursor: ${props => (props.onClick ? 'pointer' : 'auto')}; cursor: ${props => (props.onClick ? 'pointer' : 'auto')};
`; `;
@ -87,7 +89,12 @@ export const Quote = (props: QuotePropsWithListener) => {
return ( return (
<div className={classNames('module-quote-container')}> <div className={classNames('module-quote-container')}>
<StyledQuote isIncoming={isIncoming} onClick={onClick} role="button"> <StyledQuote
hasAttachment={Boolean(!isEmpty(attachment))}
isIncoming={isIncoming}
onClick={onClick}
role="button"
>
<QuoteIconContainer <QuoteIconContainer
attachment={attachment} attachment={attachment}
handleImageErrorBound={handleImageErrorBound} handleImageErrorBound={handleImageErrorBound}

@ -2,6 +2,22 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { useDisableDrag } from '../../../../../hooks/useDisableDrag'; import { useDisableDrag } from '../../../../../hooks/useDisableDrag';
import { useEncryptedFileFetch } from '../../../../../hooks/useEncryptedFileFetch'; import { useEncryptedFileFetch } from '../../../../../hooks/useEncryptedFileFetch';
import styled from 'styled-components';
const StyledQuoteImage = styled.div`
flex: initial;
min-width: 54px;
width: 54px;
max-height: 54px;
position: relative;
border-radius: 4px;
overflow: hidden;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
`;
export const QuoteImage = (props: { export const QuoteImage = (props: {
handleImageErrorBound: () => void; handleImageErrorBound: () => void;
@ -29,7 +45,7 @@ export const QuoteImage = (props: {
) : null; ) : null;
return ( return (
<div className="module-quote__icon-container"> <StyledQuoteImage>
<img <img
src={srcData} src={srcData}
alt={window.i18n('quoteThumbnailAlt')} alt={window.i18n('quoteThumbnailAlt')}
@ -37,6 +53,6 @@ export const QuoteImage = (props: {
onError={handleImageErrorBound} onError={handleImageErrorBound}
/> />
{iconElement} {iconElement}
</div> </StyledQuoteImage>
); );
}; };

Loading…
Cancel
Save