fix: message preview status icon was shrinking due to text overflow

also added session icon improvements from onboarding branch
pull/3099/head
William Grant 1 year ago
parent 009bc18903
commit 12caf66cde

@ -88,7 +88,19 @@ export type SessionIconType =
export type SessionIconSize = 'tiny' | 'small' | 'medium' | 'large' | 'huge' | 'huge2' | 'max'; export type SessionIconSize = 'tiny' | 'small' | 'medium' | 'large' | 'huge' | 'huge2' | 'max';
export const icons: Record<string, { path: string; viewBox: string; ratio: number }> = { export type ClipRule = 'nonzero' | 'evenodd' | 'inherit';
export type FillRule = 'nonzero' | 'evenodd';
type IconProps = {
path: string;
viewBox: string;
ratio: number;
fill?: string;
clipRule?: ClipRule;
fillRule?: FillRule;
};
export const icons: Record<SessionIconType, IconProps> = {
addUser: { addUser: {
path: 'M8.85,2.17c-1.73,0-3.12,1.4-3.12,3.12s1.4,3.12,3.12,3.12c1.73,0,3.13-1.4,3.13-3.12S10.58,2.17,8.85,2.17z M8.85,0.08c2.88,0,5.21,2.33,5.21,5.21s-2.33,5.21-5.21,5.21s-5.2-2.33-5.2-5.21C3.65,2.42,5.98,0.08,8.85,0.08z M20.83,5.29 c0.54,0,0.98,0.41,1.04,0.93l0.01,0.11v2.08h2.08c0.54,0,0.98,0.41,1.04,0.93v0.12c0,0.54-0.41,0.98-0.93,1.04l-0.11,0.01h-2.08 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08h-2.08c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11 c0-0.54,0.41-0.98,0.93-1.04l0.11-0.01h2.08V6.34C19.79,5.76,20.26,5.29,20.83,5.29z M12.5,12.58c2.8,0,5.09,2.21,5.2,4.99v0.22 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08c0-1.67-1.3-3.03-2.95-3.12h-0.18H5.21 c-1.67,0-3.03,1.3-3.12,2.95v0.18v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93L0,19.88V17.8 c0-2.8,2.21-5.09,4.99-5.2h0.22h7.29V12.58z', path: 'M8.85,2.17c-1.73,0-3.12,1.4-3.12,3.12s1.4,3.12,3.12,3.12c1.73,0,3.13-1.4,3.13-3.12S10.58,2.17,8.85,2.17z M8.85,0.08c2.88,0,5.21,2.33,5.21,5.21s-2.33,5.21-5.21,5.21s-5.2-2.33-5.2-5.21C3.65,2.42,5.98,0.08,8.85,0.08z M20.83,5.29 c0.54,0,0.98,0.41,1.04,0.93l0.01,0.11v2.08h2.08c0.54,0,0.98,0.41,1.04,0.93v0.12c0,0.54-0.41,0.98-0.93,1.04l-0.11,0.01h-2.08 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08h-2.08c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11 c0-0.54,0.41-0.98,0.93-1.04l0.11-0.01h2.08V6.34C19.79,5.76,20.26,5.29,20.83,5.29z M12.5,12.58c2.8,0,5.09,2.21,5.2,4.99v0.22 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08c0-1.67-1.3-3.03-2.95-3.12h-0.18H5.21 c-1.67,0-3.03,1.3-3.12,2.95v0.18v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93L0,19.88V17.8 c0-2.8,2.21-5.09,4.99-5.2h0.22h7.29V12.58z',
viewBox: '0 0 25 21', viewBox: '0 0 25 21',

@ -1,7 +1,8 @@
import React from 'react'; import React, { memo } from 'react';
import styled, { css, keyframes } from 'styled-components'; import styled, { css, CSSProperties, keyframes } from 'styled-components';
import { icons, SessionIconSize, SessionIconType } from '.'; import { icons, SessionIconSize, SessionIconType } from '.';
import { ClipRule, FillRule } from './Icons';
export type SessionIconProps = { export type SessionIconProps = {
iconType: SessionIconType; iconType: SessionIconType;
@ -15,6 +16,7 @@ export type SessionIconProps = {
glowStartDelay?: number; glowStartDelay?: number;
noScale?: boolean; noScale?: boolean;
backgroundColor?: string; backgroundColor?: string;
style?: CSSProperties;
dataTestId?: string; dataTestId?: string;
unreadCount?: number; unreadCount?: number;
}; };
@ -55,6 +57,9 @@ type StyledSvgProps = {
noScale?: boolean; noScale?: boolean;
iconColor?: string; iconColor?: string;
backgroundColor?: string; backgroundColor?: string;
fill?: string;
clipRule?: ClipRule;
filleRule?: FillRule;
}; };
const rotate = keyframes` const rotate = keyframes`
@ -119,37 +124,28 @@ const animation = (props: {
return undefined; return undefined;
}; };
const Svg = React.memo(styled.svg<StyledSvgProps>` const Svg = memo(styled.svg<StyledSvgProps>`
width: ${props => props.width}; width: ${props => props.width};
transform: ${props => `rotate(${props.iconRotation}deg)`}; transform: ${props => `rotate(${props.iconRotation}deg)`};
${props => animation(props)}; ${props => animation(props)};
border-radius: ${props => props.borderRadius}; border-radius: ${props => props.borderRadius};
background-color: ${props => background-color: ${props =>
props.backgroundColor ? props.backgroundColor : '--button-icon-background-color'}; props.backgroundColor ? props.backgroundColor : 'var(--button-icon-background-color)'};
border-radius: ${props => (props.borderRadius ? props.borderRadius : '')};
filter: ${props => (props.noScale ? `drop-shadow(0px 0px 4px ${props.iconColor})` : '')}; filter: ${props => (props.noScale ? `drop-shadow(0px 0px 4px ${props.iconColor})` : '')};
fill: ${props => (props.iconColor ? props.iconColor : '--button-icon-stroke-color')}; fill: ${props => (props.iconColor ? props.iconColor : 'var(--button-icon-stroke-color)')};
padding: ${props => (props.iconPadding ? props.iconPadding : '')}; padding: ${props => (props.iconPadding ? props.iconPadding : '')};
transition: inherit; transition: inherit;
`); `);
const SessionSvg = (props: { const SessionSvg = (
viewBox: string; props: StyledSvgProps & {
path: string | Array<string>; viewBox: string;
width: string | number; path: string | Array<string>;
height: string | number; style?: CSSProperties;
iconRotation: number; dataTestId?: string;
iconColor?: string; }
rotateDuration?: number; ) => {
glowDuration?: number; const colorSvg = props.iconColor ? props.iconColor : 'var(--button-icon-stroke-color)';
glowStartDelay?: number;
noScale?: boolean;
borderRadius?: string;
backgroundColor?: string;
iconPadding?: string;
dataTestId?: string;
}) => {
const colorSvg = props.iconColor ? props.iconColor : '--button-icon-stroke-color';
const pathArray = props.path instanceof Array ? props.path : [props.path]; const pathArray = props.path instanceof Array ? props.path : [props.path];
const propsToPick = { const propsToPick = {
width: props.width, width: props.width,
@ -164,6 +160,10 @@ const SessionSvg = (props: {
backgroundColor: props.backgroundColor, backgroundColor: props.backgroundColor,
borderRadius: props.borderRadius, borderRadius: props.borderRadius,
iconPadding: props.iconPadding, iconPadding: props.iconPadding,
fill: props.fill,
clipRule: props.clipRule,
fillRule: props.filleRule,
style: props.style,
dataTestId: props.dataTestId, dataTestId: props.dataTestId,
}; };
@ -187,6 +187,7 @@ export const SessionIcon = (props: SessionIconProps) => {
noScale, noScale,
backgroundColor, backgroundColor,
iconPadding, iconPadding,
style,
dataTestId, dataTestId,
} = props; } = props;
let { iconSize, iconRotation } = props; let { iconSize, iconRotation } = props;
@ -196,6 +197,9 @@ export const SessionIcon = (props: SessionIconProps) => {
const iconDimensions = getIconDimensionFromIconSize(iconSize); const iconDimensions = getIconDimensionFromIconSize(iconSize);
const iconDef = icons[iconType]; const iconDef = icons[iconType];
const ratio = iconDef?.ratio || 1; const ratio = iconDef?.ratio || 1;
const fill = iconDef?.fill || undefined;
const clipRule = iconDef?.clipRule || 'nonzero';
const fillRule = iconDef?.fillRule || 'nonzero';
return ( return (
<SessionSvg <SessionSvg
@ -212,6 +216,10 @@ export const SessionIcon = (props: SessionIconProps) => {
iconColor={iconColor} iconColor={iconColor}
backgroundColor={backgroundColor} backgroundColor={backgroundColor}
iconPadding={iconPadding} iconPadding={iconPadding}
fill={fill}
clipRule={clipRule}
filleRule={fillRule}
style={style}
dataTestId={dataTestId} dataTestId={dataTestId}
/> />
); );

@ -68,13 +68,21 @@ function IconMessageStatus({ status }: { status: LastMessageStatusType }) {
const nonErrorIconColor = 'var(--text-secondary-color'; const nonErrorIconColor = 'var(--text-secondary-color';
switch (status) { switch (status) {
case 'error': case 'error':
return <SessionIcon iconColor={'var(--danger-color'} iconType="error" iconSize="tiny" />; return (
<SessionIcon
iconColor={'var(--danger-color'}
iconType="error"
iconSize="tiny"
style={{ flexShrink: 0 }}
/>
);
case 'read': case 'read':
return ( return (
<SessionIcon <SessionIcon
iconColor={nonErrorIconColor} iconColor={nonErrorIconColor}
iconType="doubleCheckCircleFilled" iconType="doubleCheckCircleFilled"
iconSize="tiny" iconSize="tiny"
style={{ flexShrink: 0 }}
/> />
); );
case 'sending': case 'sending':
@ -84,10 +92,18 @@ function IconMessageStatus({ status }: { status: LastMessageStatusType }) {
iconColor={nonErrorIconColor} iconColor={nonErrorIconColor}
iconType="sending" iconType="sending"
iconSize="tiny" iconSize="tiny"
style={{ flexShrink: 0 }}
/> />
); );
case 'sent': case 'sent':
return <SessionIcon iconColor={nonErrorIconColor} iconType="circleCheck" iconSize="tiny" />; return (
<SessionIcon
iconColor={nonErrorIconColor}
iconType="circleCheck"
iconSize="tiny"
style={{ flexShrink: 0 }}
/>
);
case undefined: case undefined:
return null; return null;
default: default:

Loading…
Cancel
Save