From 77dfd154b288c14afe821b0d6e16b8726e1b90f2 Mon Sep 17 00:00:00 2001
From: Maria Rushkova <66270386+mrushkova@users.noreply.github.com>
Date: Fri, 26 Nov 2021 10:23:52 +0100
Subject: [PATCH] UI improvements (#135)
* Fix channel name styles
* Add active class to group icon
* Fix channel description
* Hide member category
* Fix community name alignment
* Add unmuting
* Add group unmuting
* Add user name to empty text
* Fix group description
* Add closing dropdown on click outside
* Add memoization
* Change useClickOutside
---
.../src/components/Channels/Channel.tsx | 13 +++---
.../src/components/Channels/EmptyChannel.tsx | 9 +++-
.../src/components/Chat/ChatCreation.tsx | 1 +
.../components/Chat/ChatMessageContent.tsx | 4 +-
.../src/components/CommunityIdentity.tsx | 1 +
.../src/components/Form/ChannelMenu.tsx | 10 +++--
.../src/components/Form/ContactMenu.tsx | 2 +-
.../src/components/Form/DropdownMenu.tsx | 15 +++++--
.../src/components/Form/ImageMenu.tsx | 4 +-
.../src/components/Icons/GroupIcon.tsx | 13 ++++--
.../src/components/Members/Member.tsx | 2 +-
.../src/components/Members/MembersList.tsx | 43 ++++++++++++-------
.../react-chat/src/hooks/useClickOutside.ts | 24 +++++++++++
.../react-chat/src/hooks/useContextMenu.ts | 2 +-
14 files changed, 105 insertions(+), 38 deletions(-)
create mode 100644 packages/react-chat/src/hooks/useClickOutside.ts
diff --git a/packages/react-chat/src/components/Channels/Channel.tsx b/packages/react-chat/src/components/Channels/Channel.tsx
index 8b849bc1..09b6ae53 100644
--- a/packages/react-chat/src/components/Channels/Channel.tsx
+++ b/packages/react-chat/src/components/Channels/Channel.tsx
@@ -1,6 +1,7 @@
import React from "react";
import styled from "styled-components";
+import { useMessengerContext } from "../../contexts/messengerProvider";
import { useNarrow } from "../../contexts/narrowProvider";
import { ChannelData } from "../../models/ChannelData";
import { GroupIcon } from "../Icons/GroupIcon";
@@ -14,12 +15,13 @@ function RenderChannelName({
channel: ChannelData;
className?: string;
}) {
+ const { activeChannel } = useMessengerContext();
switch (channel.type) {
case "group":
return (
-
- {channel.name}
+
+ {` ${channel.name}`}
);
case "channel":
@@ -77,7 +79,7 @@ export function Channel({
@@ -89,7 +91,7 @@ export function Channel({
{!activeView && !!mention && mention > 0 && !channel?.isMuted && (
{mention}
)}
- {channel?.isMuted && }
+ {channel?.isMuted && !activeView && }
);
}
@@ -101,6 +103,7 @@ const ChannelWrapper = styled.div<{ isNarrow?: boolean }>`
padding: 8px;
cursor: pointer;
width: ${({ isNarrow }) => (isNarrow ? "calc(100% - 162px)" : "100%")};
+
&.active {
background-color: ${({ theme }) => theme.activeChannelBackground};
border-radius: 8px;
@@ -136,7 +139,7 @@ export const ChannelLogo = styled.div<{ icon?: string }>`
background-color: ${({ theme }) => theme.iconColor};
background-size: cover;
background-repeat: no-repeat;
- backgroundimage: ${({ icon }) => icon && `url(${icon}`};
+ background-image: ${({ icon }) => icon && `url(${icon}`};
color: ${({ theme }) => theme.iconTextColor};
&.active {
diff --git a/packages/react-chat/src/components/Channels/EmptyChannel.tsx b/packages/react-chat/src/components/Channels/EmptyChannel.tsx
index 873a984c..9c966b53 100644
--- a/packages/react-chat/src/components/Channels/EmptyChannel.tsx
+++ b/packages/react-chat/src/components/Channels/EmptyChannel.tsx
@@ -1,6 +1,8 @@
import React from "react";
+import { utils } from "status-communities/dist/cjs";
import styled from "styled-components";
+import { useIdentity } from "../../contexts/identityProvider";
import { ChannelData } from "../../models/ChannelData";
import { textMediumStyles } from "../Text";
@@ -12,6 +14,7 @@ type EmptyChannelProps = {
export function EmptyChannel({ channel }: EmptyChannelProps) {
const groupName = channel.name.split(", ");
+ const identity = useIdentity();
return (
@@ -31,7 +34,7 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
) : channel.type === "group" ? (
- You created a group with{" "}
+ {utils.bufToHex(identity.publicKey)} created a group with{" "}
{groupName.slice(groupName.length - 1)} and{" "}
{groupName.at(-1)}
@@ -88,5 +91,7 @@ const EmptyText = styled.p`
`;
const EmptyTextGroup = styled(EmptyText)`
- word-break: break-all;
+ & > span {
+ word-break: break-all;
+ }
`;
diff --git a/packages/react-chat/src/components/Chat/ChatCreation.tsx b/packages/react-chat/src/components/Chat/ChatCreation.tsx
index ccb9e9cc..4a1e3160 100644
--- a/packages/react-chat/src/components/Chat/ChatCreation.tsx
+++ b/packages/react-chat/src/components/Chat/ChatCreation.tsx
@@ -45,6 +45,7 @@ export function ChatCreation({ editGroup }: ChatCreationProps) {
id: group.join(""),
name: group.join(", "),
type: "group",
+ description: `${group.length + 1} members`,
})
: setChannel({
id: group[0],
diff --git a/packages/react-chat/src/components/Chat/ChatMessageContent.tsx b/packages/react-chat/src/components/Chat/ChatMessageContent.tsx
index d5b2258e..7f062065 100644
--- a/packages/react-chat/src/components/Chat/ChatMessageContent.tsx
+++ b/packages/react-chat/src/components/Chat/ChatMessageContent.tsx
@@ -124,11 +124,11 @@ const MessageImage = styled.img`
height: 100%;
object-fit: cover;
border-radius: 16px;
- cursor; pointer;
+ cursor: pointer;
`;
const PreviewSiteNameWrapper = styled.div`
- font-family: Inter;
+ font-family: "Inter";
font-style: normal;
font-weight: normal;
font-size: 12px;
diff --git a/packages/react-chat/src/components/CommunityIdentity.tsx b/packages/react-chat/src/components/CommunityIdentity.tsx
index 30aa2dca..445eeb84 100644
--- a/packages/react-chat/src/components/CommunityIdentity.tsx
+++ b/packages/react-chat/src/components/CommunityIdentity.tsx
@@ -70,6 +70,7 @@ const Name = styled.p`
font-weight: 500;
text-align: left;
color: ${({ theme }) => theme.primary};
+ white-space: nowrap;
${textMediumStyles}
`;
diff --git a/packages/react-chat/src/components/Form/ChannelMenu.tsx b/packages/react-chat/src/components/Form/ChannelMenu.tsx
index e6c2cad5..2593d4bb 100644
--- a/packages/react-chat/src/components/Form/ChannelMenu.tsx
+++ b/packages/react-chat/src/components/Form/ChannelMenu.tsx
@@ -31,8 +31,9 @@ export const ChannelMenu = ({
const narrow = useNarrow();
const { clearNotifications, removeChannel } = useMessengerContext();
const { setModal } = useModal(EditModalName);
+
return (
-
+
{narrow && (