Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-12290] inline image collapse #7352

Merged

Conversation

TheDarkestDay
Copy link
Contributor

Summary

The purpose of this PR is to introduce capability for inline Markdown image to be expanded/collapsed. Moreover, they should take into account user preferences in terms of default embedded content display mode - either collapsed or expanded.

Ticket Link

mattermost/mattermost#16636

Related Pull Requests

N/A

Screenshots

Hovering large inline image now displays a special "Collapse" button in the top-left corner of the image:
image

You can collapse it by clicking on the button and then expand it again by clicking on a special collapsed view of the inline image:
image

@mattermod
Copy link
Contributor

Hello @TheDarkestDay,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@matthewbirtch matthewbirtch self-requested a review January 20, 2021 14:57
@matthewbirtch matthewbirtch added 1: PM Review Requires review by a product manager 1: UX Review Requires review by a UX Designer 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jan 20, 2021
@hanzei hanzei added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Jan 20, 2021
Copy link
Contributor

@matthewbirtch matthewbirtch left a comment

Choose a reason for hiding this comment

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

Thanks @TheDarkestDay! This is great. Just a few tweaks from my standpoint:

  1. The image has a border on it when you hover on it. Can we remove that?
  2. Is it possible to animate the collapsing transition? This would help orient users. If not, we could look at that in a separate PR
  3. Can we reduce the margin on the top of .markdown-inline-img to 2px instead of 5px? That should even out the positioning of the arrow button

&:hover {
border: 1px solid var(--center-channel-color-24);

@include box-shadow($elevation-2);
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason $elevation-2 is rendering the shadow opacity at 0.012 and it should be rendering as 0.12

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. I'll fix this. By the way, all of the elevations starting from 2 to 6 have an opacity like this. Probably we have here some sort of wide spread issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a mistake to me. Not sure when this was added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed only $elevation-2 for now.

@asaadmahmood I am sorry to bother you but according to Git blame you were the author of these elevation settings. May I request some assistance from you - are these opacity values incorrect or there were some reasoning behind this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@TheDarkestDay The opacity values are updated on master.
I did them on this PR:
https://github.com/mattermost/mattermost-webapp/pull/7696/files

@jgilliam17 jgilliam17 changed the title Mm 12290 inline image collapse [MM-12290] inline image collapse Jan 21, 2021
@TheDarkestDay
Copy link
Contributor Author

Thanks @TheDarkestDay! This is great. Just a few tweaks from my standpoint:

  1. The image has a border on it when you hover on it. Can we remove that?
  2. Is it possible to animate the collapsing transition? This would help orient users. If not, we could look at that in a separate PR
  3. Can we reduce the margin on the top of .markdown-inline-img to 2px instead of 5px? That should even out the positioning of the arrow button

Thanks @matthewbirtch! Okay, let me try to tackle this step by step.

I've been digging around point 3 and the only question I am currently having - should we apply this change universally to all of the Markdown inline images or should just create some special edge case for this one?

I tried applying this thing globally and I didn't manage to find any specific issues caused by this change. On the other hand, for sure I might be missing some use case which would really explain the purpose of this margin setting.

What do you think, does it make sense to apply this change universally, push it here and let you and the team check it?

@TheDarkestDay
Copy link
Contributor Author

  1. The image has a border on it when you hover on it. Can we remove that?

Oh, that's the same story, actually.

The thing is that each inline Markdown image is supposed to be clickable - and on click it should be shown in full size in a modal window. And I guess the reason for this shadow-on-hover effect is exactly to give a hint that this image is clickable.

So, the question is - should we treat these "images with expand" somehow different? Should we remove this thing for them or rework somehow?

@TheDarkestDay
Copy link
Contributor Author

TheDarkestDay commented Jan 25, 2021

  1. Is it possible to animate the collapsing transition? This would help orient users. If not, we could look at that in a separate PR

I think at least I can try. The only thing I am concerned about here is performance of height change animation - but we will only find it out if we try it in the wild.

May I kindly ask you to share some assets for this animation? Things like duration, easing function, maybe even some gif would be helpful.

@matthewbirtch
Copy link
Contributor

matthewbirtch commented Jan 25, 2021

I've been digging around point 3 and the only question I am currently having - should we apply this change universally to all of the Markdown inline images or should just create some special edge case for this one?

I tried applying this thing globally and I didn't manage to find any specific issues caused by this change. On the other hand, for sure I might be missing some use case which would really explain the purpose of this margin setting.

What do you think, does it make sense to apply this change universally, push it here and let you and the team check it?

Ok, let's leave this as-is for now and we can look in to it later if we feel strongly that it needs to change.

The thing is that each inline Markdown image is supposed to be clickable - and on click it should be shown in full size in a modal window. And I guess the reason for this shadow-on-hover effect is exactly to give a hint that this image is clickable.

So, the question is - should we treat these "images with expand" somehow different? Should we remove this thing for them or rework somehow?

Makes sense. Let's leave the border and shadow effect

I think at least I can try. The only thing I am concerned about here is performance of height change animation - but we will only find it out if we try it in the wild.

May I kindly ask you to share some assets for this animation? Things like duration, easing function, maybe even some gif would be helpful.

Give these a go:

transition: height 250ms cubic-bezier(0.5, 0, 0.5, 1);

We may need to tweak the above, but we'll see when it's in the wild.

Copy link
Contributor

@jgilliam17 jgilliam17 left a comment

Choose a reason for hiding this comment

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

Thank you @TheDarkestDay
Tested, looks good to merge.

  • Verified inline image collapse for images 100px or more in height; heights change animations when using slash commands for expand/collapse are happening in view; underline is removed when inline image is linked.

@jgilliam17 jgilliam17 added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Apr 7, 2021
@mm-cloud-bot
Copy link

Test server destroyed

@jgilliam17
Copy link
Contributor

@hmhealey Can you please help merge. Thanks 🙂

@hmhealey hmhealey merged commit 66b49a4 into mattermost:master Apr 8, 2021
@hmhealey
Copy link
Member

hmhealey commented Apr 8, 2021

Merged! Thanks again for the PR, @TheDarkestDay. This will be on Mattermost Cloud some time in the next couple weeks and then in (I think) Mattermost 5.35 after that.

@amyblais amyblais added this to the v5.35 milestone Apr 8, 2021
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Needed Requires documentation labels Apr 8, 2021
@ethervoid
Copy link
Contributor

/cherry-pick cloud

@mattermod
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit to mattermost-build/mattermost-webapp that referenced this pull request Apr 12, 2021
* MM-12290. More or less done with the concept, visuals and components design

* MM-12290. Added hover styles for both collapse and expand icons

* MM-12290. Changed hover style for expand button

* MM-12290. Added snapshot tests for MarkdownImageExpand

* MM-12290. Integrated proper icons for both expand and collapse buttons

* MM-12290. Added corresponding tests for Expand insertion logic inside MarkdownImage, added handling for both imageMetadata.height and regular height for MarkdownImageExpand

* MM-12290. Formatting fixes

* MM-12290. Fixed snapshots for MarkdownImageExpand

* MM-12290. An attempt to implement simple expand/collapse transition

* MM-12290. Fixed wrong shadow props for elevation-2

* MM-12290. Auto-formatting

* MM-12290. Inline image expand now properly captures settings values changed via slash commands like /expand or /collapse. Therefore, postId is now also provided for MarkdownImageExpand

* [MM-12290] Got rid of local expand state in favor of Redux one, removed animations for now

* [MM-12290] Moved inline image collapse/expand state to the corresponding storage field

* [MM-12290] Fixed snapshots for html-to-component

* [MM-12290] Fixed color usage to use setting opacity with rgba instead of using variables with opacities

* [MM-12290] Reverted package-lock fully

* [MM-12290] Missing newlinew for package-lock added back

* [MM-12290] Minor codestyle fixes, now we use image src as its expand/collapse state key instead of index

* [MM-12290] Added separate callback to let MarkdownImage notify consumers about some inner height change

* [MOB-12290] Reverted package-lock changes, fixed missing heading for MarkdiwnImage test, fixed snapshots

* [MM-12290] Written back a missing snapshot for fixed test

* [MM-12290] Hopefully finally removed obsolete snapshot

* [MM-12290] Removed redundant license information from MarkdownImageExpand

* [MM-12290] Tried migrating expand-button display to inline-block to avoid displaying underline text decoration caused by parent link

* [MM-12290] Fixed linting errors

Co-authored-by: Aleksandr Brenchev <[email protected]>
Co-authored-by: Mattermod <[email protected]>
(cherry picked from commit 66b49a4)
@mattermod mattermod added the CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone label Apr 12, 2021
ethervoid pushed a commit that referenced this pull request Apr 12, 2021
* MM-12290. More or less done with the concept, visuals and components design

* MM-12290. Added hover styles for both collapse and expand icons

* MM-12290. Changed hover style for expand button

* MM-12290. Added snapshot tests for MarkdownImageExpand

* MM-12290. Integrated proper icons for both expand and collapse buttons

* MM-12290. Added corresponding tests for Expand insertion logic inside MarkdownImage, added handling for both imageMetadata.height and regular height for MarkdownImageExpand

* MM-12290. Formatting fixes

* MM-12290. Fixed snapshots for MarkdownImageExpand

* MM-12290. An attempt to implement simple expand/collapse transition

* MM-12290. Fixed wrong shadow props for elevation-2

* MM-12290. Auto-formatting

* MM-12290. Inline image expand now properly captures settings values changed via slash commands like /expand or /collapse. Therefore, postId is now also provided for MarkdownImageExpand

* [MM-12290] Got rid of local expand state in favor of Redux one, removed animations for now

* [MM-12290] Moved inline image collapse/expand state to the corresponding storage field

* [MM-12290] Fixed snapshots for html-to-component

* [MM-12290] Fixed color usage to use setting opacity with rgba instead of using variables with opacities

* [MM-12290] Reverted package-lock fully

* [MM-12290] Missing newlinew for package-lock added back

* [MM-12290] Minor codestyle fixes, now we use image src as its expand/collapse state key instead of index

* [MM-12290] Added separate callback to let MarkdownImage notify consumers about some inner height change

* [MOB-12290] Reverted package-lock changes, fixed missing heading for MarkdiwnImage test, fixed snapshots

* [MM-12290] Written back a missing snapshot for fixed test

* [MM-12290] Hopefully finally removed obsolete snapshot

* [MM-12290] Removed redundant license information from MarkdownImageExpand

* [MM-12290] Tried migrating expand-button display to inline-block to avoid displaying underline text decoration caused by parent link

* [MM-12290] Fixed linting errors

Co-authored-by: Aleksandr Brenchev <[email protected]>
Co-authored-by: Mattermod <[email protected]>
(cherry picked from commit 66b49a4)

Co-authored-by: Alexander Brenchev <[email protected]>
cwarnermm added a commit to mattermost/docs that referenced this pull request Apr 16, 2021
Documentation for: mattermost/mattermost-webapp#7352

Updated:
- User's Guide > Messaging > Formatting Text > In-line Images
   - Added introduction to explain what in-line images are and clarify that in-line images over 100px in height are subject to the **Default Appearance of Image Previews** user preference and the equivalent slash commands
   - Applied readability and consistency updates to existing content
   - Corrected formatting where needed
cwarnermm added a commit to mattermost/docs that referenced this pull request Apr 16, 2021
Documentation for: mattermost/mattermost-webapp#7352

Updated:
- User's Guide > Settings > Account Settings > Display > Link Previews
   - Updated the existing subsection title from "Link Previews" to "Default Appearance of Image Previews"
   - Updated impact scope of user preference to include in-line images over 100px in height
cwarnermm added a commit to mattermost/docs that referenced this pull request Apr 16, 2021
Documentation for: mattermost/mattermost-webapp#7352

Updated:
- Cloud Admin Guide > Configuration > Site Configuration 
   - Applied Style Guide, consistency, and navigation updates to content throughout this page
   - Under **Posts**, added documentation for users to control whether in-line images over 100px in height can be automatically collapsed or expanded
cwarnermm added a commit to mattermost/docs that referenced this pull request Apr 16, 2021
Documentation for: mattermost/mattermost-webapp#7352

Updated:
- Cloud Admin Guide > Integrations > Slash Commands > Built-in Commands
   - Updated descriptions for both ``/expand`` and ``/collapse`` to include image previews, image attachments, and inline images over 100px in height, and included links to the in-line images user documentation
cwarnermm added a commit to mattermost/docs that referenced this pull request Apr 16, 2021
Documentation for: mattermost/mattermost-webapp#7352

Updated:
- User's Guide > Messaging > Executing Commands > Built-in Commands
   - Updated descriptions for both ``/expand`` and ``/collapse`` to include image previews, image attachments, and inline images over 100px in height, and included links to the in-line images user documentation
cwarnermm added a commit to mattermost/docs that referenced this pull request Apr 20, 2021
* MM-12290 inline image collapse

Documentation for: mattermost/mattermost-webapp#7352

Updated:
- User's Guide > Messaging > Formatting Text > In-line Images
   - Added introduction to explain what in-line images are and clarify that in-line images over 100px in height are subject to the **Default Appearance of Image Previews** user preference and the equivalent slash commands
   - Applied readability and consistency updates to existing content
   - Corrected formatting where needed

* MM-12290 inline image collapse

Documentation for: mattermost/mattermost-webapp#7352

Updated:
- User's Guide > Settings > Account Settings > Display > Link Previews
   - Updated the existing subsection title from "Link Previews" to "Default Appearance of Image Previews"
   - Updated impact scope of user preference to include in-line images over 100px in height

* Update source/help/settings/account-settings.rst

* Update source/help/messaging/formatting-text.rst

* MM-12290 inline image collapse

Documentation for: mattermost/mattermost-webapp#7352

Updated:
- Cloud Admin Guide > Configuration > Site Configuration 
   - Applied Style Guide, consistency, and navigation updates to content throughout this page
   - Under **Posts**, added documentation for users to control whether in-line images over 100px in height can be automatically collapsed or expanded

* Update source/help/messaging/formatting-text.rst

* Update source/cloud/cloud-administration/site-configuration.rst

* Update source/cloud/cloud-administration/site-configuration.rst

* MM-12290 inline image collapse

Documentation for: mattermost/mattermost-webapp#7352

Updated:
- Cloud Admin Guide > Integrations > Slash Commands > Built-in Commands
   - Updated descriptions for both ``/expand`` and ``/collapse`` to include image previews, image attachments, and inline images over 100px in height, and included links to the in-line images user documentation

* MM-12290 inline image collapse

Documentation for: mattermost/mattermost-webapp#7352

Updated:
- User's Guide > Messaging > Executing Commands > Built-in Commands
   - Updated descriptions for both ``/expand`` and ``/collapse`` to include image previews, image attachments, and inline images over 100px in height, and included links to the in-line images user documentation

* Formatting fixes

* Alignment fixes

* Changed Note to Tip

* Update source/cloud/cloud-administration/site-configuration.rst

* MM-12290 inline image collapse

Applied reviewer feedback

* MM-12290 inline image collapse

Applied reviewer feedback

* MM-12290 inline image collapse

Applied reviewer feedback.

* MM-12290 inline image collapse

Applied reviewer feedback.

* MM-12290-inline-image-collapse

Formatting fixes

* MM-12290 inline image collapse

Formatting fixes

* MM-12290 inline image collapse

Formatting fixes

* formatting fixes

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/help/messaging/formatting-text.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/help/messaging/formatting-text.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/help/messaging/formatting-text.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/help/messaging/formatting-text.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/help/messaging/formatting-text.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

* Update source/cloud/cloud-administration/site-configuration.rst

Co-authored-by: Justine Geffen <[email protected]>

Co-authored-by: Justine Geffen <[email protected]>
@cwarnermm cwarnermm added Docs/Done Required documentation has been written and removed Docs/Needed Requires documentation labels Apr 21, 2021
@mm-cloud-bot
Copy link

@TheDarkestDay: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

I understand the commands that are listed here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone do-not-merge/release-note-label-needed Docs/Done Required documentation has been written
Projects
None yet
Development

Successfully merging this pull request may close these issues.