microsoft / BotFramework-WebChat

A highly-customizable web-based client for Azure Bot Services.
https://www.botframework.com/
MIT License
1.59k stars 1.53k forks source link

Add `bubbleImageMaxHeight` and `bubbleImageMinHeight` #5236

Closed compulim closed 1 month ago

compulim commented 2 months ago

Fixes #5235.

Changelog Entry

Breaking changes

Added

Description

Previously, to support IE11, we could not use object-fit. For simplicity, we make images with fixed height.

As we discontinued support of IE11, we can now making image height variable (min/max) and relies object-fit to honor the aspect ratio.

Design

The image resize logic is "enlarge image to meet fixed width, then crop/pad top/bottom to meet height."

Current design is "fixed height", it will crop the image if it is too tall, or pad the image if it is too short.

This PR will enable variable height by min/max. When min is set to 0 and max is set to Infinity, it means "fixed width and make the image as short/tall as it fit."

When the image is taller than max, it will be cropped. When the image is shorter than min, it will be padded.

When min/max are set to the same number, say, 240, it will always crop/pad the image at height of 240px and this is same as today's behavior and enable backward compatibility.

If the deprecating styleOptions.bubbleImageHeight is set, it will propagate to min/max value and is backward compatible.

Specific Changes

Review Checklist

This section is for contributors to review your work.