Add dialogues (#93)
This commit is contained in:
parent
093b6ca7be
commit
4711dc620f
|
@ -11,6 +11,7 @@ interface ChannelsProps {
|
||||||
onCommunityClick: (val: ChannelData) => void;
|
onCommunityClick: (val: ChannelData) => void;
|
||||||
activeChannelId: string;
|
activeChannelId: string;
|
||||||
channels: ChannelData[];
|
channels: ChannelData[];
|
||||||
|
membersList: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Channels({
|
export function Channels({
|
||||||
|
@ -19,6 +20,7 @@ export function Channels({
|
||||||
clearNotifications,
|
clearNotifications,
|
||||||
activeChannelId,
|
activeChannelId,
|
||||||
channels,
|
channels,
|
||||||
|
membersList,
|
||||||
}: ChannelsProps) {
|
}: ChannelsProps) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const channel = channels.find((channel) => channel.id === activeChannelId);
|
const channel = channels.find((channel) => channel.id === activeChannelId);
|
||||||
|
@ -47,6 +49,30 @@ export function Channels({
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
{membersList.length > 0 && (
|
||||||
|
<Dialogues>
|
||||||
|
{membersList.map((member) => (
|
||||||
|
<Channel
|
||||||
|
key={member}
|
||||||
|
channel={{
|
||||||
|
id: member,
|
||||||
|
name: member.slice(0, 10),
|
||||||
|
description: "Contact",
|
||||||
|
}}
|
||||||
|
isActive={member === activeChannelId}
|
||||||
|
isMuted={false}
|
||||||
|
onClick={() => {
|
||||||
|
onCommunityClick({
|
||||||
|
id: member,
|
||||||
|
name: member.slice(0, 10),
|
||||||
|
description: "Contact",
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Dialogues>
|
||||||
|
)}
|
||||||
</ChannelList>
|
</ChannelList>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -60,3 +86,23 @@ export const ChannelList = styled.div`
|
||||||
width: 0;
|
width: 0;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const Dialogues = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: 16px;
|
||||||
|
margin-top: 16px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: calc(100% - 24px);
|
||||||
|
height: 1px;
|
||||||
|
background-color: ${({ theme }) => theme.primary};
|
||||||
|
opacity: 0.1;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
|
@ -24,9 +24,17 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
|
||||||
</ChannelLogoEmpty>
|
</ChannelLogoEmpty>
|
||||||
<ChannelNameEmpty className={"active"}>{channel.name}</ChannelNameEmpty>
|
<ChannelNameEmpty className={"active"}>{channel.name}</ChannelNameEmpty>
|
||||||
</ChannelInfoEmpty>
|
</ChannelInfoEmpty>
|
||||||
|
|
||||||
|
{channel.description === "Contact" ? (
|
||||||
|
<EmptyText>
|
||||||
|
Any messages you send here are encrypted and can only be read by you
|
||||||
|
and <span>{channel.name}</span>.
|
||||||
|
</EmptyText>
|
||||||
|
) : (
|
||||||
<EmptyText>
|
<EmptyText>
|
||||||
Welcome to the beginning of the <span>#{channel.name}</span> channel!
|
Welcome to the beginning of the <span>#{channel.name}</span> channel!
|
||||||
</EmptyText>
|
</EmptyText>
|
||||||
|
)}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +70,8 @@ const ChannelNameEmpty = styled(ChannelName)`
|
||||||
const EmptyText = styled.p`
|
const EmptyText = styled.p`
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: ${({ theme }) => theme.secondary};
|
color: ${({ theme }) => theme.secondary};
|
||||||
|
max-width: 310px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
& > span {
|
& > span {
|
||||||
color: ${({ theme }) => theme.primary};
|
color: ${({ theme }) => theme.primary};
|
||||||
|
|
|
@ -36,6 +36,8 @@ export function Chat({
|
||||||
});
|
});
|
||||||
const [showMembers, setShowMembers] = useState(true);
|
const [showMembers, setShowMembers] = useState(true);
|
||||||
const [showChannels, setShowChannels] = useState(true);
|
const [showChannels, setShowChannels] = useState(true);
|
||||||
|
const [membersList, setMembersList] = useState([]);
|
||||||
|
|
||||||
const narrow = useNarrow();
|
const narrow = useNarrow();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -110,6 +112,7 @@ export function Chat({
|
||||||
onCommunityClick={(e) => setActiveChannel(e)}
|
onCommunityClick={(e) => setActiveChannel(e)}
|
||||||
activeChannelId={activeChannel?.id ?? ""}
|
activeChannelId={activeChannel?.id ?? ""}
|
||||||
channels={channels}
|
channels={channels}
|
||||||
|
membersList={membersList}
|
||||||
/>
|
/>
|
||||||
</ChannelsWrapper>
|
</ChannelsWrapper>
|
||||||
)}
|
)}
|
||||||
|
@ -132,9 +135,15 @@ export function Chat({
|
||||||
loadingMessages={loadingMessages}
|
loadingMessages={loadingMessages}
|
||||||
clearNotifications={clearNotifications}
|
clearNotifications={clearNotifications}
|
||||||
channels={channels}
|
channels={channels}
|
||||||
|
membersList={membersList}
|
||||||
|
setMembersList={setMembersList}
|
||||||
/>
|
/>
|
||||||
{showMembers && !narrow && (
|
{showMembers && !narrow && (
|
||||||
<Members community={communityData} setShowChannels={setShowChannels} />
|
<Members
|
||||||
|
community={communityData}
|
||||||
|
setShowChannels={setShowChannels}
|
||||||
|
setMembersList={setMembersList}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<CommunityModal
|
<CommunityModal
|
||||||
isVisible={isModalVisible}
|
isVisible={isModalVisible}
|
||||||
|
|
|
@ -39,6 +39,8 @@ interface ChatBodyProps {
|
||||||
loadingMessages: boolean;
|
loadingMessages: boolean;
|
||||||
clearNotifications: (id: string) => void;
|
clearNotifications: (id: string) => void;
|
||||||
channels: ChannelData[];
|
channels: ChannelData[];
|
||||||
|
membersList: string[];
|
||||||
|
setMembersList: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChatBody({
|
export function ChatBody({
|
||||||
|
@ -60,6 +62,8 @@ export function ChatBody({
|
||||||
loadingMessages,
|
loadingMessages,
|
||||||
clearNotifications,
|
clearNotifications,
|
||||||
channels,
|
channels,
|
||||||
|
membersList,
|
||||||
|
setMembersList,
|
||||||
}: ChatBodyProps) {
|
}: ChatBodyProps) {
|
||||||
const narrow = useNarrow();
|
const narrow = useNarrow();
|
||||||
const [showChannelsList, setShowChannelsList] = useState(false);
|
const [showChannelsList, setShowChannelsList] = useState(false);
|
||||||
|
@ -154,6 +158,7 @@ export function ChatBody({
|
||||||
setShowChannels={setShowChannelsList}
|
setShowChannels={setShowChannelsList}
|
||||||
activeChannelId={activeChannelId}
|
activeChannelId={activeChannelId}
|
||||||
clearNotifications={clearNotifications}
|
clearNotifications={clearNotifications}
|
||||||
|
membersList={membersList}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{showMembersList && narrow && (
|
{showMembersList && narrow && (
|
||||||
|
@ -161,6 +166,7 @@ export function ChatBody({
|
||||||
community={community}
|
community={community}
|
||||||
setShowChannels={setShowChannelsList}
|
setShowChannels={setShowChannelsList}
|
||||||
setShowMembersList={setShowMembersList}
|
setShowMembersList={setShowMembersList}
|
||||||
|
setMembersList={setMembersList}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -7,9 +7,10 @@ import { UserIcon } from "../Icons/UserIcon";
|
||||||
|
|
||||||
interface MemberProps {
|
interface MemberProps {
|
||||||
member: string;
|
member: string;
|
||||||
isOnline: boolean;
|
isOnline?: boolean;
|
||||||
setShowChannels: (val: boolean) => void;
|
setShowChannels: (val: boolean) => void;
|
||||||
setShowMembers?: (val: boolean) => void;
|
setShowMembers?: (val: boolean) => void;
|
||||||
|
setMembersList?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Member({
|
export function Member({
|
||||||
|
@ -17,6 +18,7 @@ export function Member({
|
||||||
isOnline,
|
isOnline,
|
||||||
setShowChannels,
|
setShowChannels,
|
||||||
setShowMembers,
|
setShowMembers,
|
||||||
|
setMembersList,
|
||||||
}: MemberProps) {
|
}: MemberProps) {
|
||||||
const narrow = useNarrow();
|
const narrow = useNarrow();
|
||||||
|
|
||||||
|
@ -25,11 +27,22 @@ export function Member({
|
||||||
if (setShowMembers) setShowMembers(false);
|
if (setShowMembers) setShowMembers(false);
|
||||||
}, [setShowMembers]);
|
}, [setShowMembers]);
|
||||||
|
|
||||||
|
const startDialog = (member: string) => {
|
||||||
|
setMembersList((prevMembers: string[]) => {
|
||||||
|
if (prevMembers.find((chat) => chat === member)) {
|
||||||
|
return prevMembers;
|
||||||
|
} else {
|
||||||
|
return [...prevMembers, member];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setShowChannels(true);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MemberData
|
<MemberData
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
narrow && setShowMembers ? switchMemberList() : setShowChannels(true)
|
narrow && setShowMembers ? switchMemberList() : startDialog(member);
|
||||||
}
|
}}
|
||||||
>
|
>
|
||||||
<MemberIcon
|
<MemberIcon
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -8,13 +8,22 @@ import { MembersList } from "./MembersList";
|
||||||
interface MembersProps {
|
interface MembersProps {
|
||||||
community: CommunityData;
|
community: CommunityData;
|
||||||
setShowChannels: (val: boolean) => void;
|
setShowChannels: (val: boolean) => void;
|
||||||
|
setMembersList: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Members({ community, setShowChannels }: MembersProps) {
|
export function Members({
|
||||||
|
community,
|
||||||
|
setShowChannels,
|
||||||
|
setMembersList,
|
||||||
|
}: MembersProps) {
|
||||||
return (
|
return (
|
||||||
<MembersWrapper>
|
<MembersWrapper>
|
||||||
<MemberHeading>Members</MemberHeading>
|
<MemberHeading>Members</MemberHeading>
|
||||||
<MembersList community={community} setShowChannels={setShowChannels} />
|
<MembersList
|
||||||
|
community={community}
|
||||||
|
setShowChannels={setShowChannels}
|
||||||
|
setMembersList={setMembersList}
|
||||||
|
/>
|
||||||
</MembersWrapper>
|
</MembersWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,14 @@ interface MembersListProps {
|
||||||
community: CommunityData;
|
community: CommunityData;
|
||||||
setShowChannels: (val: boolean) => void;
|
setShowChannels: (val: boolean) => void;
|
||||||
setShowMembers?: (val: boolean) => void;
|
setShowMembers?: (val: boolean) => void;
|
||||||
|
setMembersList: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MembersList({
|
export function MembersList({
|
||||||
community,
|
community,
|
||||||
setShowChannels,
|
setShowChannels,
|
||||||
setShowMembers,
|
setShowMembers,
|
||||||
|
setMembersList,
|
||||||
}: MembersListProps) {
|
}: MembersListProps) {
|
||||||
return (
|
return (
|
||||||
<MembersListWrap>
|
<MembersListWrap>
|
||||||
|
@ -39,6 +41,7 @@ export function MembersList({
|
||||||
isOnline={false}
|
isOnline={false}
|
||||||
setShowChannels={setShowChannels}
|
setShowChannels={setShowChannels}
|
||||||
setShowMembers={setShowMembers}
|
setShowMembers={setShowMembers}
|
||||||
|
setMembersList={setMembersList}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</MemberCategory>
|
</MemberCategory>
|
||||||
|
@ -51,6 +54,7 @@ export function MembersList({
|
||||||
isOnline={false}
|
isOnline={false}
|
||||||
setShowChannels={setShowChannels}
|
setShowChannels={setShowChannels}
|
||||||
setShowMembers={setShowMembers}
|
setShowMembers={setShowMembers}
|
||||||
|
setMembersList={setMembersList}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</MemberCategory>
|
</MemberCategory>
|
||||||
|
|
|
@ -14,6 +14,8 @@ interface NarrowChannelsProps {
|
||||||
setShowChannels: (val: boolean) => void;
|
setShowChannels: (val: boolean) => void;
|
||||||
clearNotifications: (id: string) => void;
|
clearNotifications: (id: string) => void;
|
||||||
channels: ChannelData[];
|
channels: ChannelData[];
|
||||||
|
|
||||||
|
membersList: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NarrowChannels({
|
export function NarrowChannels({
|
||||||
|
@ -24,6 +26,8 @@ export function NarrowChannels({
|
||||||
setShowChannels,
|
setShowChannels,
|
||||||
clearNotifications,
|
clearNotifications,
|
||||||
channels,
|
channels,
|
||||||
|
|
||||||
|
membersList,
|
||||||
}: NarrowChannelsProps) {
|
}: NarrowChannelsProps) {
|
||||||
return (
|
return (
|
||||||
<ListWrapper>
|
<ListWrapper>
|
||||||
|
@ -37,6 +41,7 @@ export function NarrowChannels({
|
||||||
}}
|
}}
|
||||||
activeChannelId={activeChannelId}
|
activeChannelId={activeChannelId}
|
||||||
channels={channels}
|
channels={channels}
|
||||||
|
membersList={membersList}
|
||||||
/>
|
/>
|
||||||
</ListWrapper>
|
</ListWrapper>
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,12 +10,14 @@ interface NarrowMembersProps {
|
||||||
community: CommunityData;
|
community: CommunityData;
|
||||||
setShowChannels: (val: boolean) => void;
|
setShowChannels: (val: boolean) => void;
|
||||||
setShowMembersList: (val: boolean) => void;
|
setShowMembersList: (val: boolean) => void;
|
||||||
|
setMembersList: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NarrowMembers({
|
export function NarrowMembers({
|
||||||
community,
|
community,
|
||||||
setShowChannels,
|
setShowChannels,
|
||||||
setShowMembersList,
|
setShowMembersList,
|
||||||
|
setMembersList,
|
||||||
}: NarrowMembersProps) {
|
}: NarrowMembersProps) {
|
||||||
return (
|
return (
|
||||||
<ListWrapper>
|
<ListWrapper>
|
||||||
|
@ -24,6 +26,7 @@ export function NarrowMembers({
|
||||||
community={community}
|
community={community}
|
||||||
setShowChannels={setShowChannels}
|
setShowChannels={setShowChannels}
|
||||||
setShowMembers={setShowMembersList}
|
setShowMembers={setShowMembersList}
|
||||||
|
setMembersList={setMembersList}
|
||||||
/>
|
/>
|
||||||
</ListWrapper>
|
</ListWrapper>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export type ChannelData = {
|
export type ChannelData = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
isMuted?: boolean;
|
isMuted?: boolean;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue