From fd14ee5910468939c1afe488eab5d0d09d307f4a Mon Sep 17 00:00:00 2001 From: Vito Galatro Date: Wed, 20 Mar 2024 13:01:47 -0400 Subject: [PATCH] THEMES-891: Non-manual images focal point support (#1966) * THEMES-891: implemented focal point into numbered list block * THEMES-891: updated card list and extra large promo. * THEMES-891: added support for focal point to remaining blocks. * THEMES-891: fixed filter for results list, added focal point to search results list block. * THEMES-891: fixed filter for medium promo. * THEMES-891: added focal point to product featured image. --- .../features/card-list/default.jsx | 21 +++-- .../features/extra-large-promo/default.jsx | 32 +++++--- .../features/large-promo/default.jsx | 26 ++++-- .../features/leadart/default.jsx | 7 +- .../features/medium-promo/default.jsx | 17 +++- .../features/numbered-list/default.jsx | 15 +++- .../product-assortment-carousel/default.jsx | 3 +- .../product-featured-image/default.jsx | 10 +-- .../product-featured-image/default.test.jsx | 20 +---- .../features/results-list/results/index.jsx | 18 +++-- .../results-list/results/result-item.jsx | 50 +++++++----- .../results-list/results/result-item.test.jsx | 3 + .../_children/search-result.jsx | 4 + .../features/simple-list/default.jsx | 23 ++++-- .../features/small-promo/default.jsx | 80 ++++++++++--------- .../top-table-list/_children/extra-large.jsx | 8 +- .../top-table-list/_children/large.jsx | 30 +++---- .../top-table-list/_children/medium.jsx | 3 +- .../top-table-list/_children/small.jsx | 25 +++--- .../features/top-table-list/default.jsx | 32 +++++--- package-lock.json | 6 +- 21 files changed, 260 insertions(+), 173 deletions(-) diff --git a/blocks/card-list-block/features/card-list/default.jsx b/blocks/card-list-block/features/card-list/default.jsx index d2fec9bd79..cf9ce369d3 100644 --- a/blocks/card-list-block/features/card-list/default.jsx +++ b/blocks/card-list-block/features/card-list/default.jsx @@ -10,6 +10,7 @@ import { Date, formatAuthors, formatURL, + getFocalFromANS, getImageFromANS, Heading, HeadingSection, @@ -84,21 +85,29 @@ const CardListItems = (props) => { promo_items { basic { _id - type - url auth { ${RESIZER_TOKEN_VERSION} } + focal_point { + x + y + } + type + url } lead_art { promo_items { basic { _id - type - url auth { ${RESIZER_TOKEN_VERSION} } + focal_point { + x + y + } + type + url } } type @@ -170,7 +179,7 @@ const CardListItems = (props) => { ansImage, aspectRatio: "4:3", resizedOptions: { - smart: true, + ...getFocalFromANS(ansImage), }, responsiveImages: [377, 754, 1508], width: 377, @@ -230,7 +239,7 @@ const CardListItems = (props) => { ansImage: itemAnsImage, aspectRatio: "3:2", resizedOptions: { - smart: true, + ...getFocalFromANS(itemAnsImage), }, responsiveImages: [105, 210, 420], width: 105, diff --git a/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx b/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx index 8ebbf62e17..6d115cc0a0 100644 --- a/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx +++ b/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx @@ -11,6 +11,7 @@ import { Conditional, Date as DateComponent, formatAuthors, + getFocalFromANS, getImageFromANS, getVideoFromANS, Heading, @@ -211,21 +212,29 @@ const ExtraLargePromo = ({ customFields }) => { promo_items { basic { _id - type - url auth { ${RESIZER_TOKEN_VERSION} } + focal_point { + x + y + } + type + url } } } basic { _id - type - url auth { ${RESIZER_TOKEN_VERSION} } + focal_point { + x + y + } + type + url } } website_url @@ -296,21 +305,22 @@ const ExtraLargePromo = ({ customFields }) => { showByline && content?.credits?.by?.length > 0 ? formatAuthors(content.credits.by, phrases.t("global.and-text")) : null; + const ansImage = getImageFromANS(content); const imageParams = showImage && - (imageOverrideURL || (content && getImageFromANS(content)) + (imageOverrideURL || ansImage ? { ansImage: imageOverrideURL ? { - _id: resizedImage ? imageOverrideId : "", - url: imageOverrideURL, - auth: resizedAuth || {}, - } - : getImageFromANS(content), + _id: resizedImage ? imageOverrideId : "", + url: imageOverrideURL, + auth: resizedAuth || {}, + } + : ansImage, alt: content?.headlines?.basic || "", aspectRatio: imageRatio, resizedOptions: { - smart: true, + ...getFocalFromANS(ansImage), }, responsiveImages: [400, 600, 800, 1200], width: 800, diff --git a/blocks/large-promo-block/features/large-promo/default.jsx b/blocks/large-promo-block/features/large-promo/default.jsx index af4a0b5b08..80f557a635 100644 --- a/blocks/large-promo-block/features/large-promo/default.jsx +++ b/blocks/large-promo-block/features/large-promo/default.jsx @@ -18,6 +18,7 @@ import { MediaItem, Stack, formatURL, + getFocalFromANS, getImageFromANS, getVideoFromANS, isServerSide, @@ -221,21 +222,29 @@ const LargePromoItem = ({ customFields, arcSite }) => { promo_items { basic { _id - type - url auth { ${RESIZER_TOKEN_VERSION} } + focal_point { + x + y + } + type + url } } } basic { _id - type - url auth { ${RESIZER_TOKEN_VERSION} } + focal_point { + x + y + } + type + url } } embed_html @@ -337,9 +346,10 @@ const LargePromoItem = ({ customFields, arcSite }) => { const contentOverline = showOverline ? overlineText : null; const contentUrl = content?.websites?.[arcSite]?.website_url; const embedMarkup = playVideoInPlace && getVideoFromANS(content); - const promoImageParams = + const ansImage = getImageFromANS(content); + const promoImageParams = showImage && - (imageOverrideURL || (content && getImageFromANS(content)) + (imageOverrideURL || ansImage ? { ansImage: imageOverrideURL ? { @@ -347,11 +357,11 @@ const LargePromoItem = ({ customFields, arcSite }) => { url: imageOverrideURL, auth: resizedAuth || {}, } - : getImageFromANS(content), + : ansImage, alt: content?.headlines?.basic || "", aspectRatio: imageRatio, resizedOptions: { - smart: true, + ...getFocalFromANS(ansImage), }, responsiveImages: [400, 600, 800, 1200], width: 377, diff --git a/blocks/lead-art-block/features/leadart/default.jsx b/blocks/lead-art-block/features/leadart/default.jsx index c59397c39a..0cd5136a9d 100644 --- a/blocks/lead-art-block/features/leadart/default.jsx +++ b/blocks/lead-art-block/features/leadart/default.jsx @@ -9,6 +9,7 @@ import { Carousel, formatCredits, formatPowaVideoEmbed, + getFocalFromANS, Icon, Image, MediaItem, @@ -140,12 +141,12 @@ export const LeadArtPresentation = (props) => {
{leadArt.alt_text} {isOpen ? (