Skip to content
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

[Chat] Added Image Loading Placeholder to Chat Messages #3861

Merged
merged 8 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "minor",
"area": "improvement",
"workstream": "Inline Image",
"comment": "Add image placeholder for interop chat messages",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "minor",
"area": "improvement",
"workstream": "Inline Image",
"comment": "Add image placeholder for interop chat messages",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ export const useChatMessageStyles = makeStyles({
color: tokens.colorStatusWarningBackground3,
fontWeight: tokens.fontWeightSemibold
},
'& img[src=""]': {
display: 'block',
position: 'relative'
},
'& img[src=""]:after': {
backgroundColor: tokens.colorNeutralBackground1Selected,
content: `url("data:image/gif;base64,R0lGODlhAQABAAAAACw=")`,
backgroundSize: 'center',
position: 'absolute',
width: '100%',
height: '100%',
top: '0',
left: '0',
display: 'block'
},
'& img': {
maxWidth: '100% !important', // Add !important to make sure it won't be overridden by style defined in element
height: 'auto !important'
Expand Down
1 change: 1 addition & 0 deletions packages/react-components/src/theming/v9ThemeShim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const createV9Theme = (themeV8: ThemeV8, baseThemeV9?: ThemeV9): ThemeV9
colorNeutralForeground2: themeV8.palette.neutralSecondary,
colorBrandForegroundLink: themeV8.palette.themePrimary,
colorBrandForegroundLinkHover: themeV8.palette.themeDarker,
colorNeutralBackground1Selected: themeV8.palette.neutralQuaternaryAlt,
// Fix for an issue with black borders for iOS that are added with 'after' selector
colorStrokeFocus2: 'transparent'
};
Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it has changed the default scrolling behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually think the "after" is correct since it scrolls to the bottom? also i feel like there's might be a race condition when snapshot is taken (maybe rendering the placeholder caused a few ms delay so snapshot is now taken when thread is scrolled to button)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const GenerateMockNewChatMessageWithInlineImage = (): ChatMessage => {
...UserThree,
messageId: Math.random().toString(),
content:
'<p>Check out this image:&nbsp;</p>\r\n<p><img alt="image" src="" itemscope="png" width="250" height="250" id="SomeImageId" style="vertical-align:bottom"></p><p>&nbsp;</p>\r\n',
'<p>Check out this image:&nbsp;</p>\r\n<p><img alt="image" src="" itemscope="png" width="250" height="375" id="SomeImageId" style="vertical-align:bottom"></p><p>&nbsp;</p>\r\n',
jpeng-ms marked this conversation as resolved.
Show resolved Hide resolved
createdOn: new Date('2020-04-13T00:00:00.000+07:01'),
mine: false,
attached: false,
Expand Down Expand Up @@ -105,8 +105,8 @@ const GenerateMockMessageAttachments = (): InlineImageMetadata[] => {
{
id: 'SomeImageId',
attachmentType: 'inlineImage',
url: 'images/github.png',
previewUrl: 'images/github.png'
url: 'images/inlineImageExample1.png',
previewUrl: 'images/inlineImageExample1.png'
}
];
};
Expand Down
Loading