Add an Outgoing Message Status react component

pull/1381/head
Audric Ackermann 4 years ago
parent 788cb2a5fc
commit 0a6a49eda5

@ -4,7 +4,7 @@
<title>double check</title>
<desc>Created with Sketch.</desc>
<defs>
<path d="M7.91731278,0.313257194 C7.58941091,0.549084144 7.28273546,0.812570593 7.00070199,1.10030099 C6.67734551,1.03453102 6.34268082,1 6,1 C3.24,1 1,3.24 1,6 C1,8.76 3.24,11 6,11 C6.34268082,11 6.67734551,10.965469 7.00070199,10.899699 C7.28273546,11.1874294 7.58941091,11.4509159 7.91731278,11.6867428 C7.31518343,11.8898758 6.67037399,12 6,12 C2.688,12 0,9.312 0,6 C0,2.688 2.688,0 6,0 C6.67037399,0 7.31518343,0.110124239 7.91731278,0.313257194 Z M5.07266453,7.01233547 C5.12977459,7.4065842 5.21974274,7.79019382 5.33970233,8.16029767 L5,8.5 L2.5,6 L3.205,5.295 L5,7.085 L5.07266453,7.01233547 Z M12,0 C15.312,0 18,2.688 18,6 C18,9.312 15.312,12 12,12 C8.688,12 6,9.312 6,6 C6,2.688 8.688,0 12,0 Z M12,1 C9.24,1 7,3.24 7,6 C7,8.76 9.24,11 12,11 C14.76,11 17,8.76 17,6 C17,3.24 14.76,1 12,1 Z M11,8.5 L8.5,6 L9.205,5.295 L11,7.085 L14.795,3.29 L15.5,4 L11,8.5 Z" id="path-1"></path>
<path d="" id="path-1"></path>
</defs>
<g id="Android-Light" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Android-Light/Message/Status/Delivered">

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 784 B

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" version="1.1" width="12px" height="12px">
<g id="surface1">
<path style=" " d="M 6.570313 1 L 6.328125 2.289063 C 5.398438 2.5625 4.570313 3.046875 3.890625 3.695313 L 2.652344 3.261719 L 1.222656 5.738281 L 2.210938 6.585938 C 2.097656 7.042969 2 7.507813 2 8 C 2 8.492188 2.097656 8.957031 2.210938 9.414063 L 1.222656 10.261719 L 2.652344 12.738281 L 3.886719 12.300781 C 4.570313 12.957031 5.398438 13.4375 6.328125 13.714844 L 6.570313 15 L 9.429688 15 L 9.671875 13.714844 C 10.601563 13.4375 11.429688 12.953125 12.109375 12.300781 L 13.34375 12.738281 L 14.777344 10.261719 L 13.785156 9.414063 C 13.898438 8.957031 14 8.492188 14 8 C 14 7.507813 13.902344 7.042969 13.789063 6.585938 L 14.777344 5.738281 L 13.347656 3.261719 L 12.113281 3.695313 C 11.429688 3.042969 10.601563 2.5625 9.671875 2.289063 L 9.429688 1 Z M 7.398438 2 L 8.601563 2 L 8.796875 3.054688 L 9.117188 3.132813 C 10.109375 3.359375 10.984375 3.878906 11.65625 4.597656 L 11.878906 4.835938 L 12.894531 4.480469 L 13.496094 5.519531 L 12.683594 6.21875 L 12.78125 6.53125 C 12.921875 6.992188 13 7.488281 13 8 C 13 8.511719 12.921875 9.003906 12.78125 9.46875 L 12.683594 9.78125 L 13.496094 10.480469 L 12.894531 11.519531 L 11.878906 11.160156 L 11.65625 11.402344 C 10.984375 12.121094 10.109375 12.640625 9.117188 12.871094 L 8.796875 12.941406 L 8.601563 14 L 7.398438 14 L 7.203125 12.941406 L 6.882813 12.871094 C 5.890625 12.640625 5.015625 12.121094 4.34375 11.402344 L 4.117188 11.160156 L 3.101563 11.519531 L 2.503906 10.480469 L 3.316406 9.78125 L 3.21875 9.46875 C 3.078125 9.007813 3 8.511719 3 8 C 3 7.488281 3.078125 6.992188 3.21875 6.53125 L 3.316406 6.21875 L 2.503906 5.519531 L 3.101563 4.480469 L 4.121094 4.835938 L 4.34375 4.597656 C 5.015625 3.878906 5.890625 3.359375 6.882813 3.132813 L 7.203125 3.054688 Z M 8 5 C 6.347656 5 5 6.347656 5 8 C 5 9.652344 6.347656 11 8 11 C 9.652344 11 11 9.652344 11 8 C 11 6.347656 9.652344 5 8 5 Z M 8 6 C 9.109375 6 10 6.890625 10 8 C 10 9.109375 9.109375 10 8 10 C 6.890625 10 6 9.109375 6 8 C 6 6.890625 6.890625 6 8 6 Z "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

@ -4,7 +4,7 @@
<title>Icons/Read/read-18x12</title>
<desc>Created with Sketch.</desc>
<defs>
<path d="M7.91731278,0.313257194 C6.15053376,1.58392424 5,3.65760134 5,6 C5,6.343797 5.0247846,6.68180525 5.07266453,7.01233547 L5,7.085 L3.205,5.295 L2.5,6 L5,8.5 L5.33970233,8.16029767 C5.80439817,9.59399486 6.71914823,10.8250231 7.91731278,11.6867428 C7.31518343,11.8898758 6.67037399,12 6,12 C2.688,12 0,9.312 0,6 C0,2.688 2.688,0 6,0 C6.67037399,0 7.31518343,0.110124239 7.91731278,0.313257194 Z M12,0 C15.312,0 18,2.688 18,6 C18,9.312 15.312,12 12,12 C8.688,12 6,9.312 6,6 C6,2.688 8.688,0 12,0 Z M11,8.5 L15.5,4 L14.795,3.29 L11,7.085 L9.205,5.295 L8.5,6 L11,8.5 Z" id="path-1"></path>
<path d="" id="path-1"></path>
<rect id="path-3" x="0" y="0" width="18" height="12"></rect>
</defs>
<g id="Icons/Read/read-18x12" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1015 B

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="12px" height="12px" viewBox="0 0 12 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>sending</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="iOS-Light" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="iOS-Light/Message/Status/Sending" transform="translate(-6.000000, 0.000000)" fill="#000000">
<path d="M11.5,0 L12.5,0 L12.5,1 L11.5,1 L11.5,0 Z M11.5,11 L12.5,11 L12.5,12 L11.5,12 L11.5,11 Z M6,5.5 L7,5.5 L7,6.5 L6,6.5 L6,5.5 Z M17,5.5 L18,5.5 L18,6.5 L17,6.5 L17,5.5 Z M16.9461524,2.5669873 L17.4461524,3.4330127 L16.580127,3.9330127 L16.080127,3.0669873 L16.9461524,2.5669873 Z M7.41987298,8.0669873 L7.91987298,8.9330127 L7.05384758,9.4330127 L6.55384758,8.5669873 L7.41987298,8.0669873 Z M9.4330127,0.553847577 L9.9330127,1.41987298 L9.0669873,1.91987298 L8.5669873,1.05384758 L9.4330127,0.553847577 Z M14.9330127,10.080127 L15.4330127,10.9461524 L14.5669873,11.4461524 L14.0669873,10.580127 L14.9330127,10.080127 Z M14.5669873,0.553847577 L15.4330127,1.05384758 L14.9330127,1.91987298 L14.0669873,1.41987298 L14.5669873,0.553847577 Z M9.0669873,10.080127 L9.9330127,10.580127 L9.4330127,11.4461524 L8.5669873,10.9461524 L9.0669873,10.080127 Z M7.05384758,2.5669873 L7.91987298,3.0669873 L7.41987298,3.9330127 L6.55384758,3.4330127 L7.05384758,2.5669873 Z M16.580127,8.0669873 L17.4461524,8.5669873 L16.9461524,9.4330127 L16.080127,8.9330127 L16.580127,8.0669873 Z" id="sending"></path>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

@ -92,7 +92,6 @@
'reply.svg',
'save.svg',
'search.svg',
'sending.svg',
'shield.svg',
'signal-laptop.png',
'signal-phone.png',

@ -437,23 +437,6 @@
margin-inline-start: 5px;
}
.module-message__metadata__status-icon--sending {
@include color-svg('../images/sending.svg', $color-gray-60);
animation: module-message__metdata__status-icon--spinning 4s linear infinite;
}
.module-message__metadata__status-icon--pow {
@include color-svg('../images/pow.svg', $color-gray-60);
animation: module-message__metdata__status-icon--spinning 4s linear infinite;
}
@keyframes module-message__metdata__status-icon--spinning {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.module-message__metadata__status-icon--sent {
@include color-svg('../images/check-circle-outline.svg', $color-gray-60);
}
@ -1148,44 +1131,6 @@
font-weight: 300;
}
.module-message-detail__contact__status-icon {
min-width: 12px;
min-height: 12px;
width: 12px;
height: 12px;
display: inline-block;
margin-bottom: 2px;
margin-inline-start: 5px;
}
.module-message-detail__contact__status-icon--sending {
@include color-svg('../images/sending.svg', $color-gray-60);
animation: module-message-detail__contact__status-icon--spinning 4s linear
infinite;
}
@keyframes module-message-detail__contact__status-icon--spinning {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.module-message-detail__contact__status-icon--sent {
@include color-svg('../images/check-circle-outline.svg', $color-gray-60);
}
.module-message-detail__contact__status-icon--delivered {
@include color-svg('../images/double-check.svg', $color-gray-60);
width: 18px;
}
.module-message-detail__contact__status-icon--read {
@include color-svg('../images/read.svg', $color-gray-60);
width: 18px;
}
.module-message-detail__contact__status-icon--error {
@include color-svg('../images/error.svg', $session-color-danger);
}
.module-message-detail__contact__unidentified-delivery-icon {
margin-inline-start: 6px;
margin-inline-end: 10px;
@ -1551,25 +1496,6 @@
margin-inline-start: 6px;
}
.module-conversation-list-item__message__status-icon--sending {
@include color-svg('../images/sending.svg', $color-light-35);
animation: module-conversation-list-item__message__status-icon--spinning 4s
linear infinite;
}
.module-conversation-list-item__message__status-icon--pow {
@include color-svg('../images/session/gear.svg', $color-light-35);
animation: module-conversation-list-item__message__status-icon--spinning 4s
linear infinite;
}
@keyframes module-conversation-list-item__message__status-icon--spinning {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.module-conversation-list-item__message__status-icon--sent {
@include color-svg('../images/check-circle-outline.svg', $color-light-35);
}
@ -1587,94 +1513,6 @@
// Module: Main Header
.module-main-header {
display: flex;
flex-direction: column;
border-bottom: 1px solid $color-dark-90;
color: $color-dark-05;
}
.module-main-header__title {
height: 55px;
padding-inline-start: 16px;
flex: 1;
flex-direction: row;
display: flex;
align-items: center;
cursor: pointer;
&:hover {
background-color: $color-dark-75;
}
}
.module-main-header__menu {
color: $color-dark-05;
overflow: hidden;
.accordian {
margin-top: -100%;
transition: margin-top 0.35s ease-out;
&.expanded {
margin-top: 0;
}
}
.menu-item {
padding: 12px;
background-color: $color-dark-90;
user-select: none;
cursor: pointer;
&:hover {
background-color: $color-dark-75;
}
}
}
.module-main-header-content-toggle {
width: 3em;
line-height: 3em;
font-weight: bold;
overflow: hidden;
user-select: none;
color: white;
text-align: center;
&:after {
-webkit-transition: all 0.35s;
-o-transition: all 0.35s;
transition: all 0.35s;
width: 3em;
line-height: 3em;
height: 3em;
content: '\25BE';
display: inline-block;
}
}
.module-main-header-content-toggle-visible::after {
transform: rotate(180deg);
}
.module-main-header__contact-name {
font-weight: 300;
margin-inline-start: 12px;
color: $color-dark-05;
overflow-x: auto;
flex: 1;
}
.module-main-header__search {
margin: 8px;
position: relative;
}
.module-main-header__search__icon {
background-color: $color-light-35;
}
.module-main-header__search__input {
color: $color-dark-05;
background-color: $color-gray-95;
@ -1702,41 +1540,6 @@
}
}
.module-main-header__search__icon {
content: '';
display: inline-block;
width: 18px;
height: 26px;
background-color: $color-light-35;
position: absolute;
left: 14px;
top: 3px;
cursor: text;
@include color-svg('../images/search.svg', $color-gray-60);
}
.module-main-header__search__cancel-icon {
position: absolute;
right: 16px;
top: 9px;
height: 14px;
width: 14px;
cursor: pointer;
@include color-svg('../images/x-16.svg', $color-gray-60);
}
.module-main-header__search__copy-from-clipboard {
position: absolute;
right: 16px;
top: 5px;
width: 20px;
height: 22px;
opacity: 0.8;
cursor: pointer;
@include color-svg('../images/icon-paste.svg', $color-gray-60);
}
// Module: Image
.module-image {

@ -509,22 +509,6 @@
color: $color-gray-05;
}
.module-conversation-list-item__message__status-icon--sending {
@include color-svg('../images/sending.svg', $color-light-35);
}
.module-conversation-list-item__message__status-icon--sent {
@include color-svg('../images/check-circle-outline.svg', $color-light-35);
}
.module-conversation-list-item__message__status-icon--delivered {
@include color-svg('../images/double-check.svg', $color-light-35);
width: 18px;
}
.module-conversation-list-item__message__status-icon--read {
@include color-svg('../images/read.svg', $color-light-35);
width: 18px;
}
// Module: Main Header
.module-main-header__search__input {
@ -543,10 +527,6 @@
}
}
.module-main-header__search__cancel-icon {
@include color-svg('../images/x-16.svg', $color-gray-25);
}
// Module: Image
.module-image {

@ -38,10 +38,10 @@ import _ from 'lodash';
import { animation, contextMenu, Item, Menu } from 'react-contexify';
import uuid from 'uuid';
import { InView } from 'react-intersection-observer';
import { MetadataBadge, MetadataBadges } from './message/MetadataBadge';
import { nonNullish } from '../../session/utils/String';
import { MetadataBadges } from './message/MetadataBadge';
import { MetadataSpacer } from './message/MetadataUtilComponent';
import { DefaultTheme, withTheme } from 'styled-components';
import { OutgoingMessageStatus } from './message/OutgoingMessageStatus';
// Same as MIN_WIDTH in ImageGrid.tsx
const MINIMUM_LINK_PREVIEW_IMAGE_WIDTH = 200;
@ -226,7 +226,6 @@ class MessageInner extends React.PureComponent<Props, State> {
);
}
// tslint:disable-next-line: cyclomatic-complexity
public renderMetadata() {
const {
collapseMetadata,
@ -243,21 +242,13 @@ class MessageInner extends React.PureComponent<Props, State> {
if (collapseMetadata) {
return null;
}
const isOutgoing = direction === 'outgoing';
const isShowingImage = this.isShowingImage();
const withImageNoCaption = Boolean(!text && isShowingImage);
const showError = status === 'error' && direction === 'outgoing';
const showSentNoErrors =
!bodyPending &&
direction === 'outgoing' &&
status !== 'error' &&
status !== 'sending' &&
status !== 'pow';
const showSending =
!bodyPending &&
direction === 'outgoing' &&
(status === 'sending' || status === 'pow');
const showError = status === 'error' && isOutgoing;
const showStatus = Boolean(!bodyPending && status?.length && isOutgoing);
return (
<div
className={classNames(
@ -298,25 +289,13 @@ class MessageInner extends React.PureComponent<Props, State> {
/>
) : null}
<MetadataSpacer />
{bodyPending ? (
<div className="module-message__metadata__spinner-container">
<Spinner size="mini" direction={direction} />
</div>
) : null}
{bodyPending ? <Spinner size="mini" direction={direction} /> : null}
<MetadataSpacer />
{showSending ? (
<div
className={classNames(
'module-message-detail__contact__status-icon',
'module-message-detail__contact__status-icon--sending'
)}
/>
) : null}
{showSentNoErrors ? (
<SessionIcon
iconType={SessionIconType.Check}
iconSize={SessionIconSize.Small}
{showStatus ? (
<OutgoingMessageStatus
withImageNoCaption={withImageNoCaption}
theme={this.props.theme}
status={status}
/>
) : null}
</div>

@ -0,0 +1,126 @@
import React from 'react';
import styled, { DefaultTheme } from 'styled-components';
import {
SessionIcon,
SessionIconSize,
SessionIconType,
} from '../../session/icon';
const MessageStatusSendingContainer = styled.div`
min-width: 12px;
min-height: 12px;
width: 12px;
height: 12px;
display: inline-block;
margin-bottom: 2px;
margin-inline-start: 5px;
`;
const MessageStatusSending = (props: {
theme: DefaultTheme;
withImageNoCaption: boolean;
}) => {
const iconColor = props.withImageNoCaption ? 'white' : undefined;
return (
<MessageStatusSendingContainer>
<SessionIcon
rotateDuration={2}
iconColor={iconColor}
theme={props.theme}
iconType={SessionIconType.Sending}
iconSize={SessionIconSize.Tiny}
/>
</MessageStatusSendingContainer>
);
};
const MessageStatusSent = (props: {
theme: DefaultTheme;
withImageNoCaption: boolean;
}) => {
const iconColor = props.withImageNoCaption ? 'white' : undefined;
return (
<MessageStatusSendingContainer>
<SessionIcon
iconColor={iconColor}
theme={props.theme}
iconType={SessionIconType.CircleCheck}
iconSize={SessionIconSize.Small}
/>
</MessageStatusSendingContainer>
);
};
const MessageStatusDelivered = (props: {
theme: DefaultTheme;
withImageNoCaption: boolean;
}) => {
const iconColor = props.withImageNoCaption ? 'white' : undefined;
return (
<MessageStatusSendingContainer>
<SessionIcon
iconColor={iconColor}
theme={props.theme}
iconType={SessionIconType.DoubleCheck}
iconSize={SessionIconSize.Small}
/>
</MessageStatusSendingContainer>
);
};
const MessageStatusRead = (props: {
theme: DefaultTheme;
withImageNoCaption: boolean;
}) => {
const iconColor = props.withImageNoCaption ? 'white' : undefined;
return (
<MessageStatusSendingContainer>
<SessionIcon
iconColor={iconColor}
theme={props.theme}
iconType={SessionIconType.Read}
iconSize={SessionIconSize.Small}
/>
</MessageStatusSendingContainer>
);
};
const MessageStatusError = (props: {
theme: DefaultTheme;
withImageNoCaption: boolean;
}) => {
return (
<MessageStatusSendingContainer>
<SessionIcon
iconColor={props.theme.colors.destructive}
theme={props.theme}
iconType={SessionIconType.Error}
iconSize={SessionIconSize.Small}
/>
</MessageStatusSendingContainer>
);
};
export const OutgoingMessageStatus = (props: {
status?: 'sending' | 'sent' | 'delivered' | 'read' | 'error' | 'pow';
theme: DefaultTheme;
withImageNoCaption: boolean;
}) => {
switch (props.status) {
case 'pow':
case 'sending':
return <MessageStatusSending {...props} />;
case 'sent':
return <MessageStatusSent {...props} />;
case 'delivered':
return <MessageStatusDelivered {...props} />;
case 'read':
return <MessageStatusRead {...props} />;
case 'error':
return <MessageStatusError {...props} />;
default:
return null;
}
};

@ -36,9 +36,13 @@ export enum SessionIconType {
Users = 'users',
Upload = 'upload',
Warning = 'warning',
Sending = 'sending',
DoubleCheck = 'doubleCheck',
Read = 'read',
}
export enum SessionIconSize {
Tiny = 'tiny',
Small = 'small',
Medium = 'medium',
Large = 'large',
@ -79,7 +83,7 @@ export const icons = {
[SessionIconType.CircleCheck]: {
path:
'M4.77,7.61c-0.15-0.15-0.38-0.15-0.53,0c-0.15,0.15-0.15,0.38,0,0.53l1.88,1.88c0.15,0.15,0.38,0.15,0.53,0 l4.13-4.12c0.15-0.15,0.15-0.38,0-0.53c-0.15-0.15-0.38-0.15-0.53,0L6.38,9.22L4.77,7.61z',
viewBox: '0 0 15 15',
viewBox: '4 4 7 7',
},
[SessionIconType.CircleCheckFilled]: {
path:
@ -231,4 +235,19 @@ export const icons = {
'M243.225,333.382c-13.6,0-25,11.4-25,25s11.4,25,25,25c13.1,0,25-11.4,24.4-24.4 C268.225,344.682,256.925,333.382,243.225,333.382z M474.625,421.982c15.7-27.1,15.8-59.4,0.2-86.4l-156.6-271.2c-15.5-27.3-43.5-43.5-74.9-43.5s-59.4,16.3-74.9,43.4 l-156.8,271.5c-15.6,27.3-15.5,59.8,0.3,86.9c15.6,26.8,43.5,42.9,74.7,42.9h312.8 C430.725,465.582,458.825,449.282,474.625,421.982z M440.625,402.382c-8.7,15-24.1,23.9-41.3,23.9h-312.8 c-17,0-32.3-8.7-40.8-23.4c-8.6-14.9-8.7-32.7-0.1-47.7l156.8-271.4c8.5-14.9,23.7-23.7,40.9-23.7c17.1,0,32.4,8.9,40.9,23.8 l156.7,271.4C449.325,369.882,449.225,387.482,440.625,402.382z M237.025,157.882c-11.9,3.4-19.3,14.2-19.3,27.3c0.6,7.9,1.1,15.9,1.7,23.8c1.7,30.1,3.4,59.6,5.1,89.7 c0.6,10.2,8.5,17.6,18.7,17.6c10.2,0,18.2-7.9,18.7-18.2c0-6.2,0-11.9,0.6-18.2c1.1-19.3,2.3-38.6,3.4-57.9 c0.6-12.5,1.7-25,2.3-37.5c0-4.5-0.6-8.5-2.3-12.5C260.825,160.782,248.925,155.082,237.025,157.882z',
viewBox: '0 0 486.463 486.463',
},
[SessionIconType.Sending]: {
path:
'M11.5,0 L12.5,0 L12.5,1 L11.5,1 L11.5,0 Z M11.5,11 L12.5,11 L12.5,12 L11.5,12 L11.5,11 Z M6,5.5 L7,5.5 L7,6.5 L6,6.5 L6,5.5 Z M17,5.5 L18,5.5 L18,6.5 L17,6.5 L17,5.5 Z M16.9461524,2.5669873 L17.4461524,3.4330127 L16.580127,3.9330127 L16.080127,3.0669873 L16.9461524,2.5669873 Z M7.41987298,8.0669873 L7.91987298,8.9330127 L7.05384758,9.4330127 L6.55384758,8.5669873 L7.41987298,8.0669873 Z M9.4330127,0.553847577 L9.9330127,1.41987298 L9.0669873,1.91987298 L8.5669873,1.05384758 L9.4330127,0.553847577 Z M14.9330127,10.080127 L15.4330127,10.9461524 L14.5669873,11.4461524 L14.0669873,10.580127 L14.9330127,10.080127 Z M14.5669873,0.553847577 L15.4330127,1.05384758 L14.9330127,1.91987298 L14.0669873,1.41987298 L14.5669873,0.553847577 Z M9.0669873,10.080127 L9.9330127,10.580127 L9.4330127,11.4461524 L8.5669873,10.9461524 L9.0669873,10.080127 Z M7.05384758,2.5669873 L7.91987298,3.0669873 L7.41987298,3.9330127 L6.55384758,3.4330127 L7.05384758,2.5669873 Z M16.580127,8.0669873 L17.4461524,8.5669873 L16.9461524,9.4330127 L16.080127,8.9330127 L16.580127,8.0669873 Z',
viewBox: '6 0 12 12',
},
[SessionIconType.DoubleCheck]: {
path:
'M7.91731278,0.313257194 C7.58941091,0.549084144 7.28273546,0.812570593 7.00070199,1.10030099 C6.67734551,1.03453102 6.34268082,1 6,1 C3.24,1 1,3.24 1,6 C1,8.76 3.24,11 6,11 C6.34268082,11 6.67734551,10.965469 7.00070199,10.899699 C7.28273546,11.1874294 7.58941091,11.4509159 7.91731278,11.6867428 C7.31518343,11.8898758 6.67037399,12 6,12 C2.688,12 0,9.312 0,6 C0,2.688 2.688,0 6,0 C6.67037399,0 7.31518343,0.110124239 7.91731278,0.313257194 Z M5.07266453,7.01233547 C5.12977459,7.4065842 5.21974274,7.79019382 5.33970233,8.16029767 L5,8.5 L2.5,6 L3.205,5.295 L5,7.085 L5.07266453,7.01233547 Z M12,0 C15.312,0 18,2.688 18,6 C18,9.312 15.312,12 12,12 C8.688,12 6,9.312 6,6 C6,2.688 8.688,0 12,0 Z M12,1 C9.24,1 7,3.24 7,6 C7,8.76 9.24,11 12,11 C14.76,11 17,8.76 17,6 C17,3.24 14.76,1 12,1 Z M11,8.5 L8.5,6 L9.205,5.295 L11,7.085 L14.795,3.29 L15.5,4 L11,8.5 Z',
viewBox: '6 0 12 12',
},
[SessionIconType.Read]: {
path:
'M7.91731278,0.313257194 C6.15053376,1.58392424 5,3.65760134 5,6 C5,6.343797 5.0247846,6.68180525 5.07266453,7.01233547 L5,7.085 L3.205,5.295 L2.5,6 L5,8.5 L5.33970233,8.16029767 C5.80439817,9.59399486 6.71914823,10.8250231 7.91731278,11.6867428 C7.31518343,11.8898758 6.67037399,12 6,12 C2.688,12 0,9.312 0,6 C0,2.688 2.688,0 6,0 C6.67037399,0 7.31518343,0.110124239 7.91731278,0.313257194 Z M12,0 C15.312,0 18,2.688 18,6 C18,9.312 15.312,12 12,12 C8.688,12 6,9.312 6,6 C6,2.688 8.688,0 12,0 Z M11,8.5 L15.5,4 L14.795,3.29 L11,7.085 L9.205,5.295 L8.5,6 L11,8.5 Z',
viewBox: '6 0 12 12',
},
};

@ -1,13 +1,14 @@
import React from 'react';
import { icons, SessionIconSize, SessionIconType } from '../icon';
import styled, { DefaultTheme } from 'styled-components';
import styled, { css, DefaultTheme, keyframes } from 'styled-components';
export type SessionIconProps = {
iconType: SessionIconType;
iconSize: SessionIconSize | number;
iconColor?: string;
iconRotation?: number;
rotateDuration?: number;
theme: DefaultTheme;
};
@ -16,6 +17,8 @@ const getIconDimensionFromIconSize = (iconSize: SessionIconSize | number) => {
return iconSize;
} else {
switch (iconSize) {
case SessionIconSize.Tiny:
return '12';
case SessionIconSize.Small:
return '15';
case SessionIconSize.Medium:
@ -36,13 +39,36 @@ type StyledSvgProps = {
width: string | number;
height: string | number;
iconRotation: number;
rotateDuration?: number;
};
const rotate = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
`;
const animation = (props: any) => {
if (props.rotateDuration) {
return css`
${rotate} ${props.rotateDuration}s infinite linear;
`;
} else {
return;
}
};
//tslint:disable no-unnecessary-callback-wrapper
const Svg = styled.svg<StyledSvgProps>`
width: ${props => props.width};
height: ${props => props.height};
animation: ${props => animation(props)};
transform: ${props => `rotate(${props.iconRotation}deg)`};
`;
//tslint:enable no-unnecessary-callback-wrapper
const SessionSvg = (props: {
viewBox: string;
@ -51,9 +77,11 @@ const SessionSvg = (props: {
height: string | number;
iconRotation: number;
iconColor?: string;
rotateDuration?: number;
theme: DefaultTheme;
}) => {
const colorSvg = props.iconColor || props?.theme?.colors.textColor || 'red';
return (
<Svg {...props}>
<path fill={colorSvg} d={props.path} />
@ -62,15 +90,13 @@ const SessionSvg = (props: {
};
export const SessionIcon = (props: SessionIconProps) => {
const { iconType, iconColor, theme } = props;
const { iconType, iconColor, theme, rotateDuration } = props;
let { iconSize, iconRotation } = props;
iconSize = iconSize || SessionIconSize.Medium;
// default to whatever the text color is near this svg
iconRotation = iconRotation || 0;
const iconDimensions = getIconDimensionFromIconSize(iconSize);
const iconDef = icons[iconType];
// const themeContext = useContext(ThemeContext);
if (!theme) {
window.log.error('Missing theme props in SessionIcon');
@ -82,6 +108,7 @@ export const SessionIcon = (props: SessionIconProps) => {
path={iconDef.path}
width={iconDimensions}
height={iconDimensions}
rotateDuration={rotateDuration}
iconRotation={iconRotation}
iconColor={iconColor}
theme={theme}

Loading…
Cancel
Save