Skip to content

Commit 4bd0e53

Browse files
abirc8010Spiral-Memory
authored andcommitted
Fixed UI issues for Sidebar
1 parent ebca321 commit 4bd0e53

File tree

7 files changed

+85
-15
lines changed

7 files changed

+85
-15
lines changed

packages/react/src/views/Message/Message.styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const getMessageDividerStyles = (theme) => {
7575
line-height: 1rem;
7676
position: relative;
7777
display: flex;
78-
z-index: 1000;
78+
z-index: 1;
7979
align-items: center;
8080
margin-top: 0.5rem;
8181
margin-bottom: 0.75rem;

packages/react/src/views/MessageAggregators/common/MessageAggregator.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useState } from 'react';
2-
import { isSameDay, format } from 'date-fns';
1+
import React, { useEffect, useState } from 'react';
2+
import { isSameDay, format, set } from 'date-fns';
33
import { Box, Sidebar, Popup, useTheme } from '@embeddedchat/ui-elements';
44
import { MessageDivider } from '../../Message/MessageDivider';
55
import Message from '../../Message/Message';
@@ -41,14 +41,22 @@ export const MessageAggregator = ({
4141

4242
const noMessages = messageList?.length === 0 || !messageRendered;
4343
const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;
44-
44+
const [isSmallScreen, setIsSmallScreen] = useState(false);
45+
useEffect(() => {
46+
setIsSmallScreen(window.innerWidth < 780);
47+
}, []);
4548
return (
4649
<ViewComponent
4750
title={title}
4851
iconName={iconName}
4952
searchProps={searchProps}
5053
onClose={() => setExclusiveState(null)}
51-
style={{ padding: 0 }}
54+
style={{
55+
...(isSmallScreen && viewType === 'Sidebar'
56+
? styles.sidebarStyles
57+
: null),
58+
backgroundColor: theme.colors.background,
59+
}}
5260
{...(viewType === 'Popup'
5361
? {
5462
isPopupHeader: true,

packages/react/src/views/MessageAggregators/common/MessageAggregator.styles.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { css } from '@emotion/react';
22

3-
const getMessageAggregatorStyles = () => {
3+
const getMessageAggregatorStyles = (theme) => {
44
const styles = {
55
listContainerStyles: css`
66
flex: 1;
@@ -9,6 +9,7 @@ const getMessageAggregatorStyles = () => {
99
justify-content: initial;
1010
align-items: initial;
1111
max-width: 100%;
12+
overflow-y: auto;
1213
`,
1314

1415
noMessageStyles: css`
@@ -21,6 +22,15 @@ const getMessageAggregatorStyles = () => {
2122
flex-direction: column;
2223
align-items: center;
2324
`,
25+
sidebarStyles: {
26+
position: 'absolute',
27+
left: '0',
28+
bottom: '0',
29+
top: '2',
30+
width: '100%',
31+
height: '93%',
32+
zIndex: 1,
33+
},
2434
};
2535

2636
return styles;

packages/react/src/views/RoomInformation/RoomInformation.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, useState, useEffect } from 'react';
22
import { css } from '@emotion/react';
33
import {
44
Box,
55
Avatar,
66
Sidebar,
77
Popup,
88
useComponentOverrides,
9+
useTheme,
910
} from '@embeddedchat/ui-elements';
11+
import { getRoomInformationStyles } from './RoomInformation.styles';
1012
import RCContext from '../../context/RCInstance';
1113
import { useChannelStore } from '../../store';
1214
import useSetExclusiveState from '../../hooks/useSetExclusiveState';
1315

1416
const Roominfo = () => {
1517
const { RCInstance } = useContext(RCContext);
16-
18+
const { theme } = useTheme();
19+
const styles = getRoomInformationStyles(theme);
1720
const channelInfo = useChannelStore((state) => state.channelInfo);
1821
const { variantOverrides } = useComponentOverrides('RoomMember');
1922
const viewType = variantOverrides.viewType || 'Sidebar';
@@ -24,12 +27,21 @@ const Roominfo = () => {
2427
};
2528

2629
const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;
27-
30+
const [isSmallScreen, setIsSmallScreen] = useState(false);
31+
useEffect(() => {
32+
setIsSmallScreen(window.innerWidth < 780);
33+
}, []);
2834
return (
2935
<ViewComponent
3036
title="Room Information"
3137
iconName="info"
3238
onClose={() => setExclusiveState(null)}
39+
style={{
40+
...(isSmallScreen && viewType === 'Sidebar'
41+
? styles.sidebarStyles
42+
: null),
43+
backgroundColor: theme.colors.background,
44+
}}
3345
{...(viewType === 'Popup'
3446
? {
3547
isPopupHeader: true,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const getRoomInformationStyles = () => {
2+
const styles = {
3+
sidebarStyles: {
4+
position: 'absolute',
5+
left: '0',
6+
bottom: '0',
7+
top: '1',
8+
width: '100%',
9+
height: '93%',
10+
zIndex: 1,
11+
},
12+
};
13+
return styles;
14+
};

packages/react/src/views/RoomMembers/RoomMember.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,21 @@ const RoomMembers = ({ members }) => {
5050
const roles = userInfo && userInfo.roles ? userInfo.roles : [];
5151
const isAdmin = roles.includes('admin');
5252
const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;
53+
const [isSmallScreen, setIsSmallScreen] = useState(false);
54+
useEffect(() => {
55+
setIsSmallScreen(window.innerWidth < 780);
56+
}, []);
5357
return (
5458
<ViewComponent
5559
title="Members"
5660
iconName="members"
5761
onClose={() => setExclusiveState(null)}
62+
style={{
63+
...(isSmallScreen && viewType === 'Sidebar'
64+
? styles.containerStyles
65+
: null),
66+
backgroundColor: theme.colors.background,
67+
}}
5868
{...(viewType === 'Popup'
5969
? {
6070
isPopupHeader: true,
@@ -64,7 +74,7 @@ const RoomMembers = ({ members }) => {
6474
{isLoading ? (
6575
<LoadingIndicator />
6676
) : (
67-
<Box css={styles.container}>
77+
<Box css={styles.memberListStyles}>
6878
{showInvite ? (
6979
<InviteMembers />
7080
) : (
@@ -75,7 +85,7 @@ const RoomMembers = ({ members }) => {
7585

7686
{isAdmin && (
7787
<Button
78-
style={{ marginTop: '10px', width: '100%' }}
88+
style={styles.inviteButtonStyles}
7989
onClick={async () => {
8090
toggleInviteView();
8191
}}

packages/react/src/views/RoomMembers/RoomMembers.styles.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,30 @@ import { css } from '@emotion/react';
22

33
export const getRoomMemberStyles = () => {
44
const styles = {
5-
container: css`
5+
inviteButtonStyles: {
6+
display: 'flex',
7+
justifyContent: 'center',
8+
alignItems: 'center',
9+
padding: '1rem 1rem 1rem 1rem',
10+
width: '100%',
11+
},
12+
memberListStyles: css`
13+
padding: 0 1rem 1rem;
614
display: flex;
715
flex-direction: column;
8-
overflow: auto;
916
width: 100%;
10-
justify-content: center;
11-
padding: 0 1rem 1rem;
17+
height: 100%;
18+
overflow-y: auto;
1219
`,
20+
containerStyles: {
21+
position: 'absolute',
22+
left: '0',
23+
bottom: '0',
24+
top: '60px',
25+
width: '100%',
26+
height: 'auto',
27+
zIndex: 1,
28+
},
1329
};
1430

1531
return styles;

0 commit comments

Comments
 (0)