Skip to content

Commit c854c6a

Browse files
authored
fix: remove elevation from new chat component (#2791)
remove elevation from new chat component removed header line and padding from new chat fixed react-contoso sample and updated docs
1 parent 112aaba commit c854c6a

File tree

6 files changed

+33
-74
lines changed

6 files changed

+33
-74
lines changed

.yarn/install-state.gz

297 KB
Binary file not shown.

packages/mgt-chat/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ export const App: React.FunctionComponent = () => {
8282
onChatCreated={onChatCreated}
8383
onCancelClicked={() => setShowNewChat(false)}
8484
mode="auto"
85-
hideTitle={true}
86-
title="Create a new chat"
8785
/>
8886
)}
8987

packages/mgt-chat/docs/new-chat.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ The following example displays a signed-in user's conversation using the `mgt-ne
2525

2626
| Attribute | Property | Description |
2727
| - | - | - |
28-
| hide-title | hideTitle | A Boolean to set the component interface to hide its title. Default is `false`. |
29-
| title | title | Value of the title displayed in the component. |
3028
| mode | mode | Set to `oneOnOne`, `group` or `auto`. Default is `auto`. |
3129

3230
## CSS custom properties

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

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,28 @@ import { Chat } from '@microsoft/microsoft-graph-types';
44
import { IGraph, PeoplePicker, Spinner } from '@microsoft/mgt-react';
55
import {
66
Button,
7-
Divider,
87
Field,
98
FluentProvider,
109
Input,
1110
InputOnChangeData,
12-
Text,
1311
Textarea,
1412
TextareaOnChangeData,
15-
teamsLightTheme,
1613
makeStyles,
1714
typographyStyles,
1815
shorthands,
19-
tokens
16+
webLightTheme
2017
} from '@fluentui/react-components';
2118
import { createChatThread } from '../../statefulClient/graph.chat';
2219
import { graph } from '../../utils/graph';
2320
import { currentUserId } from '../../utils/currentUser';
2421

2522
interface NewChatProps {
26-
hideTitle?: boolean;
27-
title?: string;
2823
mode?: 'oneOnOne' | 'group' | 'auto';
2924
onChatCreated: (chat: Chat) => void;
3025
onCancelClicked: () => void;
3126
}
3227

3328
const useStyles = makeStyles({
34-
container: {
35-
display: 'flex',
36-
flexDirection: 'column',
37-
...shorthands.paddingBlock('3px', '16px'),
38-
minWidth: '300px',
39-
backgroundColor: tokens.colorNeutralBackground1,
40-
boxShadow: tokens.shadow8
41-
},
4229
title: {
4330
...typographyStyles.subtitle2,
4431
...shorthands.marginInline('32px')
@@ -47,8 +34,7 @@ const useStyles = makeStyles({
4734
display: 'flex',
4835
flexDirection: 'column',
4936
gridRowGap: '16px',
50-
marginBlockStart: '16px',
51-
...shorthands.marginInline('32px')
37+
minWidth: '300px'
5238
},
5339
formButtons: {
5440
display: 'flex',
@@ -58,13 +44,7 @@ const useStyles = makeStyles({
5844
}
5945
});
6046

61-
const NewChat: FC<NewChatProps> = ({
62-
hideTitle,
63-
title,
64-
mode = 'auto',
65-
onChatCreated,
66-
onCancelClicked
67-
}: NewChatProps) => {
47+
const NewChat: FC<NewChatProps> = ({ mode = 'auto', onChatCreated, onCancelClicked }: NewChatProps) => {
6848
const styles = useStyles();
6949
type NewChatState = 'initial';
7050

@@ -115,47 +95,37 @@ const NewChat: FC<NewChatProps> = ({
11595
}, [onChatCreated, selectedPeople, initialMessage, chatName, isGroup]);
11696

11797
return (
118-
<FluentProvider theme={teamsLightTheme}>
98+
<FluentProvider theme={webLightTheme}>
11999
{state === 'initial' ? (
120-
<div className={styles.container}>
121-
{!hideTitle && (
122-
<>
123-
<Text as="h2" className={styles.title}>
124-
{title ? title : 'New chat'}
125-
</Text>
126-
<Divider />
127-
</>
128-
)}
129-
<div className={styles.form}>
130-
<Field label="To">
131-
<PeoplePicker
132-
disabled={(mode === 'oneOnOne' && selectedPeople?.length > 0) || selectedPeople?.length > 19}
133-
ariaLabel="Select people to chat with"
134-
selectedPeople={selectedPeople}
135-
selectionChanged={onSelectedPeopleChange}
136-
/>
137-
</Field>
138-
139-
{isGroup && (
140-
<Field label="Group name">
141-
<Input placeholder="Chat name" onChange={onChatNameChanged} value={chatName} />
142-
</Field>
143-
)}
144-
<Textarea
145-
placeholder="Type your first message"
146-
size="large"
147-
resize="vertical"
148-
value={initialMessage}
149-
onChange={onInitialMessageChange}
100+
<div className={styles.form}>
101+
<Field label="To">
102+
<PeoplePicker
103+
disabled={(mode === 'oneOnOne' && selectedPeople?.length > 0) || selectedPeople?.length > 19}
104+
ariaLabel="Select people to chat with"
105+
selectedPeople={selectedPeople}
106+
selectionChanged={onSelectedPeopleChange}
150107
/>
151-
<div className={styles.formButtons}>
152-
<Button appearance="secondary" onClick={onCancelClicked}>
153-
Cancel
154-
</Button>
155-
<Button appearance="primary" onClick={createChat}>
156-
Send
157-
</Button>
158-
</div>
108+
</Field>
109+
110+
{isGroup && (
111+
<Field label="Group name">
112+
<Input placeholder="Chat name" onChange={onChatNameChanged} value={chatName} />
113+
</Field>
114+
)}
115+
<Textarea
116+
placeholder="Type your first message"
117+
size="large"
118+
resize="vertical"
119+
value={initialMessage}
120+
onChange={onInitialMessageChange}
121+
/>
122+
<div className={styles.formButtons}>
123+
<Button appearance="secondary" onClick={onCancelClicked}>
124+
Cancel
125+
</Button>
126+
<Button appearance="primary" onClick={createChat}>
127+
Send
128+
</Button>
159129
</div>
160130
</div>
161131
) : (

samples/react-chat/src/App.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@ function App() {
4040
<button onClick={() => setShowNewChat(true)}>New Chat</button>
4141
{showNewChat && (
4242
<div className="new-chat">
43-
<NewChat
44-
onChatCreated={onChatCreated}
45-
onCancelClicked={() => setShowNewChat(false)}
46-
mode="auto"
47-
hideTitle={true}
48-
title="Create a new chat"
49-
/>
43+
<NewChat onChatCreated={onChatCreated} onCancelClicked={() => setShowNewChat(false)} mode="auto" />
5044
</div>
5145
)}
5246
</div>

samples/react-contoso/src/pages/ChatPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ export const ChatPage: React.FunctionComponent = () => {
9292
onCancelClicked={() => {
9393
setIsNewChatOpen(false);
9494
}}
95-
hideTitle={true}
9695
></NewChat>
9796
</DialogBody>
9897
</DialogSurface>

0 commit comments

Comments
 (0)