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

A revamped scalable HTMLImage component #389

Merged
merged 5 commits into from
Sep 26, 2020
Merged

A revamped scalable HTMLImage component #389

merged 5 commits into from
Sep 26, 2020

Conversation

jsamr
Copy link
Collaborator

@jsamr jsamr commented Jul 24, 2020

BREAKING: imagesMaxWidth prop is discontinued in favor of contentWidth and computeImagesMaxWidth. See RFC001 for an exhaustive description.

This patch offers a rewrite of the HTMLImage component to get a close match with RFC001, “a deterministic approach to images scaling”. The only part of this RFC which is unsupported is the unitConverter behavior, which is planned for a later major release.

In addition to the capabilities defined in the RFC, these patches provide the new property enableExperimentalPercentWidth. It allows percent width for <img> tags, computed relatively to contentWidth.

These patches also fix #141, #172. Kudos to authors of PRs #242 and #315 which have given inspiration for this work.

TODOS:

  • Update the Image section in the README
  • Update typescript types

@jsamr jsamr linked an issue Jul 24, 2020 that may be closed by this pull request
@jsamr jsamr force-pushed the feat/scalable-images branch 3 times, most recently from 4905fe9 to b4d906b Compare July 24, 2020 14:30
@jsamr jsamr added the pr:breaking Pull Request introducing a breaking change. label Jul 24, 2020
@jsamr jsamr force-pushed the feat/scalable-images branch 6 times, most recently from 0412245 to 5e1a8f1 Compare July 27, 2020 18:50
@jsamr jsamr mentioned this pull request Aug 6, 2020
1 task
@jsamr jsamr marked this pull request as ready for review September 26, 2020 09:05
@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2020

Codecov Report

Merging #389 into master will increase coverage by 2.85%.
The diff coverage is 65.95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #389      +/-   ##
==========================================
+ Coverage   60.90%   63.76%   +2.85%     
==========================================
  Files           6        6              
  Lines         376      436      +60     
  Branches      125      136      +11     
==========================================
+ Hits          229      278      +49     
  Misses         64       64              
- Partials       83       94      +11     
Impacted Files Coverage Δ
src/HTML.js 57.39% <40.00%> (-0.60%) ⬇️
src/HTMLRenderers.js 55.10% <50.00%> (ø)
src/HTMLImage.js 73.46% <73.46%> (+15.57%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b382229...c745a30. Read the comment docs.

BREAKING: imagesMaxWidth prop is discontinued in favor of contentWidth and
computeImagesMaxWidth. See RFC001 for an exhaustive description.

This patch offers a rewrite of the HTMLImage component to get a close
match with RFC001, “a deterministic approach to images scaling”. The only
part of this RFC which is unsupported is the unitConverter behavior, which
is planned for a later major release.

In addition to the capabilities defined in the RFC, this patch provides
the following features and behaviors:

- new property enableExperimentalPercentWidth. It allows percent width
  for <img> tags, computed relatively to contentWidth.
- take margins into account when scaling down images;
- support for overriding image styles, including resizeMode;
- support for minWidth, minHeight, maxWidth, maxHeight styles.

This patch also fixes #141, #172 and provides the features offered in
PR #242 and #315.

OPTIMIZATIONS: The imageBoxDimensions are computed when required. In
addition, requirements are also recomputed when necessary, preventing
expensive operations from happening too often. Also, because we need to
flatten the style prop to infer requirements, this flatten value is now
cached and re-evaluated when appropriate. Finally, styles have been
moved to a stylesheet when that is possible, to avoid commiting updates
to the native side. Note that these performance optimizations are made
possible by the high coverage rate of the HTMLImage component.

fixes #141
fixes #172
updates #412 (could fix)
closes #315
closes #242
@jsamr jsamr merged commit 299aa8e into master Sep 26, 2020
@jsamr jsamr deleted the feat/scalable-images branch November 16, 2020 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:breaking Pull Request introducing a breaking change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

img's tag resizeMode property not modifiable through html tagStyles image getting blur issue
2 participants