diff --git a/react/src/js/components/Consonant/Grid/Grid.jsx b/react/src/js/components/Consonant/Grid/Grid.jsx index 7761b33e..541634fa 100644 --- a/react/src/js/components/Consonant/Grid/Grid.jsx +++ b/react/src/js/components/Consonant/Grid/Grid.jsx @@ -13,7 +13,7 @@ import parseHTML from 'html-react-parser'; import FullCard from '../Cards/Full'; import { cardType } from '../types/card'; -import { getByPath } from '../Helpers/general'; +import { getByPath, getHideCta } from '../Helpers/general'; import { useConfig } from '../Helpers/hooks'; import ThreeFourthCard from '../Cards/ThreeFourth'; import OneHalfCard from '../Cards/OneHalf'; @@ -203,6 +203,7 @@ const Grid = (props) => { const cardStyle = collectionStyleOverride || cardStyleOverride; const { contentArea: { title = '' } = {}, id } = card; const cardNumber = index + 1; + const hideCTA = getHideCta(card, collectionButtonStyle); switch (cardStyle) { case CARD_STYLES.FULL: @@ -257,7 +258,7 @@ const Grid = (props) => { renderBorder={renderCardsBorders} {...card} renderOverlay={renderCardsOverlay} - hideCTA={collectionButtonStyle === 'hidden'} + hideCTA={hideCTA} onFocus={() => scrollCardIntoView(card.id)} /> ); case CARD_STYLES.TEXT: @@ -272,7 +273,7 @@ const Grid = (props) => { locale={locale} renderBorder={renderCardsBorders} renderOverlay={renderCardsOverlay} - hideCTA={collectionButtonStyle === 'hidden'} + hideCTA={hideCTA} onFocus={() => scrollCardIntoView(card.id)} /> ); case CARD_STYLES.CUSTOM: @@ -289,7 +290,7 @@ const Grid = (props) => { locale={locale} renderBorder={renderCardsBorders} renderOverlay={renderCardsOverlay} - hideCTA={collectionButtonStyle === 'hidden'} + hideCTA={hideCTA} onFocus={() => scrollCardIntoView(card.id)} /> ); } diff --git a/react/src/js/components/Consonant/Helpers/general.js b/react/src/js/components/Consonant/Helpers/general.js index bd0009a2..f413aad4 100644 --- a/react/src/js/components/Consonant/Helpers/general.js +++ b/react/src/js/components/Consonant/Helpers/general.js @@ -320,6 +320,17 @@ export const getByPath = (object, path, defaultValue) => { return result; }; +/** + * Determines whether ctas should be hidden on a given card + * @param {Object} object - object to get value + * @param {String} style - the collection button style + * @returns {bool} - whether a cta should be hidden + */ +export const getHideCta = (object, style) => { + if (object.hideCtaId || style === 'hidden') return true; + return false; +}; + /** * Return sum of the selected filters * @param {items} array - filter items