feat: improved styling between states

pull/2660/head
William Grant 3 years ago
parent 1ff9f7b91e
commit 46a88990a3

@ -328,7 +328,6 @@
display: inline-flex; display: inline-flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
height: 48px;
max-width: 100%; max-width: 100%;
} }

@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Avatar, AvatarSize } from '../avatar/Avatar'; import { Avatar, AvatarSize } from '../avatar/Avatar';
@ -230,7 +230,8 @@ const CallButton = () => {
iconType="phone" iconType="phone"
iconSize="large" iconSize="large"
iconPadding="2px" iconPadding="2px"
margin="0 10px 0 0" // negative margin to keep conversation header title centered
margin="0 10px 0 -32px"
onClick={() => { onClick={() => {
void callRecipient(selectedConvoKey, canCall); void callRecipient(selectedConvoKey, canCall);
}} }}
@ -243,6 +244,7 @@ export const StyledSubtitleContainer = styled.div`
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 0 auto;
min-width: 230px; min-width: 230px;
div:first-child { div:first-child {
@ -257,9 +259,9 @@ const StyledSubtitleDot = styled.span<{ active: boolean }>`
background-color: ${props => background-color: ${props =>
props.active ? 'var(--text-primary-color)' : 'var(--text-secondary-color)'}; props.active ? 'var(--text-primary-color)' : 'var(--text-secondary-color)'};
height: 6px; height: 5px;
width: 6px; width: 5px;
margin: 0 3px; margin: 0 2px;
`; `;
const SubtitleDotMenu = ({ const SubtitleDotMenu = ({
@ -327,6 +329,7 @@ const ConversationHeaderTitle = () => {
const { i18n } = window; const { i18n } = window;
const subtitles: Array<string> = [];
const notificationSubtitle = notificationSetting const notificationSubtitle = notificationSetting
? i18n('notificationSubtitle', [notificationSetting]) ? i18n('notificationSubtitle', [notificationSetting])
: null; : null;
@ -339,36 +342,38 @@ const ConversationHeaderTitle = () => {
memberCount = members.length; memberCount = members.length;
} }
} }
if (notificationSubtitle) {
subtitles.push(notificationSubtitle);
}
let memberCountSubtitle = null; let memberCountSubtitle = null;
if (isGroup && memberCount > 0 && !isKickedFromGroup) { if (isGroup && memberCount > 0 && !isKickedFromGroup) {
const count = String(memberCount); const count = String(memberCount);
memberCountSubtitle = isPublic ? i18n('activeMembers', [count]) : i18n('members', [count]); memberCountSubtitle = isPublic ? i18n('activeMembers', [count]) : i18n('members', [count]);
} }
if (memberCountSubtitle) {
subtitles.push(memberCountSubtitle);
}
const disappearingMessageSettingText = const disappearingMessageSettingText =
expirationType === 'off' expirationType === 'off'
? window.i18n('disappearingMessagesModeOff') ? null
: expirationType === 'deleteAfterRead' : expirationType === 'deleteAfterRead'
? window.i18n('disappearingMessagesModeAfterRead') ? window.i18n('disappearingMessagesModeAfterRead')
: window.i18n('disappearingMessagesModeAfterSend'); : window.i18n('disappearingMessagesModeAfterSend');
const abbreviatedExpireTime = Boolean(expireTimer) const abbreviatedExpireTime = Boolean(expireTimer)
? ExpirationTimerOptions.getAbbreviated(expireTimer) ? ExpirationTimerOptions.getAbbreviated(expireTimer)
: null; : null;
const disappearingMessageSubtitle = `${disappearingMessageSettingText}${ const disappearingMessageSubtitle = disappearingMessageSettingText
? `${disappearingMessageSettingText}${
abbreviatedExpireTime ? ` - ${abbreviatedExpireTime}` : '' abbreviatedExpireTime ? ` - ${abbreviatedExpireTime}` : ''
}`; }`
: null;
const subtitles = [ if (disappearingMessageSubtitle) {
notificationSubtitle && notificationSubtitle, subtitles.push(disappearingMessageSubtitle);
memberCountSubtitle && memberCountSubtitle, }
disappearingMessageSubtitle && disappearingMessageSubtitle,
];
window.log.info(`WIP: subtitles`, subtitles);
// const fullTextSubtitle = memberCountText window.log.info(`WIP: subtitles`, subtitles, visibleTitleIndex);
// ? `${memberCountText} ● ${notificationSubtitle}`
// : `${notificationSubtitle}`;
const handleTitleCycle = (direction: 1 | -1) => { const handleTitleCycle = (direction: 1 | -1) => {
let newIndex = visibleTitleIndex + direction; let newIndex = visibleTitleIndex + direction;
@ -385,6 +390,10 @@ const ConversationHeaderTitle = () => {
} }
}; };
useEffect(() => {
setVisibleTitleIndex(0);
}, [convoName]);
if (isMe) { if (isMe) {
// TODO customise for new disappearing message system // TODO customise for new disappearing message system
return <div className="module-conversation-header__title">{i18n('noteToSelf')}</div>; return <div className="module-conversation-header__title">{i18n('noteToSelf')}</div>;
@ -407,15 +416,22 @@ const ConversationHeaderTitle = () => {
}} }}
role="button" role="button"
> >
<span className="module-contact-name__profile-name" data-testid="header-conversation-name"> <span
className="module-contact-name__profile-name"
data-testid="header-conversation-name"
style={{
marginBottom:
subtitles && subtitles[visibleTitleIndex] && subtitles.length > 1 ? '-5px' : undefined,
}}
>
{convoName} {convoName}
</span> </span>
{subtitles && ( {subtitles && subtitles[visibleTitleIndex] && (
<StyledSubtitleContainer> <StyledSubtitleContainer>
<Flex <Flex
container={true} container={true}
flexDirection={'row'} flexDirection={'row'}
justifyContent={'space-between'} justifyContent={subtitles.length < 2 ? 'center' : 'space-between'}
alignItems={'center'} alignItems={'center'}
width={'100%'} width={'100%'}
> >
@ -428,8 +444,9 @@ const ConversationHeaderTitle = () => {
onClick={() => { onClick={() => {
handleTitleCycle(-1); handleTitleCycle(-1);
}} }}
isHidden={subtitles.length < 2}
/> />
{visibleTitleIndex === 2 && ( {visibleTitleIndex === 2 && expirationType !== 'off' && (
<SessionIconButton <SessionIconButton
iconColor={'var(--button-icon-stroke-selected-color)'} iconColor={'var(--button-icon-stroke-selected-color)'}
iconSize={'tiny'} iconSize={'tiny'}
@ -449,12 +466,13 @@ const ConversationHeaderTitle = () => {
onClick={() => { onClick={() => {
handleTitleCycle(1); handleTitleCycle(1);
}} }}
isHidden={subtitles.length < 2}
/> />
</Flex> </Flex>
<SubtitleDotMenu <SubtitleDotMenu
options={subtitles} options={subtitles}
selectedOptionIndex={visibleTitleIndex} selectedOptionIndex={visibleTitleIndex}
style={{ margin: 'var(--margins-xs) 0' }} style={{ visibility: subtitles.length < 2 ? 'hidden' : undefined, margin: '3px 0' }}
/> />
</StyledSubtitleContainer> </StyledSubtitleContainer>
)} )}

Loading…
Cancel
Save