Move the metadata badges to use react functional components
parent
8cc2cd6581
commit
4c0a988fe5
@ -0,0 +1,84 @@
|
|||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { nonNullish } from '../../../session/utils/String';
|
||||||
|
|
||||||
|
type BadgeProps = {
|
||||||
|
badge: string;
|
||||||
|
direction: string;
|
||||||
|
withImageNoCaption: boolean;
|
||||||
|
children?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
const BadgeText = styled.span<BadgeProps>`
|
||||||
|
font-weight: bold;
|
||||||
|
padding-inline-end: 5px;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 16px;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
user-select: none;
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: ${props => props.theme.common.animations.defaultDuration};
|
||||||
|
color: ${props =>
|
||||||
|
props.withImageNoCaption ? 'white' : props.theme.colors.textColor};
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const BadgeSeparator = styled.span<{ withImageNoCaption: boolean }>`
|
||||||
|
margin-top: -2px;
|
||||||
|
color: ${props =>
|
||||||
|
props.withImageNoCaption ? 'white' : props.theme.colors.textColor};
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: ${props => props.theme.common.animations.defaultDuration};
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const MetadataBadge = (props: BadgeProps): JSX.Element => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<BadgeSeparator {...props}> • </BadgeSeparator>
|
||||||
|
<BadgeText {...props} children={props.badge} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
type BadgesProps = {
|
||||||
|
id: string;
|
||||||
|
direction: string;
|
||||||
|
isPublic?: boolean;
|
||||||
|
senderIsModerator?: boolean;
|
||||||
|
withImageNoCaption: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MetadataBadges = (props: BadgesProps): JSX.Element => {
|
||||||
|
const {
|
||||||
|
id,
|
||||||
|
direction,
|
||||||
|
isPublic,
|
||||||
|
senderIsModerator,
|
||||||
|
withImageNoCaption,
|
||||||
|
} = props;
|
||||||
|
const badges = [
|
||||||
|
(isPublic && 'Public') || null,
|
||||||
|
(senderIsModerator && 'Mod') || null,
|
||||||
|
].filter(nonNullish);
|
||||||
|
|
||||||
|
if (!badges || badges.length === 0) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const badgesElements = badges.map(badgeText => (
|
||||||
|
<MetadataBadge
|
||||||
|
key={`${id}-${badgeText}`}
|
||||||
|
badge={badgeText}
|
||||||
|
direction={direction}
|
||||||
|
withImageNoCaption={withImageNoCaption}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
||||||
|
return <>{badgesElements}</>;
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
date: string;
|
||||||
|
direction: string;
|
||||||
|
withImageNoCaption: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MetadataDate = (props: Props) => {
|
||||||
|
return <></>;
|
||||||
|
};
|
@ -0,0 +1,30 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
SessionIcon,
|
||||||
|
SessionIconSize,
|
||||||
|
SessionIconType,
|
||||||
|
} from '../../session/icon';
|
||||||
|
|
||||||
|
export const MetadataSpacer = styled.span`
|
||||||
|
flex-grow: 1;
|
||||||
|
`;
|
||||||
|
/* .session-icon.check {
|
||||||
|
@include themify($themes) {
|
||||||
|
fill: subtle(themed("sentMessageText"));
|
||||||
|
} */
|
||||||
|
|
||||||
|
const MessageReadReceiptContainer = styled.div`
|
||||||
|
margin-inline-start: 5px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const MessageReadReceipt = () => {
|
||||||
|
return (
|
||||||
|
<MessageReadReceiptContainer>
|
||||||
|
<SessionIcon
|
||||||
|
iconType={SessionIconType.Check}
|
||||||
|
iconSize={SessionIconSize.Small}
|
||||||
|
/>
|
||||||
|
</MessageReadReceiptContainer>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue