From 97535066e999cf9e86ed38dec56052e42a6f6e26 Mon Sep 17 00:00:00 2001 From: Maria Rushkova <66270386+mrushkova@users.noreply.github.com> Date: Wed, 12 Jan 2022 06:36:01 +0100 Subject: [PATCH] Lock activity center (#183) * Add input placeholder * Lock activity center without identity * Change cursor for disabled buttons Co-authored-by: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com> --- .../src/components/Chat/ChatInput.tsx | 26 ++++++++++++++----- .../src/components/Chat/ChatTopbar.tsx | 16 +++++++++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/packages/react-chat/src/components/Chat/ChatInput.tsx b/packages/react-chat/src/components/Chat/ChatInput.tsx index cde30d15..c0b98783 100644 --- a/packages/react-chat/src/components/Chat/ChatInput.tsx +++ b/packages/react-chat/src/components/Chat/ChatInput.tsx @@ -261,7 +261,12 @@ export function ChatInput({ reply, setReply }: ChatInputProps) { onKeyUp={handleCursorChange} ref={inputRef} onClick={handleCursorChange} - dangerouslySetInnerHTML={{ __html: clearComponent }} + dangerouslySetInnerHTML={{ + __html: disabled + ? "You need to join this community to send messages" + : clearComponent, + }} + className={`${disabled && "disabled"} `} /> {query && ( - + - + @@ -363,12 +369,14 @@ const Input = styled.div` color: ${({ theme }) => theme.primary}; border-radius: 16px 16px 4px 16px; outline: none; - font-family: "Inter"; - font-style: normal; - font-weight: normal; ${textMediumStyles}; + &.disabled { + color: ${({ theme }) => theme.secondary}; + cursor: default; + } + &:focus { outline: none; caret-color: ${({ theme }) => theme.notificationColor}; @@ -390,6 +398,7 @@ const Input = styled.div` &:hover { background: ${({ theme }) => theme.mentionBgHover}; + cursor: default; } } `; @@ -416,6 +425,10 @@ const AddPictureInput = styled.input` const ChatButton = styled.button` width: 32px; height: 32px; + + &:disabled { + cursor: default; + } `; const CloseButton = styled(ChatButton)` @@ -423,6 +436,7 @@ const CloseButton = styled(ChatButton)` top: 0; right: 0; `; + const ReplyWrapper = styled.div` display: flex; flex-direction: column; diff --git a/packages/react-chat/src/components/Chat/ChatTopbar.tsx b/packages/react-chat/src/components/Chat/ChatTopbar.tsx index 15fbf1a6..f5555ddf 100644 --- a/packages/react-chat/src/components/Chat/ChatTopbar.tsx +++ b/packages/react-chat/src/components/Chat/ChatTopbar.tsx @@ -1,7 +1,8 @@ -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import styled from "styled-components"; import { useActivities } from "../../contexts/activityProvider"; +import { useIdentity } from "../../contexts/identityProvider"; import { useMessengerContext } from "../../contexts/messengerProvider"; import { useNarrow } from "../../contexts/narrowProvider"; import { ActivityCenter } from "../ActivityCenter"; @@ -36,7 +37,7 @@ export function ChatTopbarLoading() { - + @@ -66,6 +67,8 @@ export function ChatTopbar({ const narrow = useNarrow(); const [showChannelMenu, setShowChannelMenu] = useState(false); const [showActivityCenter, setShowActivityCenter] = useState(false); + const identity = useIdentity(); + const disabled = useMemo(() => !identity, [identity]); if (!activeChannel) { return ; @@ -108,7 +111,10 @@ export function ChatTopbar({ - setShowActivityCenter(!showActivityCenter)}> + setShowActivityCenter(!showActivityCenter)} + disabled={disabled} + > {activities.length > 0 && ( theme.sectionBackgroundColor}; } + + &:disabled { + cursor: default; + } `; const NotificationBagde = styled.div`