From 370f6c65e4599ea90424d26d8afe8e2852f3666e Mon Sep 17 00:00:00 2001 From: Maria Rushkova <66270386+mrushkova@users.noreply.github.com> Date: Wed, 6 Oct 2021 09:33:31 +0200 Subject: [PATCH] Add empty state for channel (#41) --- .../react-chat/src/components/Channels.tsx | 6 +- .../src/components/Chat/ChatBody.tsx | 13 +-- .../src/components/EmptyChannel.tsx | 80 +++++++++++++++++++ 3 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 packages/react-chat/src/components/EmptyChannel.tsx diff --git a/packages/react-chat/src/components/Channels.tsx b/packages/react-chat/src/components/Channels.tsx index a38f7a0e..049d7474 100644 --- a/packages/react-chat/src/components/Channels.tsx +++ b/packages/react-chat/src/components/Channels.tsx @@ -183,7 +183,7 @@ const ChannelWrapper = styled.div` } `; -const ChannelInfo = styled.div` +export const ChannelInfo = styled.div` display: flex; align-items: center; `; @@ -193,7 +193,7 @@ const ChannelTextInfo = styled.div` flex-direction: column; `; -const ChannelLogo = styled.div` +export const ChannelLogo = styled.div` width: 24px; height: 24px; display: flex; @@ -225,7 +225,7 @@ const ChannelLogo = styled.div` } `; -const ChannelName = styled.p` +export const ChannelName = styled.p` font-weight: 500; opacity: 0.7; color: ${({ theme }) => theme.primary}; diff --git a/packages/react-chat/src/components/Chat/ChatBody.tsx b/packages/react-chat/src/components/Chat/ChatBody.tsx index 8fd89542..ce355531 100644 --- a/packages/react-chat/src/components/Chat/ChatBody.tsx +++ b/packages/react-chat/src/components/Chat/ChatBody.tsx @@ -8,6 +8,7 @@ import { ChatMessage } from "../../models/ChatMessage"; import { Theme } from "../../styles/themes"; import { Channel } from "../Channels"; import { Community } from "../Community"; +import { EmptyChannel } from "../EmptyChannel"; import { MembersIcon } from "../Icons/MembersIcon"; import { NarrowChannels } from "../NarrowMode/NarrowChannels"; import { NarrowTopbar } from "../NarrowMode/NarrowTopbar"; @@ -72,12 +73,14 @@ export function ChatBody({ - {!showChannelsList && !showMembersList && ( - <> + {!showChannelsList && + !showMembersList && + (messages.length > 0 ? ( - - - )} + ) : ( + + ))} + {showChannelsList && narrow && ( + + + {" "} + {!channel.icon && channel.name.slice(0, 1).toUpperCase()} + + + {channel.name} + + + + Welcome to the beginning of the #{channel.name} channel! + + + ); +} + +interface ThemeProps { + theme: Theme; +} + +const Wrapper = styled.div` + display: flex; + flex-direction: column; + align-items: center; + height: calc(100% - 44px); + padding: 8px 16px 0; +`; + +const ChannelInfoEmpty = styled(ChannelInfo)` + flex-direction: column; +`; + +const ChannelLogoEmpty = styled(ChannelLogo)` + width: 120px; + height: 120px; + font-weight: bold; + font-size: 51px; + line-height: 62px; + margin-bottom: 16px; +`; + +const ChannelNameEmpty = styled(ChannelName)` + font-weight: bold; + font-size: 22px; + line-height: 30px; + margin-bottom: 16px; +`; + +const EmptyText = styled.p` + display: inline-block; + color: ${({ theme }) => theme.secondary}; + + & > span { + color: ${({ theme }) => theme.primary}; + } + + ${textMediumStyles} +`;