Skip to content

Commit 80a6d07

Browse files
authored
fix: membership management button stacking (#2785)
1 parent 406ca1e commit 80a6d07

File tree

3 files changed

+96
-54
lines changed

3 files changed

+96
-54
lines changed

.yarn/install-state.gz

1 Byte
Binary file not shown.

packages/mgt-chat/src/components/ManageChatMembers/ListChatMembers.tsx

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useCallback, useState } from 'react';
22
import {
33
makeStyles,
4+
mergeClasses,
45
shorthands,
56
Button,
67
Dialog,
@@ -13,7 +14,7 @@ import {
1314
import { List, ListItem } from '@fluentui/react-northstar';
1415
import { Person, PersonViewType } from '@microsoft/mgt-react';
1516
import { AadUserConversationMember } from '@microsoft/microsoft-graph-types';
16-
import { Dismiss24Regular, bundleIcon } from '@fluentui/react-icons';
17+
import { Dismiss20Filled, bundleIcon, iconFilledClassName, iconRegularClassName } from '@fluentui/react-icons';
1718

1819
interface ListChatMembersProps {
1920
currentUserId: string;
@@ -22,18 +23,49 @@ interface ListChatMembersProps {
2223
closeParentPopover: () => void;
2324
}
2425

25-
const RemovePerson = bundleIcon(Dismiss24Regular, () => <></>);
26+
const RemovePerson = bundleIcon(Dismiss20Filled, () => <></>);
2627

2728
const useStyles = makeStyles({
29+
iconPlaceholder: {
30+
display: 'flex',
31+
width: '24px'
32+
},
2833
listItem: {
2934
listStyleType: 'none',
30-
width: '100%'
35+
width: '100%',
36+
':focus-visible': {
37+
[`& .${iconFilledClassName}`]: {
38+
display: 'inline',
39+
color: 'var(--colorNeutralForeground2BrandHover)'
40+
},
41+
[`& .${iconRegularClassName}`]: {
42+
display: 'none'
43+
}
44+
}
3145
},
3246
memberList: {
3347
fontWeight: 800,
3448
gridGap: '8px',
35-
...shorthands.marginBlock('0px'),
36-
...shorthands.padding('4px')
49+
...shorthands.marginBlock('0'),
50+
...shorthands.padding('0')
51+
},
52+
personRow: {
53+
display: 'flex',
54+
flexDirection: 'row',
55+
alignItems: 'center',
56+
justifyContent: 'space-between',
57+
...shorthands.paddingBlock('5px'),
58+
...shorthands.paddingInline('16px'),
59+
':hover': {
60+
backgroundColor: 'var(--colorSubtleBackgroundHover)',
61+
[`& .${iconFilledClassName}`]: {
62+
display: 'inline',
63+
color: 'var(--colorNeutralForeground2BrandHover)'
64+
},
65+
[`& .${iconRegularClassName}`]: {
66+
display: 'none'
67+
}
68+
}
3769
},
3870
fullWidth: {
3971
width: '100%'
@@ -64,6 +96,7 @@ const ListChatMembers = ({ members, currentUserId, removeChatMember, closeParent
6496

6597
void removeChatMember(removeUser.id).then(closeDialog);
6698
}, [removeUser, removeChatMember, closeDialog]);
99+
67100
return (
68101
<>
69102
<Dialog open={removeDialogOpen} onOpenChange={(_, data) => setRemoveDialogOpen(data.open)}>
@@ -91,24 +124,23 @@ const ListChatMembers = ({ members, currentUserId, removeChatMember, closeParent
91124
className={styles.listItem}
92125
index={index}
93126
content={
94-
<Button
95-
appearance="subtle"
96-
icon={isCurrentUser ? null : <RemovePerson />}
97-
iconPosition="after"
98-
className={styles.fullWidth}
99-
>
127+
<div className={mergeClasses(styles.personRow, styles.fullWidth)}>
100128
<Person
101129
className={styles.fullWidth}
102130
tabIndex={-1}
103131
userId={member.userId}
104132
view={PersonViewType.oneline}
105133
showPresence
106134
/>
107-
</Button>
135+
<span className={styles.iconPlaceholder}>{!isCurrentUser && <RemovePerson />}</span>
136+
</div>
108137
}
109138
onClick={() => {
110-
if (isCurrentUser) return;
111-
openRemoveDialog(member);
139+
if (isCurrentUser) {
140+
closeDialog();
141+
} else {
142+
openRemoveDialog(member);
143+
}
112144
}}
113145
/>
114146
) : null;

packages/mgt-chat/src/components/ManageChatMembers/ManageChatMembers.tsx

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ import {
2121
bundleIcon,
2222
PeopleAdd24Regular,
2323
PeopleAdd24Filled,
24-
DoorArrowLeft20Filled,
25-
DoorArrowLeft20Regular
24+
DoorArrowLeft24Filled,
25+
DoorArrowLeft24Regular
2626
} from '@fluentui/react-icons';
2727
import { AadUserConversationMember } from '@microsoft/microsoft-graph-types';
28-
import { buttonIconStyles } from '../styles/common.styles';
2928
import { AddChatMembers } from './AddChatMembers';
3029
import { ListChatMembers } from './ListChatMembers';
3130

@@ -37,9 +36,23 @@ interface ManageChatMembersProps {
3736
}
3837

3938
const AddPeople = bundleIcon(PeopleAdd24Filled, PeopleAdd24Regular);
40-
const Leave = bundleIcon(DoorArrowLeft20Filled, DoorArrowLeft20Regular);
39+
const Leave = bundleIcon(DoorArrowLeft24Filled, DoorArrowLeft24Regular);
4140

4241
const useStyles = makeStyles({
42+
button: {
43+
justifyContent: 'flex-start',
44+
...shorthands.paddingInline('16px')
45+
},
46+
buttonRow: {
47+
display: 'flex',
48+
flexDirection: 'column'
49+
},
50+
container: {
51+
...shorthands.paddingBlock('4px')
52+
},
53+
divider: {
54+
...shorthands.marginBlock('4px')
55+
},
4356
popover: {
4457
...shorthands.padding('0 !important')
4558
},
@@ -93,48 +106,45 @@ const ManageChatMembers = ({ currentUserId, members, addChatMembers, removeChatM
93106
{showAddMembers ? (
94107
<AddChatMembers closeDialog={closeCallout} addChatMembers={addChatMembers} />
95108
) : (
96-
<>
109+
<div className={styles.container}>
97110
<ListChatMembers
98111
members={members}
99112
removeChatMember={removeChatMember}
100113
currentUserId={currentUserId}
101114
closeParentPopover={closeCallout}
102115
/>
103-
<Divider />
104-
<Button
105-
appearance="transparent"
106-
icon={<AddPeople />}
107-
onClick={openAddMembers}
108-
className={buttonIconStyles.button}
109-
>
110-
Add people
111-
</Button>
112-
<Dialog>
113-
<DialogTrigger>
114-
<Button appearance="transparent" icon={<Leave />} className={buttonIconStyles.button}>
115-
Leave
116-
</Button>
117-
</DialogTrigger>
118-
<DialogSurface>
119-
<DialogBody>
120-
<DialogTitle>Leave the conversation?</DialogTitle>
121-
<DialogContent>You&apos;ll still have access to the chat history.</DialogContent>
122-
<DialogActions>
123-
<DialogTrigger disableButtonEnhancement>
124-
<Button appearance="secondary" onClick={closeCallout}>
125-
Cancel
126-
</Button>
127-
</DialogTrigger>
128-
{members.length > 2 && (
129-
<Button appearance="primary" onClick={leaveChat}>
130-
Leave
131-
</Button>
132-
)}
133-
</DialogActions>
134-
</DialogBody>
135-
</DialogSurface>
136-
</Dialog>
137-
</>
116+
<Divider className={styles.divider} />
117+
<div className={styles.buttonRow}>
118+
<Button appearance="subtle" icon={<AddPeople />} onClick={openAddMembers} className={styles.button}>
119+
Add people
120+
</Button>
121+
<Dialog>
122+
<DialogTrigger>
123+
<Button appearance="subtle" icon={<Leave />} className={styles.button}>
124+
Leave
125+
</Button>
126+
</DialogTrigger>
127+
<DialogSurface>
128+
<DialogBody>
129+
<DialogTitle>Leave the conversation?</DialogTitle>
130+
<DialogContent>You&apos;ll still have access to the chat history.</DialogContent>
131+
<DialogActions>
132+
<DialogTrigger disableButtonEnhancement>
133+
<Button appearance="secondary" onClick={closeCallout}>
134+
Cancel
135+
</Button>
136+
</DialogTrigger>
137+
{members.length > 2 && (
138+
<Button appearance="primary" onClick={leaveChat}>
139+
Leave
140+
</Button>
141+
)}
142+
</DialogActions>
143+
</DialogBody>
144+
</DialogSurface>
145+
</Dialog>
146+
</div>
147+
</div>
138148
)}
139149
</PopoverSurface>
140150
</Popover>

0 commit comments

Comments
 (0)