Skip to content

Commit

Permalink
Fixed UI issues for Sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
abirc8010 committed Oct 1, 2024
1 parent cbae92a commit 661acb7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/views/Message/Message.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const getMessageDividerStyles = (theme) => {
line-height: 1rem;
position: relative;
display: flex;
z-index: 1000;
z-index: 1;
align-items: center;
margin-top: 0.5rem;
margin-bottom: 0.75rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { isSameDay, format } from 'date-fns';
import React, { useEffect, useState } from 'react';
import { isSameDay, format, set } from 'date-fns';
import { Box, Sidebar, Popup, useTheme } from '@embeddedchat/ui-elements';
import { MessageDivider } from '../../Message/MessageDivider';
import Message from '../../Message/Message';
Expand Down Expand Up @@ -41,14 +41,22 @@ export const MessageAggregator = ({

const noMessages = messageList?.length === 0 || !messageRendered;
const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;

const [isSmallScreen, setIsSmallScreen] = useState(false);
useEffect(() => {
setIsSmallScreen(window.innerWidth < 780);
}, []);
return (
<ViewComponent
title={title}
iconName={iconName}
searchProps={searchProps}
onClose={() => setExclusiveState(null)}
style={{ padding: 0 }}
style={{
...(isSmallScreen && viewType === 'Sidebar'
? styles.sidebarStyles
: null),
backgroundColor: theme.colors.background,
}}
{...(viewType === 'Popup'
? {
isPopupHeader: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from '@emotion/react';

const getMessageAggregatorStyles = () => {
const getMessageAggregatorStyles = (theme) => {
const styles = {
listContainerStyles: css`
flex: 1;
Expand All @@ -9,6 +9,7 @@ const getMessageAggregatorStyles = () => {
justify-content: initial;
align-items: initial;
max-width: 100%;
overflow-y: auto;
`,

noMessageStyles: css`
Expand All @@ -21,6 +22,15 @@ const getMessageAggregatorStyles = () => {
flex-direction: column;
align-items: center;
`,
sidebarStyles: {
position: 'absolute',
left: '0',
bottom: '0',
top: '2',
width: '100%',
height: '93%',
zIndex: 1,
},
};

return styles;
Expand Down
18 changes: 15 additions & 3 deletions packages/react/src/views/RoomInformation/RoomInformation.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React, { useContext } from 'react';
import React, { useContext, useState, useEffect } from 'react';
import { css } from '@emotion/react';
import {
Box,
Avatar,
Sidebar,
Popup,
useComponentOverrides,
useTheme,
} from '@embeddedchat/ui-elements';
import { getRoomInformationStyles } from './RoomInformation.styles';
import RCContext from '../../context/RCInstance';
import { useChannelStore } from '../../store';
import useSetExclusiveState from '../../hooks/useSetExclusiveState';

const Roominfo = () => {
const { RCInstance } = useContext(RCContext);

const { theme } = useTheme();
const styles = getRoomInformationStyles(theme);
const channelInfo = useChannelStore((state) => state.channelInfo);
const { variantOverrides } = useComponentOverrides('RoomMember');
const viewType = variantOverrides.viewType || 'Sidebar';
Expand All @@ -24,12 +27,21 @@ const Roominfo = () => {
};

const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;

const [isSmallScreen, setIsSmallScreen] = useState(false);
useEffect(() => {
setIsSmallScreen(window.innerWidth < 780);
}, []);
return (
<ViewComponent
title="Room Information"
iconName="info"
onClose={() => setExclusiveState(null)}
style={{
...(isSmallScreen && viewType === 'Sidebar'
? styles.sidebarStyles
: null),
backgroundColor: theme.colors.background,
}}
{...(viewType === 'Popup'
? {
isPopupHeader: true,
Expand Down
14 changes: 14 additions & 0 deletions packages/react/src/views/RoomInformation/RoomInformation.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const getRoomInformationStyles = () => {
const styles = {
sidebarStyles: {
position: 'absolute',
left: '0',
bottom: '0',
top: '1',
width: '100%',
height: '93%',
zIndex: 1,
},
};
return styles;
};
14 changes: 12 additions & 2 deletions packages/react/src/views/RoomMembers/RoomMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ const RoomMembers = ({ members }) => {
const roles = userInfo && userInfo.roles ? userInfo.roles : [];
const isAdmin = roles.includes('admin');
const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;
const [isSmallScreen, setIsSmallScreen] = useState(false);
useEffect(() => {
setIsSmallScreen(window.innerWidth < 780);
}, []);
return (
<ViewComponent
title="Members"
iconName="members"
onClose={() => setExclusiveState(null)}
style={{
...(isSmallScreen && viewType === 'Sidebar'
? styles.containerStyles
: null),
backgroundColor: theme.colors.background,
}}
{...(viewType === 'Popup'
? {
isPopupHeader: true,
Expand All @@ -64,7 +74,7 @@ const RoomMembers = ({ members }) => {
{isLoading ? (
<LoadingIndicator />
) : (
<Box css={styles.container}>
<Box css={styles.memberListStyles}>
{showInvite ? (
<InviteMembers />
) : (
Expand All @@ -75,7 +85,7 @@ const RoomMembers = ({ members }) => {

{isAdmin && (
<Button
style={{ marginTop: '10px', width: '100%' }}
style={styles.inviteButtonStyles}
onClick={async () => {
toggleInviteView();
}}
Expand Down
24 changes: 20 additions & 4 deletions packages/react/src/views/RoomMembers/RoomMembers.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@ import { css } from '@emotion/react';

export const getRoomMemberStyles = () => {
const styles = {
container: css`
inviteButtonStyles: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
padding: '1rem 1rem 1rem 1rem',
width: '100%',
},
memberListStyles: css`
padding: 0 1rem 1rem;
display: flex;
flex-direction: column;
overflow: auto;
width: 100%;
justify-content: center;
padding: 0 1rem 1rem;
height: 100%;
overflow-y: auto;
`,
containerStyles: {
position: 'absolute',
left: '0',
bottom: '0',
top: '60px',
width: '100%',
height: 'auto',
zIndex: 1,
},
};

return styles;
Expand Down

0 comments on commit 661acb7

Please sign in to comment.