Fix creation mode alignment (#195)

This commit is contained in:
Maria Rushkova 2022-01-19 14:22:56 +01:00 committed by GitHub
parent e76eb76ef6
commit f5dd23ce97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 93 deletions

View File

@ -21,7 +21,7 @@ const BackBtn = styled.button`
left: 0; left: 0;
top: 8px; top: 8px;
width: 32px; width: 32px;
height: 32px; height: 44px;
padding: 0; padding: 0;
&.narrow { &.narrow {

View File

@ -134,7 +134,7 @@ export function ChatBody({ onClick, showMembers, permission }: ChatBodyProps) {
return <ChatBodyLoading />; return <ChatBodyLoading />;
} }
const Wrapper = styled.div` export const Wrapper = styled.div`
width: 61%; width: 61%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -15,6 +15,7 @@ import { Member } from "../Members/Member";
import { SearchBlock } from "../SearchBlock"; import { SearchBlock } from "../SearchBlock";
import { textMediumStyles } from "../Text"; import { textMediumStyles } from "../Text";
import { Wrapper } from "./ChatBody";
import { ChatInput } from "./ChatInput"; import { ChatInput } from "./ChatInput";
interface ChatCreationProps { interface ChatCreationProps {
@ -82,84 +83,91 @@ export function ChatCreation({
); );
return ( return (
<CreationWrapper> <Wrapper>
<CreationBar> <CreationWrapper>
{narrow && ( <CreationBar className={`${styledGroup.length === 5 && "limit"}`}>
<BackButton {narrow && (
onBtnClick={() => setChatState(ChatState.ChatBody)} <BackButton
className="narrow" onBtnClick={() => setChatState(ChatState.ChatBody)}
/> className="narrow"
)} />
<InputBar className={`${narrow && "narrow"}`}>
<InputText>To:</InputText>
<StyledList className={`${narrow && "narrow"}`}>
{styledGroup.map((member) => (
<StyledMember key={member}>
<StyledName>{member.slice(0, 10)}</StyledName>
<CloseButton onClick={() => removeMember(member)}>
<CrossIcon memberView={true} />
</CloseButton>
</StyledMember>
))}
</StyledList>
{styledGroup.length < 5 && (
<SearchMembers>
<Input
value={query}
onInput={(e) => setQuery(e.currentTarget.value)}
/>
<SearchBlock
query={query}
discludeList={styledGroup}
onClick={addMember}
/>
</SearchMembers>
)} )}
{styledGroup.length === 5 && ( <Column className={`${narrow && "narrow"}`}>
<LimitAlert>5 user Limit reached</LimitAlert> <InputBar>
)} <InputText>To:</InputText>
</InputBar> <StyledList>
<CreationBtn {styledGroup.map((member) => (
disabled={styledGroup.length === 0} <StyledMember key={member}>
onClick={() => { <StyledName>{member.slice(0, 10)}</StyledName>
if (!activeChannel) { <CloseButton onClick={() => removeMember(member)}>
createChat(styledGroup); <CrossIcon memberView={true} />
} else { </CloseButton>
addMembers(styledGroup, activeChannel.id); </StyledMember>
}
setEditGroup?.(false);
}}
>
Confirm
</CreationBtn>
{!narrow && <ActivityButton className="creation" />}
</CreationBar>
{!setEditGroup && !query && (
<Contacts>
<ContactsHeading>Contacts</ContactsHeading>
<ContactsList>
{identity &&
Object.values(contacts)
.filter(
(e) =>
e.id != bufToHex(identity.publicKey) &&
!styledGroup.includes(e.id)
)
.map((contact) => (
<Member
key={contact.id}
contact={contact}
isOnline={contact.online}
onClick={() => addMember(contact.id)}
/>
))} ))}
</ContactsList> </StyledList>
</Contacts> {styledGroup.length < 5 && (
)} <SearchMembers>
{!activeChannel && ( <Input
<ChatInput createChat={createChat} group={styledGroup} /> value={query}
)} onInput={(e) => setQuery(e.currentTarget.value)}
</CreationWrapper> />
<SearchBlock
query={query}
discludeList={styledGroup}
onClick={addMember}
/>
</SearchMembers>
)}
{!narrow && styledGroup.length === 5 && (
<LimitAlert>5 user Limit reached</LimitAlert>
)}
</InputBar>
{narrow && styledGroup.length === 5 && (
<LimitAlert className="narrow">5 user Limit reached</LimitAlert>
)}
</Column>
<CreationBtn
disabled={styledGroup.length === 0}
onClick={() => {
if (!activeChannel) {
createChat(styledGroup);
} else {
addMembers(styledGroup, activeChannel.id);
}
setEditGroup?.(false);
}}
>
Confirm
</CreationBtn>
{!narrow && <ActivityButton className="creation" />}
</CreationBar>
{!setEditGroup && !query && (
<Contacts>
<ContactsHeading>Contacts</ContactsHeading>
<ContactsList>
{identity &&
Object.values(contacts)
.filter(
(e) =>
e.id != bufToHex(identity.publicKey) &&
!styledGroup.includes(e.id)
)
.map((contact) => (
<Member
key={contact.id}
contact={contact}
isOnline={contact.online}
onClick={() => addMember(contact.id)}
/>
))}
</ContactsList>
</Contacts>
)}
{!activeChannel && (
<ChatInput createChat={createChat} group={styledGroup} />
)}
</CreationWrapper>
</Wrapper>
); );
} }
@ -167,6 +175,7 @@ const CreationWrapper = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
height: 100%;
background-color: ${({ theme }) => theme.bodyBackgroundColor}; background-color: ${({ theme }) => theme.bodyBackgroundColor};
padding: 8px 16px; padding: 8px 16px;
`; `;
@ -175,24 +184,35 @@ const CreationBar = styled.div`
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 32px; margin-bottom: 32px;
&.limit {
align-items: flex-start;
}
`;
const Column = styled.div`
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
margin-right: 16px;
overflow-x: hidden;
&.narrow {
}
`; `;
const InputBar = styled.div` const InputBar = styled.div`
display: flex; display: flex;
align-items: center; align-items: center;
flex: 1;
width: 100%; width: 100%;
height: 44px;
background-color: ${({ theme }) => theme.inputColor}; background-color: ${({ theme }) => theme.inputColor};
border: 1px solid ${({ theme }) => theme.inputColor}; border: 1px solid ${({ theme }) => theme.inputColor};
border-radius: 8px; border-radius: 8px;
padding: 8px 16px; padding: 6px 16px;
margin-right: 16px;
${textMediumStyles} ${textMediumStyles}
&.narrow {
overflow-x: hidden;
}
`; `;
const Input = styled.input` const Input = styled.input`
@ -227,13 +247,11 @@ const CreationBtn = styled.button`
const StyledList = styled.div` const StyledList = styled.div`
display: flex; display: flex;
overflow-x: scroll;
margin-right: 8px;
&.narrow { &::-webkit-scrollbar {
overflow-x: scroll; display: none;
&::-webkit-scrollbar {
display: none;
}
} }
`; `;
@ -244,7 +262,10 @@ const StyledMember = styled.div`
background: ${({ theme }) => theme.tertiary}; background: ${({ theme }) => theme.tertiary};
color: ${({ theme }) => theme.bodyBackgroundColor}; color: ${({ theme }) => theme.bodyBackgroundColor};
border-radius: 8px; border-radius: 8px;
margin-right: 8px;
& + & {
margin-left: 8px;
}
`; `;
const StyledName = styled.p` const StyledName = styled.p`
@ -259,6 +280,7 @@ const CloseButton = styled.button`
`; `;
const Contacts = styled.div` const Contacts = styled.div`
height: calc(100% - 44px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1; flex: 1;
@ -285,4 +307,9 @@ const LimitAlert = styled.p`
text-transform: uppercase; text-transform: uppercase;
margin-left: auto; margin-left: auto;
color: ${({ theme }) => theme.redColor}; color: ${({ theme }) => theme.redColor};
white-space: nowrap;
&.narrow {
margin: 8px 0 0;
}
`; `;

View File

@ -217,7 +217,7 @@ export function ChatInput({
); );
return ( return (
<View> <View className={`${createChat && "creation"}`}>
<SizeLimitModal /> <SizeLimitModal />
<EmojiWrapper ref={ref}> <EmojiWrapper ref={ref}>
<EmojiPicker addEmoji={addEmoji} showEmoji={showEmoji} /> <EmojiPicker addEmoji={addEmoji} showEmoji={showEmoji} />
@ -348,6 +348,10 @@ const View = styled.div`
align-items: flex-end; align-items: flex-end;
padding: 6px 8px 6px 10px; padding: 6px 8px 6px 10px;
position: relative; position: relative;
&.creation {
padding: 0;
}
`; `;
const InputArea = styled.div` const InputArea = styled.div`