Skip to content

Commit

Permalink
fix: remove elevation from new chat component (#2791)
Browse files Browse the repository at this point in the history
remove elevation from new chat component
removed header line and padding from new chat
fixed react-contoso sample and updated docs
  • Loading branch information
gavinbarron authored Oct 25, 2023
1 parent 112aaba commit c854c6a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 74 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/mgt-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export const App: React.FunctionComponent = () => {
onChatCreated={onChatCreated}
onCancelClicked={() => setShowNewChat(false)}
mode="auto"
hideTitle={true}
title="Create a new chat"
/>
)}

Expand Down
2 changes: 0 additions & 2 deletions packages/mgt-chat/docs/new-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ The following example displays a signed-in user's conversation using the `mgt-ne

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

## CSS custom properties
Expand Down
94 changes: 32 additions & 62 deletions packages/mgt-chat/src/components/NewChat/NewChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,28 @@ import { Chat } from '@microsoft/microsoft-graph-types';
import { IGraph, PeoplePicker, Spinner } from '@microsoft/mgt-react';
import {
Button,
Divider,
Field,
FluentProvider,
Input,
InputOnChangeData,
Text,
Textarea,
TextareaOnChangeData,
teamsLightTheme,
makeStyles,
typographyStyles,
shorthands,
tokens
webLightTheme
} from '@fluentui/react-components';
import { createChatThread } from '../../statefulClient/graph.chat';
import { graph } from '../../utils/graph';
import { currentUserId } from '../../utils/currentUser';

interface NewChatProps {
hideTitle?: boolean;
title?: string;
mode?: 'oneOnOne' | 'group' | 'auto';
onChatCreated: (chat: Chat) => void;
onCancelClicked: () => void;
}

const useStyles = makeStyles({
container: {
display: 'flex',
flexDirection: 'column',
...shorthands.paddingBlock('3px', '16px'),
minWidth: '300px',
backgroundColor: tokens.colorNeutralBackground1,
boxShadow: tokens.shadow8
},
title: {
...typographyStyles.subtitle2,
...shorthands.marginInline('32px')
Expand All @@ -47,8 +34,7 @@ const useStyles = makeStyles({
display: 'flex',
flexDirection: 'column',
gridRowGap: '16px',
marginBlockStart: '16px',
...shorthands.marginInline('32px')
minWidth: '300px'
},
formButtons: {
display: 'flex',
Expand All @@ -58,13 +44,7 @@ const useStyles = makeStyles({
}
});

const NewChat: FC<NewChatProps> = ({
hideTitle,
title,
mode = 'auto',
onChatCreated,
onCancelClicked
}: NewChatProps) => {
const NewChat: FC<NewChatProps> = ({ mode = 'auto', onChatCreated, onCancelClicked }: NewChatProps) => {
const styles = useStyles();
type NewChatState = 'initial';

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

return (
<FluentProvider theme={teamsLightTheme}>
<FluentProvider theme={webLightTheme}>
{state === 'initial' ? (
<div className={styles.container}>
{!hideTitle && (
<>
<Text as="h2" className={styles.title}>
{title ? title : 'New chat'}
</Text>
<Divider />
</>
)}
<div className={styles.form}>
<Field label="To">
<PeoplePicker
disabled={(mode === 'oneOnOne' && selectedPeople?.length > 0) || selectedPeople?.length > 19}
ariaLabel="Select people to chat with"
selectedPeople={selectedPeople}
selectionChanged={onSelectedPeopleChange}
/>
</Field>

{isGroup && (
<Field label="Group name">
<Input placeholder="Chat name" onChange={onChatNameChanged} value={chatName} />
</Field>
)}
<Textarea
placeholder="Type your first message"
size="large"
resize="vertical"
value={initialMessage}
onChange={onInitialMessageChange}
<div className={styles.form}>
<Field label="To">
<PeoplePicker
disabled={(mode === 'oneOnOne' && selectedPeople?.length > 0) || selectedPeople?.length > 19}
ariaLabel="Select people to chat with"
selectedPeople={selectedPeople}
selectionChanged={onSelectedPeopleChange}
/>
<div className={styles.formButtons}>
<Button appearance="secondary" onClick={onCancelClicked}>
Cancel
</Button>
<Button appearance="primary" onClick={createChat}>
Send
</Button>
</div>
</Field>

{isGroup && (
<Field label="Group name">
<Input placeholder="Chat name" onChange={onChatNameChanged} value={chatName} />
</Field>
)}
<Textarea
placeholder="Type your first message"
size="large"
resize="vertical"
value={initialMessage}
onChange={onInitialMessageChange}
/>
<div className={styles.formButtons}>
<Button appearance="secondary" onClick={onCancelClicked}>
Cancel
</Button>
<Button appearance="primary" onClick={createChat}>
Send
</Button>
</div>
</div>
) : (
Expand Down
8 changes: 1 addition & 7 deletions samples/react-chat/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ function App() {
<button onClick={() => setShowNewChat(true)}>New Chat</button>
{showNewChat && (
<div className="new-chat">
<NewChat
onChatCreated={onChatCreated}
onCancelClicked={() => setShowNewChat(false)}
mode="auto"
hideTitle={true}
title="Create a new chat"
/>
<NewChat onChatCreated={onChatCreated} onCancelClicked={() => setShowNewChat(false)} mode="auto" />
</div>
)}
</div>
Expand Down
1 change: 0 additions & 1 deletion samples/react-contoso/src/pages/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export const ChatPage: React.FunctionComponent = () => {
onCancelClicked={() => {
setIsNewChatOpen(false);
}}
hideTitle={true}
></NewChat>
</DialogBody>
</DialogSurface>
Expand Down

0 comments on commit c854c6a

Please sign in to comment.