diff --git a/packages/react-chat/src/components/Chat.tsx b/packages/react-chat/src/components/Chat.tsx index de04c018..80fccf3c 100644 --- a/packages/react-chat/src/components/Chat.tsx +++ b/packages/react-chat/src/components/Chat.tsx @@ -21,7 +21,6 @@ export function Chat({ theme, community }: ChatProps) { const [showMembers, setShowMembers] = useState(true); const [showChannels, setShowChannels] = useState(true); const narrow = useNarrow(); - // const className = useMemo(() => (narrow ? 'narrow' : ''), [narrow]); const { messenger, diff --git a/packages/react-chat/src/components/Members.tsx b/packages/react-chat/src/components/Members.tsx index 5d4b3543..9d0f998c 100644 --- a/packages/react-chat/src/components/Members.tsx +++ b/packages/react-chat/src/components/Members.tsx @@ -1,6 +1,7 @@ -import React from "react"; +import React, { useCallback } from "react"; import styled from "styled-components"; +import { useNarrow } from "../contexts/narrowProvider"; import { CommunityData } from "../helpers/communityMock"; import { Theme } from "../styles/themes"; @@ -30,12 +31,14 @@ interface MembersListProps { theme: Theme; community: CommunityData; setShowChannels: (val: boolean) => void; + setShowMembers?: (val: boolean) => void; } export function MembersList({ theme, community, setShowChannels, + setShowMembers, }: MembersListProps) { return ( @@ -59,6 +62,7 @@ export function MembersList({ member={member} isOnline={member.isOnline} setShowChannels={setShowChannels} + setShowMembers={setShowMembers} /> ))} @@ -73,6 +77,7 @@ export function MembersList({ member={member} isOnline={member.isOnline} setShowChannels={setShowChannels} + setShowMembers={setShowMembers} /> ))} @@ -85,6 +90,7 @@ interface MemberProps { member: any; isOnline: boolean; setShowChannels: (val: boolean) => void; + setShowMembers?: (val: boolean) => void; } export function Member({ @@ -92,9 +98,21 @@ export function Member({ member, isOnline, setShowChannels, + setShowMembers, }: MemberProps) { + const narrow = useNarrow(); + + const switchMemberList = useCallback(() => { + setShowChannels(false); + if (setShowMembers) setShowMembers(false); + }, [setShowMembers]); + return ( - setShowChannels(true)}> + + narrow && setShowMembers ? switchMemberList() : setShowChannels(true) + } + > + ` padding: 18px; + background: ${({ theme }) => theme.bodyBackgroundColor}; `; diff --git a/packages/react-chat/src/components/NarrowMode/NarrowMembers.tsx b/packages/react-chat/src/components/NarrowMode/NarrowMembers.tsx index 98316847..509c57c3 100644 --- a/packages/react-chat/src/components/NarrowMode/NarrowMembers.tsx +++ b/packages/react-chat/src/components/NarrowMode/NarrowMembers.tsx @@ -21,7 +21,7 @@ export function NarrowMembers({ setShowMembersList, }: NarrowMembersProps) { return ( - + ); } -const ListWrapper = styled.div` +interface ThemeProps { + theme: Theme; +} + +const ListWrapper = styled.div` padding: 18px; + background: ${({ theme }) => theme.bodyBackgroundColor}; `;