-
Notifications
You must be signed in to change notification settings - Fork 78
Responsive attach file icon #1774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
6d2960c
18b9e9e
7b6803d
8891cc8
63356c1
02fff83
ffb8e69
84ab85b
6b15edb
2b67a6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "Changing attach file icon position basis on form factor", | ||
| "packageName": "@internal/react-composites", | ||
| "email": "anjulgarg@live.com", | ||
| "dependentChangeType": "patch" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ export type ChatScreenProps = { | |
| styles?: ChatScreenStyles; | ||
| hasFocusOnMount?: 'sendBoxTextField'; | ||
| fileSharing?: FileSharingOptions; | ||
| formFactor?: 'desktop' | 'mobile'; | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -108,7 +109,15 @@ export interface FileSharingOptions { | |
| * @private | ||
| */ | ||
| export const ChatScreen = (props: ChatScreenProps): JSX.Element => { | ||
| const { onFetchAvatarPersonaData, onRenderMessage, onRenderTypingIndicator, options, styles, fileSharing } = props; | ||
| const { | ||
| onFetchAvatarPersonaData, | ||
| onRenderMessage, | ||
| onRenderTypingIndicator, | ||
| options, | ||
| styles, | ||
| fileSharing, | ||
| formFactor | ||
| } = props; | ||
|
|
||
| const defaultNumberOfChatMessagesToReload = 5; | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
|
|
@@ -147,16 +156,19 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => { | |
| /* @conditional-compile-remove(file-sharing) */ | ||
| const userId = toFlatCommunicationIdentifier(adapter.getState().userId); | ||
|
|
||
| const fileUploadButtonOnChange = (files: FileList | null): void => { | ||
| if (!files) { | ||
| return; | ||
| } | ||
| const fileUploadButtonOnChange = useCallback( | ||
| (files: FileList | null): void => { | ||
| if (!files) { | ||
| return; | ||
| } | ||
|
|
||
| /* @conditional-compile-remove(file-sharing) */ | ||
| const fileUploads = adapter.registerActiveFileUploads(Array.from(files)); | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| fileSharing?.uploadHandler(userId, fileUploads); | ||
| }; | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| const fileUploads = adapter.registerActiveFileUploads(Array.from(files)); | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| fileSharing?.uploadHandler(userId, fileUploads); | ||
| }, | ||
| [adapter, fileSharing, userId] | ||
| ); | ||
|
|
||
| /* @conditional-compile-remove(file-sharing) */ | ||
| const onRenderFileDownloads = useCallback( | ||
|
|
@@ -173,6 +185,19 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => { | |
| [fileSharing?.downloadHandler] | ||
| ); | ||
|
|
||
| const AttachFileButton = useCallback(() => { | ||
| if (!fileSharing?.uploadHandler) { | ||
| return null; | ||
| } | ||
| return ( | ||
| <FileUploadButton | ||
| accept={fileSharing?.accept} | ||
| multiple={fileSharing?.multiple} | ||
| onChange={fileUploadButtonOnChange} | ||
| /> | ||
| ); | ||
| }, [fileSharing?.accept, fileSharing?.multiple, fileSharing?.uploadHandler, fileUploadButtonOnChange]); | ||
|
|
||
| return ( | ||
| <Stack className={chatContainer} grow> | ||
| {options?.topic !== false && <ChatHeader {...headerProps} />} | ||
|
|
@@ -205,23 +230,25 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => { | |
| <TypingIndicator {...typingIndicatorProps} styles={typingIndicatorStyles} /> | ||
| )} | ||
| </div> | ||
| <SendBox | ||
| {...sendBoxProps} | ||
| autoFocus={options?.autoFocus} | ||
| styles={sendBoxStyles} | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| activeFileUploads={useSelector(fileUploadsSelector).files} | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| onCancelFileUpload={adapter.cancelFileUpload} | ||
| /> | ||
|
|
||
| {fileSharing?.uploadHandler && ( | ||
| <FileUploadButton | ||
| accept={fileSharing?.accept} | ||
| multiple={fileSharing?.multiple} | ||
| onChange={fileUploadButtonOnChange} | ||
| /> | ||
| )} | ||
| <Stack horizontal={formFactor === 'mobile'} horizontalAlign="start"> | ||
|
anjulgarg marked this conversation as resolved.
Outdated
|
||
| {formFactor === 'mobile' && ( | ||
| <Stack verticalAlign="center"> | ||
| <AttachFileButton /> | ||
| </Stack> | ||
| )} | ||
| <div style={{ width: '100%' }}> | ||
|
anjulgarg marked this conversation as resolved.
Outdated
|
||
| <SendBox | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we bringing any of these features to the sendbox component we export?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not 100% sure about the best way to do it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah not sure either, but can always make this decision when we support rich text as that's when many more changes will be made cc @PorterNan
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. That's why I am keeping it simple for now. |
||
| {...sendBoxProps} | ||
| autoFocus={options?.autoFocus} | ||
| styles={sendBoxStyles} | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| activeFileUploads={useSelector(fileUploadsSelector).files} | ||
| /* @conditional-compile-remove(file-sharing) */ | ||
| onCancelFileUpload={adapter.cancelFileUpload} | ||
| /> | ||
| </div> | ||
| {formFactor !== 'mobile' && <AttachFileButton />} | ||
| </Stack> | ||
| </Stack> | ||
| </Stack> | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when this goes stable we'll have to somehow remember to update storybook docs...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made a note.