Add input to creation (#194)
* Add input to chat creation * Set chat min-width
This commit is contained in:
parent
4eac832295
commit
e76eb76ef6
|
@ -125,6 +125,7 @@ const Bubble = styled.div`
|
||||||
|
|
||||||
const Drag = styled.div`
|
const Drag = styled.div`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
min-width: 375px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
|
|
|
@ -14,6 +14,9 @@ import { CrossIcon } from "../Icons/CrossIcon";
|
||||||
import { Member } from "../Members/Member";
|
import { Member } from "../Members/Member";
|
||||||
import { SearchBlock } from "../SearchBlock";
|
import { SearchBlock } from "../SearchBlock";
|
||||||
import { textMediumStyles } from "../Text";
|
import { textMediumStyles } from "../Text";
|
||||||
|
|
||||||
|
import { ChatInput } from "./ChatInput";
|
||||||
|
|
||||||
interface ChatCreationProps {
|
interface ChatCreationProps {
|
||||||
setEditGroup?: (val: boolean) => void;
|
setEditGroup?: (val: boolean) => void;
|
||||||
activeChannel?: ChannelData;
|
activeChannel?: ChannelData;
|
||||||
|
@ -153,6 +156,9 @@ export function ChatCreation({
|
||||||
</ContactsList>
|
</ContactsList>
|
||||||
</Contacts>
|
</Contacts>
|
||||||
)}
|
)}
|
||||||
|
{!activeChannel && (
|
||||||
|
<ChatInput createChat={createChat} group={styledGroup} />
|
||||||
|
)}
|
||||||
</CreationWrapper>
|
</CreationWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -255,6 +261,8 @@ const CloseButton = styled.button`
|
||||||
const Contacts = styled.div`
|
const Contacts = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ContactsHeading = styled.p`
|
const ContactsHeading = styled.p`
|
||||||
|
|
|
@ -7,6 +7,7 @@ import React, {
|
||||||
} from "react";
|
} from "react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
import { ChatState, useChatState } from "../../contexts/chatStateProvider";
|
||||||
import { useIdentity } from "../../contexts/identityProvider";
|
import { useIdentity } from "../../contexts/identityProvider";
|
||||||
import { useMessengerContext } from "../../contexts/messengerProvider";
|
import { useMessengerContext } from "../../contexts/messengerProvider";
|
||||||
import { useModal } from "../../contexts/modalProvider";
|
import { useModal } from "../../contexts/modalProvider";
|
||||||
|
@ -31,13 +32,21 @@ import { textMediumStyles, textSmallStyles } from "../Text";
|
||||||
import { EmojiPicker } from "./EmojiPicker";
|
import { EmojiPicker } from "./EmojiPicker";
|
||||||
|
|
||||||
interface ChatInputProps {
|
interface ChatInputProps {
|
||||||
reply: Reply | undefined;
|
reply?: Reply | undefined;
|
||||||
setReply: (val: Reply | undefined) => void;
|
setReply?: (val: Reply | undefined) => void;
|
||||||
|
createChat?: (group: string[]) => void;
|
||||||
|
group?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChatInput({ reply, setReply }: ChatInputProps) {
|
export function ChatInput({
|
||||||
|
reply,
|
||||||
|
setReply,
|
||||||
|
createChat,
|
||||||
|
group,
|
||||||
|
}: ChatInputProps) {
|
||||||
const narrow = useNarrow();
|
const narrow = useNarrow();
|
||||||
const identity = useIdentity();
|
const identity = useIdentity();
|
||||||
|
const setChatState = useChatState()[1];
|
||||||
const disabled = useMemo(() => !identity, [identity]);
|
const disabled = useMemo(() => !identity, [identity]);
|
||||||
const { sendMessage, contacts } = useMessengerContext();
|
const { sendMessage, contacts } = useMessengerContext();
|
||||||
const [content, setContent] = useState("");
|
const [content, setContent] = useState("");
|
||||||
|
@ -119,7 +128,11 @@ export function ChatInput({ reply, setReply }: ChatInputProps) {
|
||||||
inputRef.current.innerHTML = "";
|
inputRef.current.innerHTML = "";
|
||||||
}
|
}
|
||||||
setContent("");
|
setContent("");
|
||||||
setReply(undefined);
|
if (setReply) setReply(undefined);
|
||||||
|
if (createChat && group) {
|
||||||
|
createChat(group);
|
||||||
|
setChatState(ChatState.ChatBody);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[content, imageUint]
|
[content, imageUint]
|
||||||
|
@ -245,7 +258,11 @@ export function ChatInput({ reply, setReply }: ChatInputProps) {
|
||||||
</ReplyTo>
|
</ReplyTo>
|
||||||
<ReplyOn>{reply.content}</ReplyOn>
|
<ReplyOn>{reply.content}</ReplyOn>
|
||||||
{reply.image && <ImagePreview src={reply.image} />}
|
{reply.image && <ImagePreview src={reply.image} />}
|
||||||
<CloseButton onClick={() => setReply(undefined)}>
|
<CloseButton
|
||||||
|
onClick={() => {
|
||||||
|
if (setReply) setReply(undefined);
|
||||||
|
}}
|
||||||
|
>
|
||||||
{" "}
|
{" "}
|
||||||
<ClearSvg width={20} height={20} className="input" />
|
<ClearSvg width={20} height={20} className="input" />
|
||||||
</CloseButton>
|
</CloseButton>
|
||||||
|
|
|
@ -139,7 +139,7 @@ const Topbar = styled.div`
|
||||||
const ChannelWrapper = styled.div`
|
const ChannelWrapper = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
max-width: 85%;
|
max-width: 80%;
|
||||||
|
|
||||||
&.narrow {
|
&.narrow {
|
||||||
width: calc(100% - 46px);
|
width: calc(100% - 46px);
|
||||||
|
|
Loading…
Reference in New Issue