-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set custom color when applying initial background image (#54054)
* set overlay from image background average color and refactor code to compute it only once per URL and set is dark attribute correctly * don't reset the maually set overlay, stop redefining utility functions, improve featured image case, don't compute darkness for same color background and foreground * update test with the new default color being white * add the userOverlayColor attribute to keep track of system vs user color setting * Remove default value to fix integration tests * Update JSDoc comments * Consolidate all color functions into color-utils.js * Memoize the average color calculation with memize * Move await before setAttributes calls so they won't be spread out * Consolidate setAttributes calls * Refactor out setIsDark * Refactor attributesFromMedia to return the attributes rather than set them * Refactor out setOverlayFromAverageColor to merge more setAttribute calls * Refactor compositeIsDark to return early if second params are the same * Rename next* to new* for consistency with other existing functions * Move useEffect up near related code * Fix comment * Add check for fully opaque overlay colors * Fix clearMedia from not resetting overlayColor when not manually specified * Rename getAverageBackgroundColor to getMediaColor * Fix use newDimRatio on media select * Fix overlay color not resetting when clearing featured image * Fix missing averageBackgroundColor when toggling featured image * Rename userOverlayColor to isUserOverlayColor * Fix isDark calculation when clearing media * Fix undo states * Update docs with new attribute * Separate out compositeIsDark calls from setAttributes * Fix case where isDark wasn't correctly set when toggling off featured image * Move useFeaturedImage: false to index * Move focalPoint: undefined to index * Set useFeaturedImage to undefined instead of false for slightly cleaner attributes * Shorten #FFFFFF to #FFF * Fix overlayColor in onUpdateDimRatio * Fix use newDimRatio for isDark on updateDimRatio * Fix use newDimRatio for isDark on toggleUseFeaturedImage * Rename DEFAULT_AVERAGE_COLOR to DEFAULT_BACKGROUND_COLOR to better describe what it means in the contexts used * Better JSDoc comment * Fix DEFAULT_BACKGROUND_COLOR import * Update tests to use playwright toHaveCSS * Variable naming * Replace remaining instance of checking backgrounds with toHaveCSS * Update image upload test * Update image transform test * Add block deprecation for auto overlay color * Fix lint * Remove unnecessary expect for the default value * update mobile snapshots due to new attribute * updated snapshots for transforms on mobile tests due to new attribute --------- Co-authored-by: Alex Lende <[email protected]>
- Loading branch information
1 parent
8a82a37
commit 6a258b3
Showing
17 changed files
with
651 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.